This class will read in an XML-file and call the appropriate handler functions of the Object classes and objects.
More...
List of all members.
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.
Definition at line 3967 of file utils.h.
Member Typedef Documentation
Constructor & Destructor Documentation
frepple::utils::XMLInput::XMLInput |
( |
unsigned short |
maxNestedElmnts = 20 |
) |
[inline] |
Constructor.
- Parameters:
-
| maxNestedElmnts | Defines the maximum depth of elements an XML document is allowed to have. The default is 20. |
Definition at line 4118 of file utils.h.
virtual frepple::utils::XMLInput::~XMLInput |
( |
|
) |
[inline, virtual] |
Member Function Documentation
void frepple::utils::XMLInput::executeCommands |
( |
|
) |
[protected] |
Execute the commands that have been read from the input stream.
Definition at line 777 of file xmlparser.cpp.
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.
Definition at line 4218 of file utils.h.
const AttributeList& frepple::utils::XMLInput::getAttributes |
( |
|
) |
const [inline] |
Return a pointer to an array of character pointer which point to the attributes. See the xerces documentation if this description doesn't satisfy you...
Definition at line 4130 of file utils.h.
CommandList& frepple::utils::XMLInput::getCommands |
( |
|
) |
[inline] |
Return a reference to the list of commands.
Definition at line 4221 of file utils.h.
const datapair& frepple::utils::XMLInput::getCurrentElement |
( |
|
) |
const [inline] |
Returns a reference to the current element.
Definition at line 4189 of file utils.h.
const datapair& frepple::utils::XMLInput::getParentElement |
( |
|
) |
const [inline] |
Returns a reference to the parent element.
Definition at line 4185 of file utils.h.
Object* frepple::utils::XMLInput::getParentObject |
( |
|
) |
const [inline] |
Clears the previously read object.
Definition at line 4178 of file utils.h.
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");
Definition at line 4175 of file utils.h.
void* frepple::utils::XMLInput::getUserArea |
( |
|
) |
const [inline] |
Returns the user definable pointer.
Definition at line 4205 of file utils.h.
void frepple::utils::XMLInput::IgnoreElement |
( |
|
) |
[inline] |
Ignore an element.
Definition at line 4149 of file utils.h.
void frepple::utils::XMLInput::invalidateCurrentObject |
( |
|
) |
[inline] |
Invalidates the current object.
This method is useful when, for instance, the object being parsed is being deleted.
Definition at line 4159 of file utils.h.
bool frepple::utils::XMLInput::isObjectEnd |
( |
|
) |
[inline] |
Returns true if the current object is finishing with the current tag. This method should only be used in the endElement() method.
Definition at line 4153 of file utils.h.
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::XMLInputString, and frepple::utils::XMLInputFile.
Definition at line 4234 of file utils.h.
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 448 of file xmlparser.cpp.
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 344 of file xmlparser.cpp.
void frepple::utils::XMLInput::setAbortOnDataError |
( |
bool |
i |
) |
[inline] |
Updates whether we ignore data exceptions or whether we abort the processing of the XML data stream.
Definition at line 4210 of file utils.h.
void frepple::utils::XMLInput::setUserArea |
( |
void * |
v |
) |
[inline] |
Updates the user definable pointer. This pointer is used to store status information between handler calls.
Definition at line 4201 of file utils.h.
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 371 of file xmlparser.cpp.
The documentation for this class was generated from the following files: