This class will read in an XML-file and call the appropriate handler functions of the Object classes and objects. More...
#include <utils.h>

Public Types | |
typedef pair< Attribute, XMLElement > | datapair |
Public Member Functions | |
bool | getAbortOnDataError () const |
const AttributeList & | getAttributes () const |
const datapair & | getCurrentElement () const |
const datapair & | getParentElement () const |
Object * | getParentObject () const |
Object * | getPreviousObject () const |
void * | getUserArea () const |
void | IgnoreElement () |
void | invalidateCurrentObject () |
bool | isObjectEnd () |
void | parse (xercesc::InputSource &, Object *, bool=false) |
void | readto (Object *) |
void | setAbortOnDataError (bool i) |
void | setUserArea (void *v) |
void | shutdown () |
XMLInput (unsigned short maxNestedElmnts=20) | |
virtual | ~XMLInput () |
Protected Member Functions | |
virtual void | parse (Object *s, bool b=false) |
Detailed Description
This class will read in an XML-file and call the appropriate handler functions of the Object classes and objects.
This class is implemented based on the Xerces SAX XML parser. For debugging purposes a flag is defined at the start of the file "xmlparser.cpp". Uncomment the line and recompile to use it.
FrePPLe creates a new parser and loads the XML schema every time XML data need to be parsed. When this happens only a few times during a run this is good enough.
However, when the libary has to parse plenty of small XML messages this will create a significant overhead. The code would need to be enhanced to maintain a pool of parsers and cache their grammars.
Member Typedef Documentation
typedef pair<Attribute,XMLElement> frepple::utils::XMLInput::datapair |
Constructor & Destructor Documentation
frepple::utils::XMLInput::XMLInput | ( | unsigned short | maxNestedElmnts = 20 | ) | [inline] |
virtual frepple::utils::XMLInput::~XMLInput | ( | ) | [inline, virtual] |
Member Function Documentation
bool frepple::utils::XMLInput::getAbortOnDataError | ( | ) | const [inline] |
Returns the behavior of the parser in case of data errors.
When true is returned, the processing of the XML stream continues after a DataException. Other, more critical, exceptions types will still abort the parsing process.
False indicates that the processing of the XML stream is aborted.
const AttributeList& frepple::utils::XMLInput::getAttributes | ( | ) | const [inline] |
const datapair& frepple::utils::XMLInput::getCurrentElement | ( | ) | const [inline] |
const datapair& frepple::utils::XMLInput::getParentElement | ( | ) | const [inline] |
Object* frepple::utils::XMLInput::getParentObject | ( | ) | const [inline] |
Object* frepple::utils::XMLInput::getPreviousObject | ( | ) | const [inline] |
Return a pointer to the previous object being read in.
In a typical use the returned pointer will require a dynamic_cast to a subclass type.
The typical usage is as follows:
Operation *o = dynamic_cast<Operation*>(pIn.getPreviousObject()); if (o) doSomeThing(o); else throw LogicException("Incorrect object type");
void* frepple::utils::XMLInput::getUserArea | ( | ) | const [inline] |
void frepple::utils::XMLInput::IgnoreElement | ( | ) | [inline] |
void frepple::utils::XMLInput::invalidateCurrentObject | ( | ) | [inline] |
bool frepple::utils::XMLInput::isObjectEnd | ( | ) | [inline] |
void frepple::utils::XMLInput::parse | ( | xercesc::InputSource & | in, |
Object * | pRoot, | ||
bool | validate = false |
||
) |
This is the core parsing function, which triggers the XML parser to start processing the input. It is normally called from the method parse(Object*) once a proper stream has been created.
- See also:
- parse(Object*)
Definition at line 444 of file xmlparser.cpp.
virtual void frepple::utils::XMLInput::parse | ( | Object * | s, |
bool | b = false |
||
) | [inline, protected, virtual] |
The real parsing job is delegated to subclasses. Subclass can then define the specifics for parsing a flat file, a string, a SOAP message, etc...
- Exceptions:
-
RuntimeException Thrown in the following situations: - the xml-document is incorrectly formatted
- the xml-parser librabry can't be initialized
- no memory can be allocated to the xml-parser
DataException Thrown when the data can't be processed normally by the objects being created or updated.
Reimplemented in frepple::utils::XMLInputFile, and frepple::utils::XMLInputString.
void frepple::utils::XMLInput::readto | ( | Object * | pPI | ) |
Redirect event stream into a new Object.
It is also possible to pass a NULL pointer to the function. In that situation, we simple ignore the content of that element.
Important: The user is reponsible of making sure the argument object has a proper write-lock. The release of that lock is handled by the parser.
Definition at line 340 of file xmlparser.cpp.
void frepple::utils::XMLInput::setAbortOnDataError | ( | bool | i | ) | [inline] |
void frepple::utils::XMLInput::setUserArea | ( | void * | v | ) | [inline] |
void frepple::utils::XMLInput::shutdown | ( | ) |
Abort the parsing. The actual shutdown cannot be called inside a SAX handler function, so actual shutdown is deferred until the next iteration of the feed loop.
Definition at line 367 of file xmlparser.cpp.
The documentation for this class was generated from the following files:
Documentation generated for frePPLe by
