commonlib
XmlSerializer Class Reference

XmlSerializer class implements functions for parsing xml files or xml streams using libxml2 library and for writing to an xml file or streams. More...

#include <xml_serializer.h>

Static Public Member Functions

static DxDocumentPtr dxDocumentCreate ()
 Function creates new DxDocument. More...
 
static void dxDocumentDestroy (DxDocumentPtr &document)
 Function recursively clears all child nodes and sets document pointer to nullptr. More...
 
static DxNodePtr dxDocumentGetStartNode (const DxDocumentPtr &document)
 Function returns a shared pointer to a root node (start node). More...
 
static void dxDocumentSetStartNode (const DxDocumentPtr &document, const DxNodePtr &startNode)
 Function sets a root node (start node) to a given document. More...
 
static void dxDocumentWriteToFile (const DxDocumentPtr &document, const std::string &fileName, const DxDocumentWriteParameters writeParams)
 Function writes a document to a file stream. More...
 
static void dxDocumentWriteToStream (const DxDocumentPtr &document, std::ostream &outStream, const DxDocumentWriteParameters writeParams)
 Function writes a document to a ostream. More...
 
static DxDocumentPtr dxDocumentParse (const std::string &fileName)
 Function reads and parses an xml file using libxml2 library and returns parsed document. More...
 
static DxDocumentPtr dxDocumentParseStream (std::istream &inStream)
 Function reads and parses an xml istream using libxml2 library and returns parsed document. More...
 

Detailed Description

XmlSerializer class implements functions for parsing xml files or xml streams using libxml2 library and for writing to an xml file or streams.

Member Function Documentation

◆ dxDocumentCreate()

static DxDocumentPtr XmlSerializer::dxDocumentCreate ( )
static

Function creates new DxDocument.

Returns
Returns a shared pointer to newly created DxDocument

◆ dxDocumentDestroy()

static void XmlSerializer::dxDocumentDestroy ( DxDocumentPtr &  document)
static

Function recursively clears all child nodes and sets document pointer to nullptr.

Parameters
documentShared pointer to a document

◆ dxDocumentGetStartNode()

static DxNodePtr XmlSerializer::dxDocumentGetStartNode ( const DxDocumentPtr &  document)
static

Function returns a shared pointer to a root node (start node).

Parameters
documentShared pointer to a document
Returns
A shared pointer to a root node

◆ dxDocumentParse()

static DxDocumentPtr XmlSerializer::dxDocumentParse ( const std::string &  fileName)
static

Function reads and parses an xml file using libxml2 library and returns parsed document.

Parameters
fileNameXml file name
Returns
A shared pointer to a newly created document. If xml file is not valid it returns a nullptr

◆ dxDocumentParseStream()

static DxDocumentPtr XmlSerializer::dxDocumentParseStream ( std::istream &  inStream)
static

Function reads and parses an xml istream using libxml2 library and returns parsed document.

Parameters
inStreaminput stream
Returns
A shared pointer to a newly created document.

◆ dxDocumentSetStartNode()

static void XmlSerializer::dxDocumentSetStartNode ( const DxDocumentPtr &  document,
const DxNodePtr &  startNode 
)
static

Function sets a root node (start node) to a given document.

Parameters
documentShared pointer to a document
startNodeShared pointer to a node

◆ dxDocumentWriteToFile()

static void XmlSerializer::dxDocumentWriteToFile ( const DxDocumentPtr &  document,
const std::string &  fileName,
const DxDocumentWriteParameters  writeParams 
)
static

Function writes a document to a file stream.

Parameters
documentShared pointer to a document
fileNameXml file name
writeParamsA struct that contains information if document nodes should be indented

◆ dxDocumentWriteToStream()

static void XmlSerializer::dxDocumentWriteToStream ( const DxDocumentPtr &  document,
std::ostream &  outStream,
const DxDocumentWriteParameters  writeParams 
)
static

Function writes a document to a ostream.

Parameters
documentShared pointer to a document
outStreamoutput stream
writeParamsA struct that contains information if document nodes should be indented

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