SHAPER  9.12.0
Config_XMLReader Class Reference

Base class for all libxml readers. Provides high-level API for all xml operations. More...

Inheritance diagram for Config_XMLReader:
Inheritance graph

Public Member Functions

CONFIG_EXPORT Config_XMLReader (const std::string &theXmlFile, bool isXMLContent=false)
 
CONFIG_EXPORT void readAll ()
 
CONFIG_EXPORT xmlNodePtr findRoot (const std::string theDocumentPath="")
 
CONFIG_EXPORT const char * encoding () const
 

Static Public Member Functions

static CONFIG_EXPORT std::string resourcesConfigFile ()
 
static CONFIG_EXPORT std::string pluginConfigFile ()
 
static CONFIG_EXPORT std::string findConfigFile (const std::string theFileName, const int theFindIndex=0)
 Checks all possible paths to configuration file given Uses theFindIndex if several solutions can be found (this is the number of solution to find) More...
 

Protected Member Functions

virtual void processNode (xmlNodePtr aNode)
 Allows to customize reader's behavior for a node. Virtual. The default implementation process "source" and "validator" nodes. More...
 
virtual void cleanup (xmlNodePtr aNode)
 
virtual bool processChildren (xmlNodePtr aNode)
 Defines which nodes should be processed recursively. Virtual. The default impl is to read all nodes. More...
 
void readRecursively (xmlNodePtr theParent)
 
xmlNodePtr node (void *theNode)
 void* -> xmlNodePtr More...
 
std::string getNodeName (xmlNodePtr theNode)
 Gets xml node name. More...
 
void storeAttribute (xmlNodePtr theNode, const char *theNodeAttribute, bool doClean=false)
 Stores an attribute in internal map for later use. More...
 
std::string restoreAttribute (xmlNodePtr theNode, const char *theNodeAttribute)
 Restores an attribute from internal map. More...
 
std::string restoreAttribute (const char *theNodeName, const char *theNodeAttribute)
 Restores an attribute from internal map. More...
 
bool cleanupAttribute (xmlNodePtr theNode, const char *theNodeAttribute)
 Cleanups attribute from cache. More...
 
bool cleanupAttribute (const char *theNodeName, const char *theNodeAttribute)
 Cleanups attribute from cache. More...
 

Protected Attributes

std::string myDocumentPath
 Path to the xml document. More...
 
xmlDocPtr myXmlDoc
 Root of the xml document. More...
 
std::string myRootFileName
 name of the root file More...
 
std::map< std::string, std::string > myCachedAttributes
 A map to store all parent's attributes. More...
 
bool isFromMemory
 

Detailed Description

Base class for all libxml readers. Provides high-level API for all xml operations.

Constructor & Destructor Documentation

◆ Config_XMLReader()

Config_XMLReader::Config_XMLReader ( const std::string &  theXmlFile,
bool  isXMLContent = false 
)

Constructor

Parameters
theXmlFile- full path to the xml file which will be processed by the reader

Member Function Documentation

◆ resourcesConfigFile()

std::string Config_XMLReader::resourcesConfigFile ( )
static

Returns a path to resource files (created from ROOT_DIR environment variable)

Returns
string value

◆ pluginConfigFile()

std::string Config_XMLReader::pluginConfigFile ( )
static

Returns a path to the plugins.xml file (created from ROOT_DIR environment variable)

Returns
string value

◆ readAll()

void Config_XMLReader::readAll ( )

Read all nodes in associated xml file, recursively if processChildren(xmlNode) is true for the xmlNode. For each read node the processNode will be called.

◆ findRoot()

xmlNodePtr Config_XMLReader::findRoot ( const std::string  theDocumentPath = "")

Returns xmlNodePtr to the root of reader's document or NULL if not found. If the path to the document to read is empty, uses myDocumentPath.

◆ findConfigFile()

std::string Config_XMLReader::findConfigFile ( const std::string  theFileName,
const int  theFindIndex = 0 
)
static

Checks all possible paths to configuration file given Uses theFindIndex if several solutions can be found (this is the number of solution to find)

◆ processNode()

void Config_XMLReader::processNode ( xmlNodePtr  aNode)
protectedvirtual

Allows to customize reader's behavior for a node. Virtual. The default implementation process "source" and "validator" nodes.

Reimplemented in Config_WidgetReader, Config_TSReader, Config_DataModelReader, Config_ValidatorReader, Config_ModuleReader, and Config_FeatureReader.

◆ cleanup()

void Config_XMLReader::cleanup ( xmlNodePtr  aNode)
protectedvirtual

This method gives an ability to finalize processing of a node, when reader is about to leave the node (node and all it's children are processed)

Reimplemented in Config_ValidatorReader, and Config_FeatureReader.

◆ processChildren()

bool Config_XMLReader::processChildren ( xmlNodePtr  aNode)
protectedvirtual

Defines which nodes should be processed recursively. Virtual. The default impl is to read all nodes.

Reimplemented in Config_WidgetReader, Config_ValidatorReader, Config_ModuleReader, and Config_FeatureReader.

◆ readRecursively()

void Config_XMLReader::readRecursively ( xmlNodePtr  theParent)
protected

Calls processNode() for each child (for some - recursively) of the given node.

See also
ReadAll()

◆ node()

xmlNodePtr Config_XMLReader::node ( void *  theNode)
protected

void* -> xmlNodePtr

◆ getNodeName()

std::string Config_XMLReader::getNodeName ( xmlNodePtr  theNode)
protected

Gets xml node name.

◆ storeAttribute()

void Config_XMLReader::storeAttribute ( xmlNodePtr  theNode,
const char *  theNodeAttribute,
bool  doClean = false 
)
protected

Stores an attribute in internal map for later use.

Key is "Node_Name:Node_Attribute" and value is getProperty(theNodeAttribute)

◆ restoreAttribute() [1/2]

std::string Config_XMLReader::restoreAttribute ( xmlNodePtr  theNode,
const char *  theNodeAttribute 
)
protected

Restores an attribute from internal map.

◆ restoreAttribute() [2/2]

std::string Config_XMLReader::restoreAttribute ( const char *  theNodeName,
const char *  theNodeAttribute 
)
protected

Restores an attribute from internal map.

◆ cleanupAttribute() [1/2]

bool Config_XMLReader::cleanupAttribute ( xmlNodePtr  theNode,
const char *  theNodeAttribute 
)
protected

Cleanups attribute from cache.

◆ cleanupAttribute() [2/2]

bool Config_XMLReader::cleanupAttribute ( const char *  theNodeName,
const char *  theNodeAttribute 
)
protected

Cleanups attribute from cache.

Field Documentation

◆ myDocumentPath

std::string Config_XMLReader::myDocumentPath
protected

Path to the xml document.

◆ myXmlDoc

xmlDocPtr Config_XMLReader::myXmlDoc
protected

Root of the xml document.

◆ myRootFileName

std::string Config_XMLReader::myRootFileName
protected

name of the root file

◆ myCachedAttributes

std::map<std::string, std::string> Config_XMLReader::myCachedAttributes
protected

A map to store all parent's attributes.

The key has from "Node_Name:Node_Attribute"