llxmlparser.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLXMLPARSER_H
00033 #define LL_LLXMLPARSER_H
00034 
00035 #ifndef XML_STATIC
00036 #define XML_STATIC 1
00037 #endif
00038 #ifdef LL_STANDALONE
00039 #include <expat.h>
00040 #else
00041 #include "expat/expat.h"
00042 #endif
00043 
00044 class LLXmlParser
00045 {
00046 public:
00047         LLXmlParser();
00048         virtual ~LLXmlParser();
00049 
00050         // Parses entire file
00051         BOOL parseFile(const std::string &path);
00052 
00053         //      Parses some input. Returns 0 if a fatal error is detected.
00054         //      The last call must have isFinal true;
00055         //      len may be zero for this call (or any other).
00056         S32 parse( const char* buf, int len, int isFinal );
00057 
00058         const char* getErrorString();
00059         
00060         S32 getCurrentLineNumber();
00061 
00062         S32 getCurrentColumnNumber();
00063 
00064         S32 getDepth() { return mDepth; }
00065 
00066 protected:
00067         // atts is array of name/value pairs, terminated by 0;
00068         // names and values are 0 terminated.
00069         virtual void startElement(const char *name, const char **atts) {}
00070 
00071         virtual void endElement(const char *name) {}
00072 
00073         // s is not 0 terminated.
00074         virtual void characterData(const char *s, int len) {}
00075         
00076         // target and data are 0 terminated
00077         virtual void processingInstruction(const char *target, const char *data) {}
00078 
00079         // data is 0 terminated 
00080         virtual void comment(const char *data) {}
00081 
00082         virtual void startCdataSection() {}
00083 
00084         virtual void endCdataSection() {}
00085 
00086         //      This is called for any characters in the XML document for
00087         //      which there is no applicable handler.  This includes both
00088         //      characters that are part of markup which is of a kind that is
00089         //      not reported (comments, markup declarations), or characters
00090         //      that are part of a construct which could be reported but
00091         //      for which no handler has been supplied. The characters are passed
00092         //      exactly as they were in the XML document except that
00093         //      they will be encoded in UTF-8.  Line boundaries are not normalized.
00094         //      Note that a byte order mark character is not passed to the default handler.
00095         //      There are no guarantees about how characters are divided between calls
00096         //      to the default handler: for example, a comment might be split between
00097         //      multiple calls.
00098         virtual void defaultData(const char *s, int len) {}
00099 
00100         //      This is called for a declaration of an unparsed (NDATA)
00101         //      entity.  The base argument is whatever was set by XML_SetBase.
00102         //      The entityName, systemId and notationName arguments will never be null.
00103         //      The other arguments may be.
00104         virtual void unparsedEntityDecl(
00105                 const char *entityName,
00106                 const char *base,
00107                 const char *systemId,
00108                 const char *publicId,
00109                 const char *notationName) {}
00110 
00111 public:
00113         // Pseudo-private methods.  These are only used by internal callbacks.
00114         
00115         static void startElementHandler(void *userData, const XML_Char *name, const XML_Char **atts);
00116         static void endElementHandler(void *userData, const XML_Char *name);
00117         static void characterDataHandler(void *userData, const XML_Char *s, int len);
00118         static void processingInstructionHandler(void *userData, const XML_Char *target, const XML_Char *data);
00119         static void commentHandler(void *userData, const XML_Char *data);
00120         static void startCdataSectionHandler(void *userData);
00121         static void endCdataSectionHandler(void *userData);
00122         static void defaultDataHandler( void *userData, const XML_Char *s, int len);
00123         static void unparsedEntityDeclHandler(
00124                 void *userData,
00125                 const XML_Char *entityName,
00126                 const XML_Char *base,
00127                 const XML_Char *systemId,
00128                 const XML_Char *publicId,
00129                 const XML_Char *notationName);
00130 
00131 
00132 protected:
00133         XML_Parser              mParser;
00134         int                             mDepth;
00135         char                    mAuxErrorString[1024];          /*Flawfinder: ignore*/
00136 };
00137 
00138 #endif  // LL_LLXMLPARSER_H

Generated on Fri May 16 08:33:06 2008 for SecondLife by  doxygen 1.5.5