![]() |
XRootD
|
#include <XrdXmlReader.hh>
Public Member Functions | |
XrdXmlReader () | |
Constructor & Destructor. More... | |
virtual | ~XrdXmlReader () |
virtual bool | GetAttributes (const char **aname, char **aval)=0 |
virtual int | GetElement (const char **ename, bool reqd=false)=0 |
virtual const char * | GetError (int &ecode)=0 |
virtual char * | GetText (const char *ename, bool reqd=false)=0 |
Static Public Member Functions | |
static XrdXmlReader * | GetReader (const char *fname, const char *enc=0, const char *impl=0) |
static bool | Init (const char *impl=0) |
The XrdXmlReader object provides a virtual interface to read xml files, irrespective of the underlying mplementation. Obtain an XML reader using GetRead(). You may also wish to call Init() prior to obtaining a reader in multi-threader applications. As some implementations may not be MT-safe. See GetReader() for more information.
Definition at line 40 of file XrdXmlReader.hh.
|
inline |
|
inlinevirtual |
Definition at line 165 of file XrdXmlReader.hh.
|
pure virtual |
Get attributes from an XML tag. GetAttributes() should only be called after a successful GetElement() call.
aname | Pointer to an array of attribute names whose values are to be returned. The last entry in the array must be nil. |
aval | Pointer to an array where the corresponding attribute values are to be placed in 1-to-1 correspondence. The values must be freed using free(). |
Implemented in XrdXmlRdrXml2, and XrdXmlRdrTiny.
Referenced by XrdXmlMetaLink::Convert().
|
pure virtual |
Find an XML tag element.
ename | Pointer to an array of tag names any of which should be searched for. The last entry in the array must be nil. The first element of the array should contain the name of the context tag. Elements are searched only within the scope of that tag. When searching for the first desired tag, use a null string to indicate document scope. |
reqd | When true one of the tag elements listed in ename must be found otherwise an error is generated. |
Implemented in XrdXmlRdrXml2, and XrdXmlRdrTiny.
Referenced by XrdXmlMetaLink::Convert().
|
pure virtual |
Get the description of the last error encountered.
ecode | The error code associated with the error. |
Implemented in XrdXmlRdrXml2, and XrdXmlRdrTiny.
Referenced by GetReader().
|
static |
Get a reader object to parse an XML file.
fname | Pointer to the filepath of the file to be parsed. |
enc | Pointer to the encoding specification. When nil, UTF-8 is used. Currently, this parameter is ignored. |
impl | Pointer to the desired implementation. When nil, the default implementation, tinyxml, is used. The following are supported |
tinyxml - builtin xml reader. Each instance is independent Since it builds a full DOM tree in memory, it is only good for small amounts of xml. Certain esoteric xml features are not supported.
libxml2 - full-fledged xml reader. Instances are not independent if multiple uses involve setting callbacks, allocators, or I/O overrides. For MT-safeness, it must be initialized in the main thread (see Init() below). It is used in streaming mode and is good for large documents.
Definition at line 43 of file XrdXmlReader.cc.
References GetError().
Referenced by XrdXmlMetaLink::Convert().
|
pure virtual |
Get the text portion of an XML tag element. GetText() should only be called after a successful call to GetElement() with a possibly intervening call to GetAttributes().
ename | Pointer to the corresponding tag name. |
reqd | When true text must exist and not be null. Otherwise, an error is generated if the text is missing or null. |
Implemented in XrdXmlRdrXml2, and XrdXmlRdrTiny.
|
static |
Preinitialze the desired implementation for future use. This is meant to be used in multi-threaded applications, as some implementation must be initialized using the main thread before spawning other threads. An exmaple is libxml2 which is generally MT-unsafe unles preinitialized.
impl | Pointer to the desired implementation. When nil, the default implementation is used. Currently, only "libxml2" and "tinyxml" are supported. |
Definition at line 87 of file XrdXmlReader.cc.
References XrdXmlRdrXml2::Init().