tinyxml2.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef TINYXML2_INCLUDED
  2. #define TINYXML2_INCLUDED
  3. #include <limits.h>
  4. #if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)
  5. #ifndef DEBUG
  6. #define DEBUG
  7. #endif
  8. #endif
  9. #if defined(DEBUG)
  10. #if defined(_MSC_VER)
  11. #define TIXMLASSERT( x ) if ( !(x)) { _asm { int 3 } } //if ( !(x)) WinDebugBreak()
  12. #elif defined (ANDROID_NDK)
  13. #include <android/log.h>
  14. #define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
  15. #else
  16. #include <assert.h>
  17. #define TIXMLASSERT assert
  18. #endif
  19. #else
  20. #define TIXMLASSERT( x ) {}
  21. #endif
  22. namespace tinyxml2
  23. {
  24. // internal - move to separate namespace
  25. struct CharBuffer
  26. {
  27. size_t length;
  28. char mem[1];
  29. static CharBuffer* Construct( const char* in );
  30. static void Free( CharBuffer* );
  31. };
  32. class XMLNode
  33. {
  34. friend class XMLDocument;
  35. public:
  36. static XMLNode* Identify( const char* p );
  37. protected:
  38. static const char* SkipWhiteSpace( const char* p );
  39. static char* SkipWhiteSpace( char* p ) { return (char*) SkipWhiteSpace( (const char*)p ); }
  40. inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
  41. int n = 0;
  42. while( *p && *q && *p == *q && n<nChar ) {
  43. ++p; ++q; ++n;
  44. }
  45. if ( (n == nChar) || ( *p == 0 && *q == 0 ) ) {
  46. return true;
  47. }
  48. return false;
  49. }
  50. private:
  51. };
  52. class XMLComment : public XMLNode
  53. {
  54. };
  55. class XMLDocument
  56. {
  57. public:
  58. XMLDocument();
  59. bool Parse( const char* );
  60. private:
  61. XMLDocument( const XMLDocument& ); // not implemented
  62. CharBuffer* charBuffer;
  63. };
  64. }; // tinyxml2
  65. #endif // TINYXML2_INCLUDED