CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Attributes
FWXMLConfigParser Class Reference

#include <FWXMLConfigParser.h>

Inheritance diagram for FWXMLConfigParser:
SimpleSAXParser

Public Member Functions

FWConfigurationconfig (void)
 
virtual void data (const std::string &data) override
 
void debug_config_state_machine (const char *where, const std::string &tag, int state)
 
virtual void endElement (const std::string &tag) override
 
 FWXMLConfigParser (std::istream &f)
 
void pushConfig (Attributes &attributes)
 
virtual void startElement (const std::string &tag, Attributes &attributes) override
 
- Public Member Functions inherited from SimpleSAXParser
void parse (void)
 
 SimpleSAXParser (std::istream &f)
 
virtual ~SimpleSAXParser ()
 

Private Types

enum  STATES {
  IN_BEGIN_DOCUMENT, IN_PUSHED_CONFIG, IN_POPPED_CONFIG, IN_BEGIN_STRING,
  IN_STORED_STRING
}
 

Private Attributes

std::vector< std::pair
< std::string, FWConfiguration * > > 
m_configs
 
std::string m_currentConfigName
 
std::auto_ptr< FWConfigurationm_first
 
enum STATES m_state
 

Additional Inherited Members

- Public Types inherited from SimpleSAXParser
typedef std::vector< AttributeAttributes
 
enum  PARSER_STATES {
  IN_DOCUMENT, IN_BEGIN_TAG, IN_DONE, IN_BEGIN_ELEMENT,
  IN_ELEMENT_WHITESPACE, IN_END_ELEMENT, IN_ATTRIBUTE_KEY, IN_END_TAG,
  IN_DATA, IN_BEGIN_ATTRIBUTE_VALUE, IN_STRING, IN_END_ATTRIBUTE_VALUE,
  IN_STRING_ENTITY, IN_DATA_ENTITY
}
 

Detailed Description

Helper class which reads the XML configuration and constructs the FWConfiguration classes.

State machine for the parser can be found by cut and pasting the following in graphviz.

digraph { IN_BEGIN_DOCUMENT->IN_PUSHED_CONFIG [label = "beginElement(config)"]

IN_PUSHED_CONFIG->IN_PUSHED_CONFIG [label = "beginElement(config)"] IN_PUSHED_CONFIG->IN_POPPED_CONFIG [label = "endElement(config)"] IN_PUSHED_CONFIG->IN_BEGIN_STRING [label = "beginElement(string)"]

IN_POPPED_CONFIG->IN_PUSHED_CONFIG [label = "beginElement(config)"] IN_POPPED_CONFIG->IN_POPPED_CONFIG [label = "endElement(config)"] IN_POPPED_CONFIG->DONE [label = "top level config popped"]

IN_BEGIN_STRING->IN_STORED_STRING [label = "data()"]; IN_BEGIN_STRING->IN_PUSHED_CONFIG [label = "endElement(string)"]

IN_STORED_STRING->IN_PUSHED_CONFIG [label = "endElement(string)"] }

Definition at line 33 of file FWXMLConfigParser.h.

Member Enumeration Documentation

Enumerator
IN_BEGIN_DOCUMENT 
IN_PUSHED_CONFIG 
IN_POPPED_CONFIG 
IN_BEGIN_STRING 
IN_STORED_STRING 

Definition at line 35 of file FWXMLConfigParser.h.

Constructor & Destructor Documentation

FWXMLConfigParser::FWXMLConfigParser ( std::istream &  f)
inline

Definition at line 44 of file FWXMLConfigParser.h.

Member Function Documentation

FWConfiguration* FWXMLConfigParser::config ( void  )
inline

The parsed configuration. Notice that the parser owns it and destroys it when destroyed.

Definition at line 164 of file FWXMLConfigParser.h.

virtual void FWXMLConfigParser::data ( const std::string &  data)
inlineoverridevirtual

Executes any transaction in the state machine which happens when the xml parser finds some data (i.e. text) between tags This is mainly used to handle <string> element contents but also whitespace between tags.

Reimplemented from SimpleSAXParser.

Definition at line 147 of file FWXMLConfigParser.h.

void FWXMLConfigParser::debug_config_state_machine ( const char *  where,
const std::string &  tag,
int  state 
)
inline

Definition at line 171 of file FWXMLConfigParser.h.

virtual void FWXMLConfigParser::endElement ( const std::string &  tag)
inlineoverridevirtual

Executes any transaction in the state machine which happens when the xml parser closes an element.

Notice that we need to do addKeyValue on endElement (and carry around the FWConfigutation name) because of the "copy by value" policy of addKeyValue addition which would add empty FWConfiguration objects if done on startElement.

Reimplemented from SimpleSAXParser.

Definition at line 116 of file FWXMLConfigParser.h.

void FWXMLConfigParser::pushConfig ( Attributes attributes)
inline

Pushes the configuration on stack eventually

Definition at line 51 of file FWXMLConfigParser.h.

virtual void FWXMLConfigParser::startElement ( const std::string &  tag,
Attributes attributes 
)
inlineoverridevirtual

Executes any transaction in the state machine which happens when the xml parser finds an new element.

Reimplemented from SimpleSAXParser.

Definition at line 77 of file FWXMLConfigParser.h.

Member Data Documentation

std::vector<std::pair<std::string, FWConfiguration *> > FWXMLConfigParser::m_configs
private

Definition at line 187 of file FWXMLConfigParser.h.

std::string FWXMLConfigParser::m_currentConfigName
private

Definition at line 191 of file FWXMLConfigParser.h.

std::auto_ptr<FWConfiguration> FWXMLConfigParser::m_first
private

Definition at line 189 of file FWXMLConfigParser.h.

enum STATES FWXMLConfigParser::m_state
private

Definition at line 188 of file FWXMLConfigParser.h.