llxmlparser.h

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

Generated on Thu Jul 1 06:09:48 2010 for Second Life Viewer by  doxygen 1.4.7