2 // Some very simple XML utility functions that just function on STL strings.
4 // Good for recursively splitting up the job of reinstatiating objects
5 // that have been serialized to an XML file.
7 // Copyright 2005 by Keith Vertanen
10 #define __XML_UTIL_H__
16 #include "FileLogger.h"
18 extern CFileLogger
* gLogger
;
23 typedef vector
<string
> VECTOR_STRING
;
25 #ifndef VECTOR_STRING_ITER
26 typedef vector
<string
>::iterator VECTOR_STRING_ITER
;
29 // We want to be able grab all the name/value pairs in XML like:
40 typedef vector
<NameValuePair
> VECTOR_NAME_VALUE_PAIR
;
41 typedef vector
<NameValuePair
>::iterator VECTOR_NAME_VALUE_PAIR_ITER
;
43 const int XML_UTIL_READ_BUFFER_SIZE
= 4096;
44 const int XML_UTIL_DEFAULT_VECTOR_SIZE
= 128;
52 static string
LoadFile(const string
& filename
, unsigned int iSizeHint
= 128000);
53 static string
GetElementString(const string
& strTag
, const string
& strXML
, bool bStripWhiteSpace
= true);
54 static int GetElementInt(const string
& strTag
, const string
& strXML
, bool* pFound
= NULL
);
55 static int64
GetElementLongLong(const string
& strTag
, const string
& strXML
, bool* pFound
= NULL
);
56 static float GetElementFloat(const string
& strTag
, const string
& strXML
, bool* pFound
= NULL
);
57 static VECTOR_STRING
GetElementStrings(const string
& strTag
, const string
& strXML
, bool bStripWhiteSpace
= true);
58 static VECTOR_NAME_VALUE_PAIR
GetNameValuePairs(const string
& strXML
, bool bStripWhiteSpace
= true);
60 static bool IsWhiteSpace(char cLetter
);
61 static string
StripWhiteSpace(const string
& strText
);
62 static bool IsDigit(char cLetter
);