nomlib
Loading...
Searching...
No Matches
nom::RapidXmlSerializer Class Reference

Number of spaces to pass to RapidXml for indention. More...

#include <RapidXmlSerializer.hpp>

Inheritance diagram for nom::RapidXmlSerializer:
[legend]

Public Types

typedef RapidXmlSerializer SelfType
Public Types inherited from nom::IValueSerializer
typedef IValueSerializer self_type
typedef self_type * raw_ptr
typedef std::unique_ptr< self_type > unique_ptr
typedef std::shared_ptr< self_type > shared_ptr

Public Member Functions

 RapidXmlSerializer (void)
 Default constructor; initialize the writer with human friendly output.
 ~RapidXmlSerializer (void)
 Destructor.
 RapidXmlSerializer (enum SerializerOptions options)
 Construct a parser with a feature set enumeration.
std::string serialize (const Value &source)
 Output a nom::Value object to a string.
bool save (const Value &source, const std::string &filename)
 Save nom::Value values to XML nodes.

Private Member Functions

bool write (const Value &source, rapidxml::xml_document< char > &dest) const
bool write_value (const Value &object, const std::string &key, rapidxml::xml_document< char > &doc, rapidxml::xml_node< char > *parent) const
bool write_array (const Value &object, const std::string &key, rapidxml::xml_document< char > &doc, rapidxml::xml_node< char > *parent) const
 Internal helper method for serialization of array nodes.
bool write_object (const Value &object, const std::string &key, rapidxml::xml_document< char > &doc, rapidxml::xml_node< char > *parent) const
 Internal helper method for serialization of object nodes.
const char * stralloc (const std::string &buffer, rapidxml::xml_document< char > &dest) const
void append_decl (rapidxml::xml_document< char > &dest) const
 Add the top-level XML node declaring the version and encoding used (think: DOCTYPE).

Private Attributes

enum SerializerOptions options_

Detailed Description

Number of spaces to pass to RapidXml for indention.

Remarks
Two space tabbed indention.
Todo
Implement feature

Saving of nom::Value objects to XML documents using the RapidXml library.

[TO BE WRITTEN]

References

  1. http://sfmlcoder.wordpress.com/2011/05/29/a-lightweight-xml-parser-rapid-xml/
  2. http://www.w3schools.com/xml/xml_attributes.asp

    Todo
    Implement XML comments
    Todo
    Finish implementation of ::serialize_object & related case handling, err handling.

Definition at line 68 of file RapidXmlSerializer.hpp.

Member Typedef Documentation

◆ SelfType

typedef RapidXmlSerializer nom::RapidXmlSerializer::SelfType

Definition at line 71 of file RapidXmlSerializer.hpp.

Constructor & Destructor Documentation

◆ RapidXmlSerializer()

nom::RapidXmlSerializer::RapidXmlSerializer ( void )

Default constructor; initialize the writer with human friendly output.

Remarks
See the SerializerOptions enumeration for more information.

Member Function Documentation

◆ append_decl()

void nom::RapidXmlSerializer::append_decl ( rapidxml::xml_document< char > & dest) const
private

Add the top-level XML node declaring the version and encoding used (think: DOCTYPE).

Parameters
destThe document to append the declaration onto.
Remarks
This is automatically added to all serialized XML output.

◆ save()

bool nom::RapidXmlSerializer::save ( const Value & source,
const std::string & filename )
virtual

Save nom::Value values to XML nodes.

Parameters
sourcenom::Value container to serialize from.
filenameAbsolute file path to output resulting data to.
Remarks
The source input will automatically have the standard XML DOCTYPE prepended onto the resulting output. See ::append_decl method for details.
Note
Implements ISerializer interface.

Implements nom::IValueSerializer.

◆ serialize()

std::string nom::RapidXmlSerializer::serialize ( const Value & source)
virtual

Output a nom::Value object to a string.

Parameters
sourcenom::Value container to serialize from.
Returns
std::string with XML-conforming output on success, or a null- terminated string on err.
Note
Implements ISerializer interface.

Implements nom::IValueSerializer.

Member Data Documentation

◆ options_

enum SerializerOptions nom::RapidXmlSerializer::options_
private

Definition at line 108 of file RapidXmlSerializer.hpp.


The documentation for this class was generated from the following file: