Classes | |
class | tXmlParser |
TODO: add documentation, this is just here so tXmlParser::node gets documented. More... | |
class | tXmlResource |
Typedefs | |
typedef std::map< tString, tString > | tAttributeList |
Enumerations | |
enum | { SAX, DOM } |
Functions | |
void | cb_startDocument (void *userData) |
void | cb_endDocument (void *userData) |
void | cb_startElement (void *userData, const xmlChar *name, const xmlChar **attrs) |
void | cb_endElement (void *userData, const xmlChar *name) |
void | cb_warning (void *ctx, const char *msg,...) |
void | cb_error (void *ctx, const char *msg,...) |
void | cb_fatalError (void *ctx, const char *msg,...) |
int | myxmlInputReadFILE (void *context, char *buffer, int len) |
int | myxmlInputCloseFILE (void *context) |
static bool | sg_IgnoreRequest (tString const &URI) |
xmlParserInputBufferPtr | myxmlParserInputBufferCreateFilenameFunc (const char *URI, xmlCharEncoding enc) |
static void | st_ErrorFunc (void *ctx, const char *msg,...) |
Variables | |
xmlSAXHandler | aaSaxCallsback |
static tString | st_errorLeadIn ("") |
typedef std::map<tString, tString> tXmlParserNamespace::tAttributeList |
Definition at line 48 of file tXmlParser.h.
anonymous enum |
void tXmlParserNamespace::cb_endDocument | ( | void * | userData | ) |
Definition at line 54 of file tXmlParser.cpp.
References CALL_MEMBER_FN, and tXmlParserNamespace::tXmlParser::cb_endDocument().
00054 { 00055 CALL_MEMBER_FN((tXmlParser*)userData,&tXmlParser::cb_endDocument)(); 00056 }
void tXmlParserNamespace::cb_endElement | ( | void * | userData, | |
const xmlChar * | name | |||
) |
Definition at line 62 of file tXmlParser.cpp.
References CALL_MEMBER_FN, and tXmlParserNamespace::tXmlParser::cb_endElement().
00062 { 00063 CALL_MEMBER_FN((tXmlParser*)userData,&tXmlParser::cb_endElement)(name); 00064 }
void tXmlParserNamespace::cb_error | ( | void * | ctx, | |
const char * | msg, | |||
... | ||||
) |
Definition at line 78 of file tXmlParser.cpp.
00079 { 00080 va_list args; 00081 00082 va_start(args, msg); 00083 fprintf(stdout, "SAX.error: "); 00084 vfprintf(stdout, msg, args); 00085 va_end(args); 00086 }
void tXmlParserNamespace::cb_fatalError | ( | void * | ctx, | |
const char * | msg, | |||
... | ||||
) |
Definition at line 88 of file tXmlParser.cpp.
00089 { 00090 va_list args; 00091 00092 va_start(args, msg); 00093 fprintf(stdout, "SAX.fatalError: "); 00094 vfprintf(stdout, msg, args); 00095 va_end(args); 00096 }
void tXmlParserNamespace::cb_startDocument | ( | void * | userData | ) |
Definition at line 50 of file tXmlParser.cpp.
References CALL_MEMBER_FN, and tXmlParserNamespace::tXmlParser::cb_startDocument().
00050 { 00051 CALL_MEMBER_FN((tXmlParser*)userData,&tXmlParser::cb_startDocument)(); 00052 }
void tXmlParserNamespace::cb_startElement | ( | void * | userData, | |
const xmlChar * | name, | |||
const xmlChar ** | attrs | |||
) |
Definition at line 58 of file tXmlParser.cpp.
References CALL_MEMBER_FN, and tXmlParserNamespace::tXmlParser::cb_startElement().
00058 { 00059 CALL_MEMBER_FN((tXmlParser*)userData,&tXmlParser::cb_startElement)(name, attrs); 00060 }
void tXmlParserNamespace::cb_warning | ( | void * | ctx, | |
const char * | msg, | |||
... | ||||
) |
Definition at line 68 of file tXmlParser.cpp.
00069 { 00070 va_list args; 00071 00072 va_start(args, msg); 00073 fprintf(stdout, "SAX.warning: "); 00074 vfprintf(stdout, msg, args); 00075 va_end(args); 00076 }
int tXmlParserNamespace::myxmlInputCloseFILE | ( | void * | context | ) |
Definition at line 166 of file tXmlParser.cpp.
Referenced by myxmlParserInputBufferCreateFilenameFunc().
int tXmlParserNamespace::myxmlInputReadFILE | ( | void * | context, | |
char * | buffer, | |||
int | len | |||
) |
Definition at line 162 of file tXmlParser.cpp.
Referenced by myxmlParserInputBufferCreateFilenameFunc(), and tXmlParserNamespace::tXmlParser::ValidateXml().
00162 { 00163 return fread(buffer, 1, len, (FILE *)context); 00164 }
xmlParserInputBufferPtr tXmlParserNamespace::myxmlParserInputBufferCreateFilenameFunc | ( | const char * | URI, | |
xmlCharEncoding | enc | |||
) |
Definition at line 180 of file tXmlParser.cpp.
References myxmlInputCloseFILE(), myxmlInputReadFILE(), NULL, tResourceManager::openResource(), and sg_IgnoreRequest().
Referenced by tXmlParserNamespace::tXmlParser::ValidateXml().
00180 { 00181 if ( sg_IgnoreRequest( tString( URI ) ) ) 00182 { 00183 #ifdef DEBUG 00184 printf("Ignoring xml request for %s\n", URI); 00185 #endif 00186 return NULL; 00187 } 00188 #ifdef DEBUG 00189 // con << "xml wants " << URI << "\n"; 00190 #endif 00191 FILE *f = tResourceManager::openResource(URI, NULL); 00192 if (f == NULL) 00193 return NULL; 00194 xmlParserInputBufferPtr ret = xmlAllocParserInputBuffer(enc); 00195 ret->context = f; 00196 ret->readcallback = myxmlInputReadFILE; 00197 ret->closecallback = myxmlInputCloseFILE; 00198 return ret; 00199 }
static bool tXmlParserNamespace::sg_IgnoreRequest | ( | tString const & | URI | ) | [static] |
Definition at line 171 of file tXmlParser.cpp.
References tString::EndsWith(), and tString::StartsWith().
Referenced by myxmlParserInputBufferCreateFilenameFunc().
00172 { 00173 #ifdef WIN32 00174 return URI.EndsWith( "../etc/catalog" ); 00175 #else 00176 return URI.StartsWith( "file:///" ) && strstr( URI, "xml" ) && URI.EndsWith( "catalog" ); 00177 #endif 00178 }
static void tXmlParserNamespace::st_ErrorFunc | ( | void * | ctx, | |
const char * | msg, | |||
... | ||||
) | [static] |
Definition at line 342 of file tXmlParser.cpp.
References buffer, con, tString::Len(), tArray< T, MALLOC >::SetLen(), and st_errorLeadIn.
Referenced by tXmlParserNamespace::tXmlParser::ValidateXml().
00345 { 00346 // print formatted message into buffer 00347 static int maxlen = 100; 00348 tArray<char> buffer; 00349 bool retry = true; 00350 while ( retry ) 00351 { 00352 buffer.SetLen( maxlen ); 00353 va_list ap; 00354 va_start(ap, msg); 00355 retry = vsnprintf(&buffer[0], maxlen, msg, ap) >= maxlen; 00356 va_end(ap); 00357 00358 if ( retry ) 00359 maxlen *= 2; 00360 } 00361 char * message = &buffer[0]; 00362 00363 // print buffer to stderr and console 00364 if ( st_errorLeadIn.Len() > 2 ) 00365 { 00366 con << st_errorLeadIn; 00367 #ifndef DEBUG 00368 std::cerr << st_errorLeadIn; 00369 #endif 00370 st_errorLeadIn = ""; 00371 } 00372 00373 #ifndef DEBUG 00374 std::cerr << message; 00375 #endif 00376 00377 con << message; 00378 }
xmlSAXHandler tXmlParserNamespace::aaSaxCallsback |
Definition at line 127 of file tXmlParser.cpp.
Referenced by tXmlParserNamespace::tXmlParser::ParseSax().
tString tXmlParserNamespace::st_errorLeadIn("") [static] |
Referenced by st_ErrorFunc(), and tXmlParserNamespace::tXmlParser::ValidateXml().