DDS  ver. 3.4
Classes | Namespaces | Macros
IXMLPersist.h File Reference
#include "XMLHelper.h"

Go to the source code of this file.

Classes

struct  MiscCommon::IXMLPersistImpl< _T >
 The IXMLPersistImpl interface is a class of the XML persistance. More...
 

Namespaces

 MiscCommon
 Miscellaneous functions and helpers are located here.
 

Macros

#define DECLARE_XMLPERSIST_IMPL(_T)   friend class MiscCommon::IXMLPersistImpl<_T>;
 Declares an XML Persist Interface for user's class. More...
 
#define BEGIN_READ_XML_NODE(_T, _ELEMENT_NAME)
 The BEGIN_READ_XML_NODE macro precedes the sequence of READ_NODE_VALUE. More...
 
#define READ_NODE_ATTR(ELEMENT_NAME, VAR)   MiscCommon::XMLHelper::get_attr_value(elementConfig, ELEMENT_NAME, &VAR);
 Reads attributes of the node from XML file. More...
 
#define READ_NODE_VALUE(NODE_NAME, VAR)   MiscCommon::XMLHelper::get_node_value(elementConfig, NODE_NAME, &VAR);
 
#define END_READ_XML_NODE   }
 Closes the sequence of READ_NODE_VALUE. More...
 
#define BEGIN_READ_XML_CFG(_T)   BEGIN_READ_XML_NODE(_T, "config")
 The BEGIN_READ_XML_CFG(_T) macro precedes the sequence of READ_NODE_VALUE. More...
 
#define END_READ_XML_CFG   }
 Closes the sequence of READ_NODE_VALUE. More...
 
#define BEGIN_WRITE_XML_CFG(_T)
 
#define END_WRITE_XML_CFG   }
 

Macro Definition Documentation

◆ BEGIN_READ_XML_CFG

#define BEGIN_READ_XML_CFG (   _T)    BEGIN_READ_XML_NODE(_T, "config")

The BEGIN_READ_XML_CFG(_T) macro precedes the sequence of READ_NODE_VALUE.

Parameters
[in]_T- Name of the parent class.
Note
Example
class CMyClass : public MiscCommon::IXMLPersistImpl<CMyClass>
{
...
public:
private:
// IXMLPersist implementation
BEGIN_READ_XML_CFG(CCatalogManager)
READ_NODE_VALUE( "lfc_host", m_Data.m_sLFCHost )
READ_NODE_VALUE( "lfc_wrkdir", m_Data.m_sWrkDir )
READ_NODE_VALUE( "lfc_session_comment", m_Data.m_sLFCSessionComment )
...
};

◆ BEGIN_READ_XML_NODE

#define BEGIN_READ_XML_NODE (   _T,
  _ELEMENT_NAME 
)
Value:
void ReadXmlCfg(xercesc::DOMNode* _element) \
{ \
const std::string str("An internal error has been detected. Can't read configuration of " + std::string(#_T) + \
" manager, "); \
if (!_element) \
throw std::invalid_argument(str + "DOMNode is NULL."); \
MiscCommon::XMLHelper::smart_XMLCh ElementName(_ELEMENT_NAME); \
xercesc::DOMElement* config_element(dynamic_cast<xercesc::DOMElement*>(_element)); \
if (!config_element) \
throw std::runtime_error(str + "element " + std::string(#_ELEMENT_NAME) + " is missing"); \
xercesc::DOMNodeList* list(config_element->getElementsByTagName(ElementName)); \
if (!list) \
throw std::runtime_error(str + "element " + std::string(#_ELEMENT_NAME) + " is missing"); \
xercesc::DOMNode* node(list->item(0)); \
if (!node) \
throw std::runtime_error(str + "element " + std::string(#_ELEMENT_NAME) + " is missing"); \
xercesc::DOMElement* elementConfig(NULL); \
if (xercesc::DOMNode::ELEMENT_NODE == node->getNodeType()) \
elementConfig = dynamic_cast<xercesc::DOMElement*>(node); \
if (!elementConfig) \
throw std::runtime_error(str + "empty XML document");
#define _T(s)
Use TCHAR instead of char or wchar_t. It will be appropriately translated.
Definition: def.h:85

The BEGIN_READ_XML_NODE macro precedes the sequence of READ_NODE_VALUE.

Parameters
[in]_T- Name of the parent class.
[in]_ELEMENT_NAME- Name of the XML element to read.

◆ BEGIN_WRITE_XML_CFG

#define BEGIN_WRITE_XML_CFG (   _T)
Value:
void WriteXmlCfg(xercesc::DOMNode* /*_element*/) \
{

◆ DECLARE_XMLPERSIST_IMPL

#define DECLARE_XMLPERSIST_IMPL (   _T)    friend class MiscCommon::IXMLPersistImpl<_T>;

Declares an XML Persist Interface for user's class.

Parameters
[in]_T- name of the parent class.
Note
Example
class CMyClass : public MiscCommon::IXMLPersistImpl<CMyClass>
{
...
public:
...
};

◆ END_READ_XML_CFG

#define END_READ_XML_CFG   }

Closes the sequence of READ_NODE_VALUE.

Note
see the example of BEGIN_READ_XML_CFG(_T)

◆ END_READ_XML_NODE

#define END_READ_XML_NODE   }

Closes the sequence of READ_NODE_VALUE.

◆ END_WRITE_XML_CFG

#define END_WRITE_XML_CFG   }

◆ READ_NODE_ATTR

#define READ_NODE_ATTR (   ELEMENT_NAME,
  VAR 
)    MiscCommon::XMLHelper::get_attr_value(elementConfig, ELEMENT_NAME, &VAR);

Reads attributes of the node from XML file.

Parameters
[in]ELEMENT_NAME- Name of the XML element to read.
[in,out]VAR- A buffer where value of the XML elements should be stored in.

◆ READ_NODE_VALUE

#define READ_NODE_VALUE (   NODE_NAME,
  VAR 
)    MiscCommon::XMLHelper::get_node_value(elementConfig, NODE_NAME, &VAR);