tinyxml/000775 000765 000024 00000000000 11563634571 014260 5ustar00leethomasonstaff000000 000000 tinyxml/changes.txt000644 000765 000024 00000036272 11563634571 016441 0ustar00leethomasonstaff000000 000000 Changes in version 1.0.1: - Fixed comment tags which were outputing as ' include. Thanks to Steve Lhomme for that. Changes in version 2.0.0 BETA - Made the ToXXX() casts safe if 'this' is null. When "LoadFile" is called with a filename, the value will correctly get set. Thanks to Brian Yoder. - Fixed bug where isalpha() and isalnum() would get called with a negative value for high ascii numbers. Thanks to Alesky Aksenov. - Fixed some errors codes that were not getting set. - Made methods "const" that were not. - Added a switch to enable or disable the ignoring of white space. ( TiXmlDocument::SetIgnoreWhiteSpace() ) - Greater standardization and code re-use in the parser. - Added a stream out operator. - Added a stream in operator. - Entity support, of predefined entites. &#x entities are untouched by input or output. - Improved text out formatting. - Fixed ReplaceChild bug, thanks to Tao Chen. Changes in version 2.0.1 - Fixed hanging on loading a 0 length file. Thanks to Jeff Scozzafava. - Fixed crashing on InsertBeforeChild and InsertAfterChild. Also possibility of bad links being created by same function. Thanks to Frank De prins. - Added missing licence text. Thanks to Lars Willemsens. - Added include, at the suggestion of Steve Walters. Changes in version 2.1.0 - Yves Berquin brings us the STL switch. The forum on SourceForge, and various emails to me, have long debated all out STL vs. no STL at all. And now you can have it both ways. TinyXml will compile either way. Changes in version 2.1.1 - Compilation warnings. Changes in version 2.1.2 - Uneeded code is not compiled in the STL case. - Changed headers so that STL can be turned on or off in tinyxml.h Changes in version 2.1.3 - Fixed non-const reference in API; now uses a pointer. - Copy constructor of TiXmlString not checking for assignment to self. - Nimrod Cohen found a truly evil bug in the STL implementation that occurs when a string is converted to a c_str and then assigned to self. Search for STL_STRING_BUG for a full description. I'm asserting this is a Microsoft STL bug, since &string and string.c_str() should never be the same. Nevertheless, the code works around it. - Urivan Saaib pointed out a compiler conflict, where the C headers define the isblank macro, which was wiping out the TiXmlString::isblank() method. The method was unused and has been removed. Changes in version 2.1.4 - Reworked the entity code. Entities were not correctly surving round trip input and output. Will now automatically create entities for high ascii in output. Changes in version 2.1.5 - Bug fix by kylotan : infinite loop on some input (tinyxmlparser.cpp rev 1.27) - Contributed by Ivica Aracic (bytelord) : 1 new VC++ project to compile versions as static libraries (tinyxml_lib.dsp), and an example usage in xmltest.dsp (Patch request ID 678605) - A suggestion by Ronald Fenner Jr (dormlock) to add #include and for Apple's Project Builder (Patch request ID 697642) - A patch from ohommes that allows to parse correctly dots in element names and attribute names (Patch request 602600 and kylotan 701728) - A patch from hermitgeek ( James ) and wasteland for improper error reporting - Reviewed by Lee, with the following changes: - Got sick of fighting the STL/non-STL thing in the windows build. Broke them out as seperate projects. - I have too long not included the dsw. Added. - TinyXmlText had a protected Print. Odd. - Made LinkEndChild public, with docs and appropriate warnings. - Updated the docs. 2.2.0 - Fixed an uninitialized pointer in the TiXmlAttributes - Fixed STL compilation problem in MinGW (and gcc 3?) - thanks Brian Yoder for finding this one - Fixed a syntax error in TiXmlDeclaration - thanks Brian Yoder - Fletcher Dunn proposed and submitted new error handling that tracked the row and column. Lee modified it to not have performance impact. - General cleanup suggestions from Fletcher Dunn. - In error handling, general errors will no longer clear the error state of specific ones. - Fix error in documentation : comments starting with ">) has now been fixed. 2.5.2 - Lieven, and others, pointed out a missing const-cast that upset the Open Watcom compiler. Should now be fixed. - ErrorRow and ErrorCol should have been const, and weren't. Fixed thanks to Dmitry Polutov. 2.5.3 - zloe_zlo identified a missing string specialization for QueryValueAttribute() [ 1695429 ]. Worked on this bug, but not sure how to fix it in a safe, cross-compiler way. - increased warning level to 4 and turned on detect 64 bit portability issues for VC2005. May address [ 1677737 ] VS2005: /Wp64 warnings - grosheck identified several problems with the Document copy. Many thanks for [ 1660367 ] - Nice catch, and suggested fix, be Gilad Novik on the Printer dropping entities. "[ 1600650 ] Bug when printing xml text" is now fixed. - A subtle fix from Nicos Gollan in the tinystring initializer: [ 1581449 ] Fix initialiser of TiXmlString::nullrep_ - Great catch, although there isn't a submitter for the bug. [ 1475201 ] TinyXML parses entities in comments. Comments should not, in fact, parse entities. Fixed the code path and added tests. - We were not catching all the returns from ftell. Thanks to Bernard for catching that. 2.5.4 - A TiXMLDocument can't be a sub-node. Block this from happening in the 'replace'. Thanks Noam. - [ 1714831 ] TiXmlBase::location is not copied by copy-ctors, fix reported and suggested by Nicola Civran. - Fixed possible memory overrun in the comment reading code - thanks gcarlton77 2.5.5 - Alex van der Wal spotted incorrect types (lf) being used in print and scan. robertnestor pointed out some problems with the simple solution. Types updated. - Johannes Hillert pointed out some bug typos. - Christian Mueller identified inconsistent error handling with Attributes. - olivier barthelemy also reported a problem with double truncation, also related to the %lf issue. - zaelsius came up with a great (and simple) suggestion to fix QueryValueAttribute truncating strings. - added some null pointer checks suggested by hansenk - Sami Väisänen found a (rare) buffer overrun that could occur in parsing. - vi tri filed a bug that led to a refactoring of the attribute setting mess (as well as adding a missing SetDoubleAttribute() ) - removed TIXML_ERROR_OUT_OF_MEMORY. TinyXML does not systematically address OOO, and the notion it does is misleading. - vanneto, keithmarshall, others all reported the warning from IsWhiteSpace() usage. Cleaned this up - many thanks to everyone who reported this one. - tibur found a bug in end tag parsing 2.6.2 - Switched over to VC 2010 - Fixed up all the build issues arising from that. (Lots of latent build problems.) - Removed the old, now unmaintained and likely not working, build files. - Fixed some static analysis issues reported by orbitcowboy from cppcheck. - Bayard 95 sent in analysis from a different analyzer - fixes applied from that as well. - Tim Kosse sent a patch fixing an infinite loop. - Ma Anguo identified a doc issue. - Eddie Cohen identified a missing qualifier resulting in a compilation error on some systems. - Fixed a line ending bug. (What year is this? Can we all agree on a format for text files? Please? ...oh well.) tinyxml/docs/000775 000765 000024 00000000000 11563634571 015210 5ustar00leethomasonstaff000000 000000 tinyxml/._Makefile000644 000765 000024 00000000253 11563634571 016133 0ustar00leethomasonstaff000000 000000 Mac OS X  2y«ATTRTĪ«œœcom.apple.TextEncodingutf-8;134217984tinyxml/Makefile000644 000765 000024 00000006656 11563634571 015733 0ustar00leethomasonstaff000000 000000 #**************************************************************************** # # Makefile for TinyXml test. # Lee Thomason # www.grinninglizard.com # # This is a GNU make (gmake) makefile #**************************************************************************** # DEBUG can be set to YES to include debugging info, or NO otherwise DEBUG := NO # PROFILE can be set to YES to include profiling info, or NO otherwise PROFILE := NO # TINYXML_USE_STL can be used to turn on STL support. NO, then STL # will not be used. YES will include the STL files. TINYXML_USE_STL := NO #**************************************************************************** CC := gcc CXX := g++ LD := g++ AR := ar rc RANLIB := ranlib DEBUG_CFLAGS := -Wall -Wno-format -g -DDEBUG RELEASE_CFLAGS := -Wall -Wno-unknown-pragmas -Wno-format -O3 LIBS := DEBUG_CXXFLAGS := ${DEBUG_CFLAGS} RELEASE_CXXFLAGS := ${RELEASE_CFLAGS} DEBUG_LDFLAGS := -g RELEASE_LDFLAGS := ifeq (YES, ${DEBUG}) CFLAGS := ${DEBUG_CFLAGS} CXXFLAGS := ${DEBUG_CXXFLAGS} LDFLAGS := ${DEBUG_LDFLAGS} else CFLAGS := ${RELEASE_CFLAGS} CXXFLAGS := ${RELEASE_CXXFLAGS} LDFLAGS := ${RELEASE_LDFLAGS} endif ifeq (YES, ${PROFILE}) CFLAGS := ${CFLAGS} -pg -O3 CXXFLAGS := ${CXXFLAGS} -pg -O3 LDFLAGS := ${LDFLAGS} -pg endif #**************************************************************************** # Preprocessor directives #**************************************************************************** ifeq (YES, ${TINYXML_USE_STL}) DEFS := -DTIXML_USE_STL else DEFS := endif #**************************************************************************** # Include paths #**************************************************************************** #INCS := -I/usr/include/g++-2 -I/usr/local/include INCS := #**************************************************************************** # Makefile code common to all platforms #**************************************************************************** CFLAGS := ${CFLAGS} ${DEFS} CXXFLAGS := ${CXXFLAGS} ${DEFS} #**************************************************************************** # Targets of the build #**************************************************************************** OUTPUT := xmltest all: ${OUTPUT} #**************************************************************************** # Source files #**************************************************************************** SRCS := tinyxml.cpp tinyxmlparser.cpp xmltest.cpp tinyxmlerror.cpp tinystr.cpp # Add on the sources for libraries SRCS := ${SRCS} OBJS := $(addsuffix .o,$(basename ${SRCS})) #**************************************************************************** # Output #**************************************************************************** ${OUTPUT}: ${OBJS} ${LD} -o $@ ${LDFLAGS} ${OBJS} ${LIBS} ${EXTRA_LIBS} #**************************************************************************** # common rules #**************************************************************************** # Rules for compiling source files to object files %.o : %.cpp ${CXX} -c ${CXXFLAGS} ${INCS} $< -o $@ %.o : %.c ${CC} -c ${CFLAGS} ${INCS} $< -o $@ dist: bash makedistlinux clean: -rm -f core ${OBJS} ${OUTPUT} depend: #makedepend ${INCS} ${SRCS} tinyxml.o: tinyxml.h tinystr.h tinyxmlparser.o: tinyxml.h tinystr.h xmltest.o: tinyxml.h tinystr.h tinyxmlerror.o: tinyxml.h tinystr.h tinyxml/readme.txt000644 000765 000024 00000046567 11563634571 016276 0ustar00leethomasonstaff000000 000000 /** @mainpage

TinyXML

TinyXML is a simple, small, C++ XML parser that can be easily integrated into other programs.

What it does.

In brief, TinyXML parses an XML document, and builds from that a Document Object Model (DOM) that can be read, modified, and saved. XML stands for "eXtensible Markup Language." It allows you to create your own document markups. Where HTML does a very good job of marking documents for browsers, XML allows you to define any kind of document markup, for example a document that describes a "to do" list for an organizer application. XML is a very structured and convenient format. All those random file formats created to store application data can all be replaced with XML. One parser for everything. The best place for the complete, correct, and quite frankly hard to read spec is at http://www.w3.org/TR/2004/REC-xml-20040204/. An intro to XML (that I really like) can be found at http://skew.org/xml/tutorial. There are different ways to access and interact with XML data. TinyXML uses a Document Object Model (DOM), meaning the XML data is parsed into a C++ objects that can be browsed and manipulated, and then written to disk or another output stream. You can also construct an XML document from scratch with C++ objects and write this to disk or another output stream. TinyXML is designed to be easy and fast to learn. It is two headers and four cpp files. Simply add these to your project and off you go. There is an example file - xmltest.cpp - to get you started. TinyXML is released under the ZLib license, so you can use it in open source or commercial code. The details of the license are at the top of every source file. TinyXML attempts to be a flexible parser, but with truly correct and compliant XML output. TinyXML should compile on any reasonably C++ compliant system. It does not rely on exceptions or RTTI. It can be compiled with or without STL support. TinyXML fully supports the UTF-8 encoding, and the first 64k character entities.

What it doesn't do.

TinyXML doesn't parse or use DTDs (Document Type Definitions) or XSLs (eXtensible Stylesheet Language.) There are other parsers out there (check out www.sourceforge.org, search for XML) that are much more fully featured. But they are also much bigger, take longer to set up in your project, have a higher learning curve, and often have a more restrictive license. If you are working with browsers or have more complete XML needs, TinyXML is not the parser for you. The following DTD syntax will not parse at this time in TinyXML: @verbatim ]> @endverbatim because TinyXML sees this as a !DOCTYPE node with an illegally embedded !ELEMENT node. This may be addressed in the future.

Tutorials.

For the impatient, here is a tutorial to get you going. A great way to get started, but it is worth your time to read this (very short) manual completely. - @subpage tutorial0

Code Status.

TinyXML is mature, tested code. It is very stable. If you find bugs, please file a bug report on the sourceforge web site (www.sourceforge.net/projects/tinyxml). We'll get them straightened out as soon as possible. There are some areas of improvement; please check sourceforge if you are interested in working on TinyXML.

Related Projects

TinyXML projects you may find useful! (Descriptions provided by the projects.)
  • TinyXPath (http://tinyxpath.sourceforge.net). TinyXPath is a small footprint XPath syntax decoder, written in C++.
  • TinyXML++ (http://code.google.com/p/ticpp/). TinyXML++ is a completely new interface to TinyXML that uses MANY of the C++ strengths. Templates, exceptions, and much better error handling.

Features

Using STL

TinyXML can be compiled to use or not use STL. When using STL, TinyXML uses the std::string class, and fully supports std::istream, std::ostream, operator<<, and operator>>. Many API methods have both 'const char*' and 'const std::string&' forms. When STL support is compiled out, no STL files are included whatsoever. All the string classes are implemented by TinyXML itself. API methods all use the 'const char*' form for input. Use the compile time #define: TIXML_USE_STL to compile one version or the other. This can be passed by the compiler, or set as the first line of "tinyxml.h". Note: If compiling the test code in Linux, setting the environment variable TINYXML_USE_STL=YES/NO will control STL compilation. In the Windows project file, STL and non STL targets are provided. In your project, It's probably easiest to add the line "#define TIXML_USE_STL" as the first line of tinyxml.h.

UTF-8

TinyXML supports UTF-8 allowing to manipulate XML files in any language. TinyXML also supports "legacy mode" - the encoding used before UTF-8 support and probably best described as "extended ascii". Normally, TinyXML will try to detect the correct encoding and use it. However, by setting the value of TIXML_DEFAULT_ENCODING in the header file, TinyXML can be forced to always use one encoding. TinyXML will assume Legacy Mode until one of the following occurs:
  1. If the non-standard but common "UTF-8 lead bytes" (0xef 0xbb 0xbf) begin the file or data stream, TinyXML will read it as UTF-8.
  2. If the declaration tag is read, and it has an encoding="UTF-8", then TinyXML will read it as UTF-8.
  3. If the declaration tag is read, and it has no encoding specified, then TinyXML will read it as UTF-8.
  4. If the declaration tag is read, and it has an encoding="something else", then TinyXML will read it as Legacy Mode. In legacy mode, TinyXML will work as it did before. It's not clear what that mode does exactly, but old content should keep working.
  5. Until one of the above criteria is met, TinyXML runs in Legacy Mode.
What happens if the encoding is incorrectly set or detected? TinyXML will try to read and pass through text seen as improperly encoded. You may get some strange results or mangled characters. You may want to force TinyXML to the correct mode. You may force TinyXML to Legacy Mode by using LoadFile( TIXML_ENCODING_LEGACY ) or LoadFile( filename, TIXML_ENCODING_LEGACY ). You may force it to use legacy mode all the time by setting TIXML_DEFAULT_ENCODING = TIXML_ENCODING_LEGACY. Likewise, you may force it to TIXML_ENCODING_UTF8 with the same technique. For English users, using English XML, UTF-8 is the same as low-ASCII. You don't need to be aware of UTF-8 or change your code in any way. You can think of UTF-8 as a "superset" of ASCII. UTF-8 is not a double byte format - but it is a standard encoding of Unicode! TinyXML does not use or directly support wchar, TCHAR, or Microsoft's _UNICODE at this time. It is common to see the term "Unicode" improperly refer to UTF-16, a wide byte encoding of unicode. This is a source of confusion. For "high-ascii" languages - everything not English, pretty much - TinyXML can handle all languages, at the same time, as long as the XML is encoded in UTF-8. That can be a little tricky, older programs and operating systems tend to use the "default" or "traditional" code page. Many apps (and almost all modern ones) can output UTF-8, but older or stubborn (or just broken) ones still output text in the default code page. For example, Japanese systems traditionally use SHIFT-JIS encoding. Text encoded as SHIFT-JIS can not be read by TinyXML. A good text editor can import SHIFT-JIS and then save as UTF-8. The Skew.org link does a great job covering the encoding issue. The test file "utf8test.xml" is an XML containing English, Spanish, Russian, and Simplified Chinese. (Hopefully they are translated correctly). The file "utf8test.gif" is a screen capture of the XML file, rendered in IE. Note that if you don't have the correct fonts (Simplified Chinese or Russian) on your system, you won't see output that matches the GIF file even if you can parse it correctly. Also note that (at least on my Windows machine) console output is in a Western code page, so that Print() or printf() cannot correctly display the file. This is not a bug in TinyXML - just an OS issue. No data is lost or destroyed by TinyXML. The console just doesn't render UTF-8.

Entities

TinyXML recognizes the pre-defined "character entities", meaning special characters. Namely: @verbatim & & < < > > " " ' ' @endverbatim These are recognized when the XML document is read, and translated to there UTF-8 equivalents. For instance, text with the XML of: @verbatim Far & Away @endverbatim will have the Value() of "Far & Away" when queried from the TiXmlText object, and will be written back to the XML stream/file as an ampersand. Older versions of TinyXML "preserved" character entities, but the newer versions will translate them into characters. Additionally, any character can be specified by its Unicode code point: The syntax " " or " " are both to the non-breaking space characher.

Printing

TinyXML can print output in several different ways that all have strengths and limitations. - Print( FILE* ). Output to a std-C stream, which includes all C files as well as stdout. - "Pretty prints", but you don't have control over printing options. - The output is streamed directly to the FILE object, so there is no memory overhead in the TinyXML code. - used by Print() and SaveFile() - operator<<. Output to a c++ stream. - Integrates with standart C++ iostreams. - Outputs in "network printing" mode without line breaks. Good for network transmission and moving XML between C++ objects, but hard for a human to read. - TiXmlPrinter. Output to a std::string or memory buffer. - API is less concise - Future printing options will be put here. - Printing may change slightly in future versions as it is refined and expanded.

Streams

With TIXML_USE_STL on TinyXML supports C++ streams (operator <<,>>) streams as well as C (FILE*) streams. There are some differences that you may need to be aware of. C style output: - based on FILE* - the Print() and SaveFile() methods Generates formatted output, with plenty of white space, intended to be as human-readable as possible. They are very fast, and tolerant of ill formed XML documents. For example, an XML document that contains 2 root elements and 2 declarations, will still print. C style input: - based on FILE* - the Parse() and LoadFile() methods A fast, tolerant read. Use whenever you don't need the C++ streams. C++ style output: - based on std::ostream - operator<< Generates condensed output, intended for network transmission rather than readability. Depending on your system's implementation of the ostream class, these may be somewhat slower. (Or may not.) Not tolerant of ill formed XML: a document should contain the correct one root element. Additional root level elements will not be streamed out. C++ style input: - based on std::istream - operator>> Reads XML from a stream, making it useful for network transmission. The tricky part is knowing when the XML document is complete, since there will almost certainly be other data in the stream. TinyXML will assume the XML data is complete after it reads the root element. Put another way, documents that are ill-constructed with more than one root element will not read correctly. Also note that operator>> is somewhat slower than Parse, due to both implementation of the STL and limitations of TinyXML.

White space

The world simply does not agree on whether white space should be kept, or condensed. For example, pretend the '_' is a space, and look at "Hello____world". HTML, and at least some XML parsers, will interpret this as "Hello_world". They condense white space. Some XML parsers do not, and will leave it as "Hello____world". (Remember to keep pretending the _ is a space.) Others suggest that __Hello___world__ should become Hello___world. It's an issue that hasn't been resolved to my satisfaction. TinyXML supports the first 2 approaches. Call TiXmlBase::SetCondenseWhiteSpace( bool ) to set the desired behavior. The default is to condense white space. If you change the default, you should call TiXmlBase::SetCondenseWhiteSpace( bool ) before making any calls to Parse XML data, and I don't recommend changing it after it has been set.

Handles

Where browsing an XML document in a robust way, it is important to check for null returns from method calls. An error safe implementation can generate a lot of code like: @verbatim TiXmlElement* root = document.FirstChildElement( "Document" ); if ( root ) { TiXmlElement* element = root->FirstChildElement( "Element" ); if ( element ) { TiXmlElement* child = element->FirstChildElement( "Child" ); if ( child ) { TiXmlElement* child2 = child->NextSiblingElement( "Child" ); if ( child2 ) { // Finally do something useful. @endverbatim Handles have been introduced to clean this up. Using the TiXmlHandle class, the previous code reduces to: @verbatim TiXmlHandle docHandle( &document ); TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement(); if ( child2 ) { // do something useful @endverbatim Which is much easier to deal with. See TiXmlHandle for more information.

Row and Column tracking

Being able to track nodes and attributes back to their origin location in source files can be very important for some applications. Additionally, knowing where parsing errors occured in the original source can be very time saving. TinyXML can tracks the row and column origin of all nodes and attributes in a text file. The TiXmlBase::Row() and TiXmlBase::Column() methods return the origin of the node in the source text. The correct tabs can be configured in TiXmlDocument::SetTabSize().

Using and Installing

To Compile and Run xmltest: A Linux Makefile and a Windows Visual C++ .dsw file is provided. Simply compile and run. It will write the file demotest.xml to your disk and generate output on the screen. It also tests walking the DOM by printing out the number of nodes found using different techniques. The Linux makefile is very generic and runs on many systems - it is currently tested on mingw and MacOSX. You do not need to run 'make depend'. The dependecies have been hard coded.

Windows project file for VC6

  • tinyxml: tinyxml library, non-STL
  • tinyxmlSTL: tinyxml library, STL
  • tinyXmlTest: test app, non-STL
  • tinyXmlTestSTL: test app, STL

Makefile

At the top of the makefile you can set: PROFILE, DEBUG, and TINYXML_USE_STL. Details (such that they are) are in the makefile. In the tinyxml directory, type "make clean" then "make". The executable file 'xmltest' will be created.

To Use in an Application:

Add tinyxml.cpp, tinyxml.h, tinyxmlerror.cpp, tinyxmlparser.cpp, tinystr.cpp, and tinystr.h to your project or make file. That's it! It should compile on any reasonably compliant C++ system. You do not need to enable exceptions or RTTI for TinyXML.

How TinyXML works.

An example is probably the best way to go. Take: @verbatim Go to the Toy store! Do bills @endverbatim Its not much of a To Do list, but it will do. To read this file (say "demo.xml") you would create a document, and parse it in: @verbatim TiXmlDocument doc( "demo.xml" ); doc.LoadFile(); @endverbatim And its ready to go. Now lets look at some lines and how they relate to the DOM. @verbatim @endverbatim The first line is a declaration, and gets turned into the TiXmlDeclaration class. It will be the first child of the document node. This is the only directive/special tag parsed by TinyXML. Generally directive tags are stored in TiXmlUnknown so the commands wont be lost when it is saved back to disk. @verbatim @endverbatim A comment. Will become a TiXmlComment object. @verbatim @endverbatim The "ToDo" tag defines a TiXmlElement object. This one does not have any attributes, but does contain 2 other elements. @verbatim @endverbatim Creates another TiXmlElement which is a child of the "ToDo" element. This element has 1 attribute, with the name "priority" and the value "1". @verbatim Go to the @endverbatim A TiXmlText. This is a leaf node and cannot contain other nodes. It is a child of the "Item" TiXmlElement. @verbatim @endverbatim Another TiXmlElement, this one a child of the "Item" element. Etc. Looking at the entire object tree, you end up with: @verbatim TiXmlDocument "demo.xml" TiXmlDeclaration "version='1.0'" "standalone=no" TiXmlComment " Our to do list data" TiXmlElement "ToDo" TiXmlElement "Item" Attribtutes: priority = 1 TiXmlText "Go to the " TiXmlElement "bold" TiXmlText "Toy store!" TiXmlElement "Item" Attributes: priority=2 TiXmlText "Do bills" @endverbatim

Documentation

The documentation is build with Doxygen, using the 'dox' configuration file.

License

TinyXML is released under the zlib license: This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution.

References

The World Wide Web Consortium is the definitive standard body for XML, and their web pages contain huge amounts of information. The definitive spec: http://www.w3.org/TR/2004/REC-xml-20040204/ I also recommend "XML Pocket Reference" by Robert Eckstein and published by OReilly...the book that got the whole thing started.

Contributors, Contacts, and a Brief History

Thanks very much to everyone who sends suggestions, bugs, ideas, and encouragement. It all helps, and makes this project fun. A special thanks to the contributors on the web pages that keep it lively. So many people have sent in bugs and ideas, that rather than list here we try to give credit due in the "changes.txt" file. TinyXML was originally written by Lee Thomason. (Often the "I" still in the documentation.) Lee reviews changes and releases new versions, with the help of Yves Berquin, Andrew Ellerton, and the tinyXml community. We appreciate your suggestions, and would love to know if you use TinyXML. Hopefully you will enjoy it and find it useful. Please post questions, comments, file bugs, or contact us at: www.sourceforge.net/projects/tinyxml Lee Thomason, Yves Berquin, Andrew Ellerton */ tinyxml/tinystr.cpp000644 000765 000024 00000004713 11563634571 016503 0ustar00leethomasonstaff000000 000000 /* www.sourceforge.net/projects/tinyxml This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef TIXML_USE_STL #include "tinystr.h" // Error value for find primitive const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1); // Null rep. TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } }; void TiXmlString::reserve (size_type cap) { if (cap > capacity()) { TiXmlString tmp; tmp.init(length(), cap); memcpy(tmp.start(), data(), length()); swap(tmp); } } TiXmlString& TiXmlString::assign(const char* str, size_type len) { size_type cap = capacity(); if (len > cap || cap > 3*(len + 8)) { TiXmlString tmp; tmp.init(len); memcpy(tmp.start(), str, len); swap(tmp); } else { memmove(start(), str, len); set_size(len); } return *this; } TiXmlString& TiXmlString::append(const char* str, size_type len) { size_type newsize = length() + len; if (newsize > capacity()) { reserve (newsize + capacity()); } memmove(finish(), str, len); set_size(newsize); return *this; } TiXmlString operator + (const TiXmlString & a, const TiXmlString & b) { TiXmlString tmp; tmp.reserve(a.length() + b.length()); tmp += a; tmp += b; return tmp; } TiXmlString operator + (const TiXmlString & a, const char* b) { TiXmlString tmp; TiXmlString::size_type b_len = static_cast( strlen(b) ); tmp.reserve(a.length() + b_len); tmp += a; tmp.append(b, b_len); return tmp; } TiXmlString operator + (const char* a, const TiXmlString & b) { TiXmlString tmp; TiXmlString::size_type a_len = static_cast( strlen(a) ); tmp.reserve(a_len + b.length()); tmp.append(a, a_len); tmp += b; return tmp; } #endif // TIXML_USE_STL tinyxml/tinystr.h000644 000765 000024 00000020006 11563634571 016141 0ustar00leethomasonstaff000000 000000 /* www.sourceforge.net/projects/tinyxml This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef TIXML_USE_STL #ifndef TIXML_STRING_INCLUDED #define TIXML_STRING_INCLUDED #include #include /* The support for explicit isn't that universal, and it isn't really required - it is used to check that the TiXmlString class isn't incorrectly used. Be nice to old compilers and macro it here: */ #if defined(_MSC_VER) && (_MSC_VER >= 1200 ) // Microsoft visual studio, version 6 and higher. #define TIXML_EXPLICIT explicit #elif defined(__GNUC__) && (__GNUC__ >= 3 ) // GCC version 3 and higher.s #define TIXML_EXPLICIT explicit #else #define TIXML_EXPLICIT #endif /* TiXmlString is an emulation of a subset of the std::string template. Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. Only the member functions relevant to the TinyXML project have been implemented. The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase a string and there's no more room, we allocate a buffer twice as big as we need. */ class TiXmlString { public : // The size type used typedef size_t size_type; // Error value for find primitive static const size_type npos; // = -1; // TiXmlString empty constructor TiXmlString () : rep_(&nullrep_) { } // TiXmlString copy constructor TiXmlString ( const TiXmlString & copy) : rep_(0) { init(copy.length()); memcpy(start(), copy.data(), length()); } // TiXmlString constructor, based on a string TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0) { init( static_cast( strlen(copy) )); memcpy(start(), copy, length()); } // TiXmlString constructor, based on a string TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0) { init(len); memcpy(start(), str, len); } // TiXmlString destructor ~TiXmlString () { quit(); } TiXmlString& operator = (const char * copy) { return assign( copy, (size_type)strlen(copy)); } TiXmlString& operator = (const TiXmlString & copy) { return assign(copy.start(), copy.length()); } // += operator. Maps to append TiXmlString& operator += (const char * suffix) { return append(suffix, static_cast( strlen(suffix) )); } // += operator. Maps to append TiXmlString& operator += (char single) { return append(&single, 1); } // += operator. Maps to append TiXmlString& operator += (const TiXmlString & suffix) { return append(suffix.data(), suffix.length()); } // Convert a TiXmlString into a null-terminated char * const char * c_str () const { return rep_->str; } // Convert a TiXmlString into a char * (need not be null terminated). const char * data () const { return rep_->str; } // Return the length of a TiXmlString size_type length () const { return rep_->size; } // Alias for length() size_type size () const { return rep_->size; } // Checks if a TiXmlString is empty bool empty () const { return rep_->size == 0; } // Return capacity of string size_type capacity () const { return rep_->capacity; } // single char extraction const char& at (size_type index) const { assert( index < length() ); return rep_->str[ index ]; } // [] operator char& operator [] (size_type index) const { assert( index < length() ); return rep_->str[ index ]; } // find a char in a string. Return TiXmlString::npos if not found size_type find (char lookup) const { return find(lookup, 0); } // find a char in a string from an offset. Return TiXmlString::npos if not found size_type find (char tofind, size_type offset) const { if (offset >= length()) return npos; for (const char* p = c_str() + offset; *p != '\0'; ++p) { if (*p == tofind) return static_cast< size_type >( p - c_str() ); } return npos; } void clear () { //Lee: //The original was just too strange, though correct: // TiXmlString().swap(*this); //Instead use the quit & re-init: quit(); init(0,0); } /* Function to reserve a big amount of data when we know we'll need it. Be aware that this function DOES NOT clear the content of the TiXmlString if any exists. */ void reserve (size_type cap); TiXmlString& assign (const char* str, size_type len); TiXmlString& append (const char* str, size_type len); void swap (TiXmlString& other) { Rep* r = rep_; rep_ = other.rep_; other.rep_ = r; } private: void init(size_type sz) { init(sz, sz); } void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; } char* start() const { return rep_->str; } char* finish() const { return rep_->str + rep_->size; } struct Rep { size_type size, capacity; char str[1]; }; void init(size_type sz, size_type cap) { if (cap) { // Lee: the original form: // rep_ = static_cast(operator new(sizeof(Rep) + cap)); // doesn't work in some cases of new being overloaded. Switching // to the normal allocation, although use an 'int' for systems // that are overly picky about structure alignment. const size_type bytesNeeded = sizeof(Rep) + cap; const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); rep_ = reinterpret_cast( new int[ intsNeeded ] ); rep_->str[ rep_->size = sz ] = '\0'; rep_->capacity = cap; } else { rep_ = &nullrep_; } } void quit() { if (rep_ != &nullrep_) { // The rep_ is really an array of ints. (see the allocator, above). // Cast it back before delete, so the compiler won't incorrectly call destructors. delete [] ( reinterpret_cast( rep_ ) ); } } Rep * rep_; static Rep nullrep_; } ; inline bool operator == (const TiXmlString & a, const TiXmlString & b) { return ( a.length() == b.length() ) // optimization on some platforms && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare } inline bool operator < (const TiXmlString & a, const TiXmlString & b) { return strcmp(a.c_str(), b.c_str()) < 0; } inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); } inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; } inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); } inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); } inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; } inline bool operator == (const char* a, const TiXmlString & b) { return b == a; } inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); } inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); } TiXmlString operator + (const TiXmlString & a, const TiXmlString & b); TiXmlString operator + (const TiXmlString & a, const char* b); TiXmlString operator + (const char* a, const TiXmlString & b); /* TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString. Only the operators that we need for TinyXML have been developped. */ class TiXmlOutStream : public TiXmlString { public : // TiXmlOutStream << operator. TiXmlOutStream & operator << (const TiXmlString & in) { *this += in; return *this; } // TiXmlOutStream << operator. TiXmlOutStream & operator << (const char * in) { *this += in; return *this; } } ; #endif // TIXML_STRING_INCLUDED #endif // TIXML_USE_STL tinyxml/tinyxml.cpp000644 000765 000024 00000111327 11563634571 016473 0ustar00leethomasonstaff000000 000000 /* www.sourceforge.net/projects/tinyxml Original code by Lee Thomason (www.grinninglizard.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include #ifdef TIXML_USE_STL #include #include #endif #include "tinyxml.h" FILE* TiXmlFOpen( const char* filename, const char* mode ); bool TiXmlBase::condenseWhiteSpace = true; // Microsoft compiler security FILE* TiXmlFOpen( const char* filename, const char* mode ) { #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) FILE* fp = 0; errno_t err = fopen_s( &fp, filename, mode ); if ( !err && fp ) return fp; return 0; #else return fopen( filename, mode ); #endif } void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) { int i=0; while( i<(int)str.length() ) { unsigned char c = (unsigned char) str[i]; if ( c == '&' && i < ( (int)str.length() - 2 ) && str[i+1] == '#' && str[i+2] == 'x' ) { // Hexadecimal character reference. // Pass through unchanged. // © -- copyright symbol, for example. // // The -1 is a bug fix from Rob Laveaux. It keeps // an overflow from happening if there is no ';'. // There are actually 2 ways to exit this loop - // while fails (error case) and break (semicolon found). // However, there is no mechanism (currently) for // this function to return an error. while ( i<(int)str.length()-1 ) { outString->append( str.c_str() + i, 1 ); ++i; if ( str[i] == ';' ) break; } } else if ( c == '&' ) { outString->append( entity[0].str, entity[0].strLength ); ++i; } else if ( c == '<' ) { outString->append( entity[1].str, entity[1].strLength ); ++i; } else if ( c == '>' ) { outString->append( entity[2].str, entity[2].strLength ); ++i; } else if ( c == '\"' ) { outString->append( entity[3].str, entity[3].strLength ); ++i; } else if ( c == '\'' ) { outString->append( entity[4].str, entity[4].strLength ); ++i; } else if ( c < 32 ) { // Easy pass at non-alpha/numeric/symbol // Below 32 is symbolic. char buf[ 32 ]; #if defined(TIXML_SNPRINTF) TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) ); #else sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); #endif //*ME: warning C4267: convert 'size_t' to 'int' //*ME: Int-Cast to make compiler happy ... outString->append( buf, (int)strlen( buf ) ); ++i; } else { //char realc = (char) c; //outString->append( &realc, 1 ); *outString += (char) c; // somewhat more efficient function call. ++i; } } } TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() { parent = 0; type = _type; firstChild = 0; lastChild = 0; prev = 0; next = 0; } TiXmlNode::~TiXmlNode() { TiXmlNode* node = firstChild; TiXmlNode* temp = 0; while ( node ) { temp = node; node = node->next; delete temp; } } void TiXmlNode::CopyTo( TiXmlNode* target ) const { target->SetValue (value.c_str() ); target->userData = userData; target->location = location; } void TiXmlNode::Clear() { TiXmlNode* node = firstChild; TiXmlNode* temp = 0; while ( node ) { temp = node; node = node->next; delete temp; } firstChild = 0; lastChild = 0; } TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) { assert( node->parent == 0 || node->parent == this ); assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); if ( node->Type() == TiXmlNode::TINYXML_DOCUMENT ) { delete node; if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } node->parent = this; node->prev = lastChild; node->next = 0; if ( lastChild ) lastChild->next = node; else firstChild = node; // it was an empty list. lastChild = node; return node; } TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) { if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) { if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } TiXmlNode* node = addThis.Clone(); if ( !node ) return 0; return LinkEndChild( node ); } TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) { if ( !beforeThis || beforeThis->parent != this ) { return 0; } if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) { if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } TiXmlNode* node = addThis.Clone(); if ( !node ) return 0; node->parent = this; node->next = beforeThis; node->prev = beforeThis->prev; if ( beforeThis->prev ) { beforeThis->prev->next = node; } else { assert( firstChild == beforeThis ); firstChild = node; } beforeThis->prev = node; return node; } TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) { if ( !afterThis || afterThis->parent != this ) { return 0; } if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) { if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } TiXmlNode* node = addThis.Clone(); if ( !node ) return 0; node->parent = this; node->prev = afterThis; node->next = afterThis->next; if ( afterThis->next ) { afterThis->next->prev = node; } else { assert( lastChild == afterThis ); lastChild = node; } afterThis->next = node; return node; } TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) { if ( !replaceThis ) return 0; if ( replaceThis->parent != this ) return 0; if ( withThis.ToDocument() ) { // A document can never be a child. Thanks to Noam. TiXmlDocument* document = GetDocument(); if ( document ) document->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } TiXmlNode* node = withThis.Clone(); if ( !node ) return 0; node->next = replaceThis->next; node->prev = replaceThis->prev; if ( replaceThis->next ) replaceThis->next->prev = node; else lastChild = node; if ( replaceThis->prev ) replaceThis->prev->next = node; else firstChild = node; delete replaceThis; node->parent = this; return node; } bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) { if ( !removeThis ) { return false; } if ( removeThis->parent != this ) { assert( 0 ); return false; } if ( removeThis->next ) removeThis->next->prev = removeThis->prev; else lastChild = removeThis->prev; if ( removeThis->prev ) removeThis->prev->next = removeThis->next; else firstChild = removeThis->next; delete removeThis; return true; } const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const { const TiXmlNode* node; for ( node = firstChild; node; node = node->next ) { if ( strcmp( node->Value(), _value ) == 0 ) return node; } return 0; } const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const { const TiXmlNode* node; for ( node = lastChild; node; node = node->prev ) { if ( strcmp( node->Value(), _value ) == 0 ) return node; } return 0; } const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const { if ( !previous ) { return FirstChild(); } else { assert( previous->parent == this ); return previous->NextSibling(); } } const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const { if ( !previous ) { return FirstChild( val ); } else { assert( previous->parent == this ); return previous->NextSibling( val ); } } const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const { const TiXmlNode* node; for ( node = next; node; node = node->next ) { if ( strcmp( node->Value(), _value ) == 0 ) return node; } return 0; } const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const { const TiXmlNode* node; for ( node = prev; node; node = node->prev ) { if ( strcmp( node->Value(), _value ) == 0 ) return node; } return 0; } void TiXmlElement::RemoveAttribute( const char * name ) { #ifdef TIXML_USE_STL TIXML_STRING str( name ); TiXmlAttribute* node = attributeSet.Find( str ); #else TiXmlAttribute* node = attributeSet.Find( name ); #endif if ( node ) { attributeSet.Remove( node ); delete node; } } const TiXmlElement* TiXmlNode::FirstChildElement() const { const TiXmlNode* node; for ( node = FirstChild(); node; node = node->NextSibling() ) { if ( node->ToElement() ) return node->ToElement(); } return 0; } const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const { const TiXmlNode* node; for ( node = FirstChild( _value ); node; node = node->NextSibling( _value ) ) { if ( node->ToElement() ) return node->ToElement(); } return 0; } const TiXmlElement* TiXmlNode::NextSiblingElement() const { const TiXmlNode* node; for ( node = NextSibling(); node; node = node->NextSibling() ) { if ( node->ToElement() ) return node->ToElement(); } return 0; } const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const { const TiXmlNode* node; for ( node = NextSibling( _value ); node; node = node->NextSibling( _value ) ) { if ( node->ToElement() ) return node->ToElement(); } return 0; } const TiXmlDocument* TiXmlNode::GetDocument() const { const TiXmlNode* node; for( node = this; node; node = node->parent ) { if ( node->ToDocument() ) return node->ToDocument(); } return 0; } TiXmlElement::TiXmlElement (const char * _value) : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) { firstChild = lastChild = 0; value = _value; } #ifdef TIXML_USE_STL TiXmlElement::TiXmlElement( const std::string& _value ) : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) { firstChild = lastChild = 0; value = _value; } #endif TiXmlElement::TiXmlElement( const TiXmlElement& copy) : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) { firstChild = lastChild = 0; copy.CopyTo( this ); } TiXmlElement& TiXmlElement::operator=( const TiXmlElement& base ) { ClearThis(); base.CopyTo( this ); return *this; } TiXmlElement::~TiXmlElement() { ClearThis(); } void TiXmlElement::ClearThis() { Clear(); while( attributeSet.First() ) { TiXmlAttribute* node = attributeSet.First(); attributeSet.Remove( node ); delete node; } } const char* TiXmlElement::Attribute( const char* name ) const { const TiXmlAttribute* node = attributeSet.Find( name ); if ( node ) return node->Value(); return 0; } #ifdef TIXML_USE_STL const std::string* TiXmlElement::Attribute( const std::string& name ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); if ( attrib ) return &attrib->ValueStr(); return 0; } #endif const char* TiXmlElement::Attribute( const char* name, int* i ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); const char* result = 0; if ( attrib ) { result = attrib->Value(); if ( i ) { attrib->QueryIntValue( i ); } } return result; } #ifdef TIXML_USE_STL const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); const std::string* result = 0; if ( attrib ) { result = &attrib->ValueStr(); if ( i ) { attrib->QueryIntValue( i ); } } return result; } #endif const char* TiXmlElement::Attribute( const char* name, double* d ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); const char* result = 0; if ( attrib ) { result = attrib->Value(); if ( d ) { attrib->QueryDoubleValue( d ); } } return result; } #ifdef TIXML_USE_STL const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); const std::string* result = 0; if ( attrib ) { result = &attrib->ValueStr(); if ( d ) { attrib->QueryDoubleValue( d ); } } return result; } #endif int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); if ( !attrib ) return TIXML_NO_ATTRIBUTE; return attrib->QueryIntValue( ival ); } int TiXmlElement::QueryUnsignedAttribute( const char* name, unsigned* value ) const { const TiXmlAttribute* node = attributeSet.Find( name ); if ( !node ) return TIXML_NO_ATTRIBUTE; int ival = 0; int result = node->QueryIntValue( &ival ); *value = (unsigned)ival; return result; } int TiXmlElement::QueryBoolAttribute( const char* name, bool* bval ) const { const TiXmlAttribute* node = attributeSet.Find( name ); if ( !node ) return TIXML_NO_ATTRIBUTE; int result = TIXML_WRONG_TYPE; if ( StringEqual( node->Value(), "true", true, TIXML_ENCODING_UNKNOWN ) || StringEqual( node->Value(), "yes", true, TIXML_ENCODING_UNKNOWN ) || StringEqual( node->Value(), "1", true, TIXML_ENCODING_UNKNOWN ) ) { *bval = true; result = TIXML_SUCCESS; } else if ( StringEqual( node->Value(), "false", true, TIXML_ENCODING_UNKNOWN ) || StringEqual( node->Value(), "no", true, TIXML_ENCODING_UNKNOWN ) || StringEqual( node->Value(), "0", true, TIXML_ENCODING_UNKNOWN ) ) { *bval = false; result = TIXML_SUCCESS; } return result; } #ifdef TIXML_USE_STL int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); if ( !attrib ) return TIXML_NO_ATTRIBUTE; return attrib->QueryIntValue( ival ); } #endif int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); if ( !attrib ) return TIXML_NO_ATTRIBUTE; return attrib->QueryDoubleValue( dval ); } #ifdef TIXML_USE_STL int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); if ( !attrib ) return TIXML_NO_ATTRIBUTE; return attrib->QueryDoubleValue( dval ); } #endif void TiXmlElement::SetAttribute( const char * name, int val ) { TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); if ( attrib ) { attrib->SetIntValue( val ); } } #ifdef TIXML_USE_STL void TiXmlElement::SetAttribute( const std::string& name, int val ) { TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); if ( attrib ) { attrib->SetIntValue( val ); } } #endif void TiXmlElement::SetDoubleAttribute( const char * name, double val ) { TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); if ( attrib ) { attrib->SetDoubleValue( val ); } } #ifdef TIXML_USE_STL void TiXmlElement::SetDoubleAttribute( const std::string& name, double val ) { TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); if ( attrib ) { attrib->SetDoubleValue( val ); } } #endif void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) { TiXmlAttribute* attrib = attributeSet.FindOrCreate( cname ); if ( attrib ) { attrib->SetValue( cvalue ); } } #ifdef TIXML_USE_STL void TiXmlElement::SetAttribute( const std::string& _name, const std::string& _value ) { TiXmlAttribute* attrib = attributeSet.FindOrCreate( _name ); if ( attrib ) { attrib->SetValue( _value ); } } #endif void TiXmlElement::Print( FILE* cfile, int depth ) const { int i; assert( cfile ); for ( i=0; iNext() ) { fprintf( cfile, " " ); attrib->Print( cfile, depth ); } // There are 3 different formatting approaches: // 1) An element without children is printed as a node // 2) An element with only a text child is printed as text // 3) An element with children is printed on multiple lines. TiXmlNode* node; if ( !firstChild ) { fprintf( cfile, " />" ); } else if ( firstChild == lastChild && firstChild->ToText() ) { fprintf( cfile, ">" ); firstChild->Print( cfile, depth + 1 ); fprintf( cfile, "", value.c_str() ); } else { fprintf( cfile, ">" ); for ( node = firstChild; node; node=node->NextSibling() ) { if ( !node->ToText() ) { fprintf( cfile, "\n" ); } node->Print( cfile, depth+1 ); } fprintf( cfile, "\n" ); for( i=0; i", value.c_str() ); } } void TiXmlElement::CopyTo( TiXmlElement* target ) const { // superclass: TiXmlNode::CopyTo( target ); // Element class: // Clone the attributes, then clone the children. const TiXmlAttribute* attribute = 0; for( attribute = attributeSet.First(); attribute; attribute = attribute->Next() ) { target->SetAttribute( attribute->Name(), attribute->Value() ); } TiXmlNode* node = 0; for ( node = firstChild; node; node = node->NextSibling() ) { target->LinkEndChild( node->Clone() ); } } bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const { if ( visitor->VisitEnter( *this, attributeSet.First() ) ) { for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) { if ( !node->Accept( visitor ) ) break; } } return visitor->VisitExit( *this ); } TiXmlNode* TiXmlElement::Clone() const { TiXmlElement* clone = new TiXmlElement( Value() ); if ( !clone ) return 0; CopyTo( clone ); return clone; } const char* TiXmlElement::GetText() const { const TiXmlNode* child = this->FirstChild(); if ( child ) { const TiXmlText* childText = child->ToText(); if ( childText ) { return childText->Value(); } } return 0; } TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) { tabsize = 4; useMicrosoftBOM = false; ClearError(); } TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) { tabsize = 4; useMicrosoftBOM = false; value = documentName; ClearError(); } #ifdef TIXML_USE_STL TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) { tabsize = 4; useMicrosoftBOM = false; value = documentName; ClearError(); } #endif TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) { copy.CopyTo( this ); } TiXmlDocument& TiXmlDocument::operator=( const TiXmlDocument& copy ) { Clear(); copy.CopyTo( this ); return *this; } bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) { return LoadFile( Value(), encoding ); } bool TiXmlDocument::SaveFile() const { return SaveFile( Value() ); } bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) { TIXML_STRING filename( _filename ); value = filename; // reading in binary mode so that tinyxml can normalize the EOL FILE* file = TiXmlFOpen( value.c_str (), "rb" ); if ( file ) { bool result = LoadFile( file, encoding ); fclose( file ); return result; } else { SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); return false; } } bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) { if ( !file ) { SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); return false; } // Delete the existing data: Clear(); location.Clear(); // Get the file size, so we can pre-allocate the string. HUGE speed impact. long length = 0; fseek( file, 0, SEEK_END ); length = ftell( file ); fseek( file, 0, SEEK_SET ); // Strange case, but good to handle up front. if ( length <= 0 ) { SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); return false; } // Subtle bug here. TinyXml did use fgets. But from the XML spec: // 2.11 End-of-Line Handling // // // ...the XML processor MUST behave as if it normalized all line breaks in external // parsed entities (including the document entity) on input, before parsing, by translating // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to // a single #xA character. // // // It is not clear fgets does that, and certainly isn't clear it works cross platform. // Generally, you expect fgets to translate from the convention of the OS to the c/unix // convention, and not work generally. /* while( fgets( buf, sizeof(buf), file ) ) { data += buf; } */ char* buf = new char[ length+1 ]; buf[0] = 0; if ( fread( buf, length, 1, file ) != 1 ) { delete [] buf; SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); return false; } // Process the buffer in place to normalize new lines. (See comment above.) // Copies from the 'p' to 'q' pointer, where p can advance faster if // a newline-carriage return is hit. // // Wikipedia: // Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or // CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, 0x0D 0x0A)... // * LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS X, FreeBSD, etc.), BeOS, Amiga, RISC OS, and others // * CR+LF: DEC RT-11 and most other early non-Unix, non-IBM OSes, CP/M, MP/M, DOS, OS/2, Microsoft Windows, Symbian OS // * CR: Commodore 8-bit machines, Apple II family, Mac OS up to version 9 and OS-9 const char* p = buf; // the read head char* q = buf; // the write head const char CR = 0x0d; const char LF = 0x0a; buf[length] = 0; while( *p ) { assert( p < (buf+length) ); assert( q <= (buf+length) ); assert( q <= p ); if ( *p == CR ) { *q++ = LF; p++; if ( *p == LF ) { // check for CR+LF (and skip LF) p++; } } else { *q++ = *p++; } } assert( q <= (buf+length) ); *q = 0; Parse( buf, 0, encoding ); delete [] buf; return !Error(); } bool TiXmlDocument::SaveFile( const char * filename ) const { // The old c stuff lives on... FILE* fp = TiXmlFOpen( filename, "w" ); if ( fp ) { bool result = SaveFile( fp ); fclose( fp ); return result; } return false; } bool TiXmlDocument::SaveFile( FILE* fp ) const { if ( useMicrosoftBOM ) { const unsigned char TIXML_UTF_LEAD_0 = 0xefU; const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; fputc( TIXML_UTF_LEAD_0, fp ); fputc( TIXML_UTF_LEAD_1, fp ); fputc( TIXML_UTF_LEAD_2, fp ); } Print( fp, 0 ); return (ferror(fp) == 0); } void TiXmlDocument::CopyTo( TiXmlDocument* target ) const { TiXmlNode::CopyTo( target ); target->error = error; target->errorId = errorId; target->errorDesc = errorDesc; target->tabsize = tabsize; target->errorLocation = errorLocation; target->useMicrosoftBOM = useMicrosoftBOM; TiXmlNode* node = 0; for ( node = firstChild; node; node = node->NextSibling() ) { target->LinkEndChild( node->Clone() ); } } TiXmlNode* TiXmlDocument::Clone() const { TiXmlDocument* clone = new TiXmlDocument(); if ( !clone ) return 0; CopyTo( clone ); return clone; } void TiXmlDocument::Print( FILE* cfile, int depth ) const { assert( cfile ); for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) { node->Print( cfile, depth ); fprintf( cfile, "\n" ); } } bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const { if ( visitor->VisitEnter( *this ) ) { for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) { if ( !node->Accept( visitor ) ) break; } } return visitor->VisitExit( *this ); } const TiXmlAttribute* TiXmlAttribute::Next() const { // We are using knowledge of the sentinel. The sentinel // have a value or name. if ( next->value.empty() && next->name.empty() ) return 0; return next; } /* TiXmlAttribute* TiXmlAttribute::Next() { // We are using knowledge of the sentinel. The sentinel // have a value or name. if ( next->value.empty() && next->name.empty() ) return 0; return next; } */ const TiXmlAttribute* TiXmlAttribute::Previous() const { // We are using knowledge of the sentinel. The sentinel // have a value or name. if ( prev->value.empty() && prev->name.empty() ) return 0; return prev; } /* TiXmlAttribute* TiXmlAttribute::Previous() { // We are using knowledge of the sentinel. The sentinel // have a value or name. if ( prev->value.empty() && prev->name.empty() ) return 0; return prev; } */ void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const { TIXML_STRING n, v; EncodeString( name, &n ); EncodeString( value, &v ); if (value.find ('\"') == TIXML_STRING::npos) { if ( cfile ) { fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); } if ( str ) { (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; } } else { if ( cfile ) { fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); } if ( str ) { (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; } } } int TiXmlAttribute::QueryIntValue( int* ival ) const { if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 ) return TIXML_SUCCESS; return TIXML_WRONG_TYPE; } int TiXmlAttribute::QueryDoubleValue( double* dval ) const { if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 ) return TIXML_SUCCESS; return TIXML_WRONG_TYPE; } void TiXmlAttribute::SetIntValue( int _value ) { char buf [64]; #if defined(TIXML_SNPRINTF) TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); #else sprintf (buf, "%d", _value); #endif SetValue (buf); } void TiXmlAttribute::SetDoubleValue( double _value ) { char buf [256]; #if defined(TIXML_SNPRINTF) TIXML_SNPRINTF( buf, sizeof(buf), "%g", _value); #else sprintf (buf, "%g", _value); #endif SetValue (buf); } int TiXmlAttribute::IntValue() const { return atoi (value.c_str ()); } double TiXmlAttribute::DoubleValue() const { return atof (value.c_str ()); } TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) { copy.CopyTo( this ); } TiXmlComment& TiXmlComment::operator=( const TiXmlComment& base ) { Clear(); base.CopyTo( this ); return *this; } void TiXmlComment::Print( FILE* cfile, int depth ) const { assert( cfile ); for ( int i=0; i", value.c_str() ); } void TiXmlComment::CopyTo( TiXmlComment* target ) const { TiXmlNode::CopyTo( target ); } bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const { return visitor->Visit( *this ); } TiXmlNode* TiXmlComment::Clone() const { TiXmlComment* clone = new TiXmlComment(); if ( !clone ) return 0; CopyTo( clone ); return clone; } void TiXmlText::Print( FILE* cfile, int depth ) const { assert( cfile ); if ( cdata ) { int i; fprintf( cfile, "\n" ); for ( i=0; i\n", value.c_str() ); // unformatted output } else { TIXML_STRING buffer; EncodeString( value, &buffer ); fprintf( cfile, "%s", buffer.c_str() ); } } void TiXmlText::CopyTo( TiXmlText* target ) const { TiXmlNode::CopyTo( target ); target->cdata = cdata; } bool TiXmlText::Accept( TiXmlVisitor* visitor ) const { return visitor->Visit( *this ); } TiXmlNode* TiXmlText::Clone() const { TiXmlText* clone = 0; clone = new TiXmlText( "" ); if ( !clone ) return 0; CopyTo( clone ); return clone; } TiXmlDeclaration::TiXmlDeclaration( const char * _version, const char * _encoding, const char * _standalone ) : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) { version = _version; encoding = _encoding; standalone = _standalone; } #ifdef TIXML_USE_STL TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, const std::string& _encoding, const std::string& _standalone ) : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) { version = _version; encoding = _encoding; standalone = _standalone; } #endif TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy ) : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) { copy.CopyTo( this ); } TiXmlDeclaration& TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ) { Clear(); copy.CopyTo( this ); return *this; } void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const { if ( cfile ) fprintf( cfile, "" ); if ( str ) (*str) += "?>"; } void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const { TiXmlNode::CopyTo( target ); target->version = version; target->encoding = encoding; target->standalone = standalone; } bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const { return visitor->Visit( *this ); } TiXmlNode* TiXmlDeclaration::Clone() const { TiXmlDeclaration* clone = new TiXmlDeclaration(); if ( !clone ) return 0; CopyTo( clone ); return clone; } void TiXmlUnknown::Print( FILE* cfile, int depth ) const { for ( int i=0; i", value.c_str() ); } void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const { TiXmlNode::CopyTo( target ); } bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const { return visitor->Visit( *this ); } TiXmlNode* TiXmlUnknown::Clone() const { TiXmlUnknown* clone = new TiXmlUnknown(); if ( !clone ) return 0; CopyTo( clone ); return clone; } TiXmlAttributeSet::TiXmlAttributeSet() { sentinel.next = &sentinel; sentinel.prev = &sentinel; } TiXmlAttributeSet::~TiXmlAttributeSet() { assert( sentinel.next == &sentinel ); assert( sentinel.prev == &sentinel ); } void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ) { #ifdef TIXML_USE_STL assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set. #else assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. #endif addMe->next = &sentinel; addMe->prev = sentinel.prev; sentinel.prev->next = addMe; sentinel.prev = addMe; } void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) { TiXmlAttribute* node; for( node = sentinel.next; node != &sentinel; node = node->next ) { if ( node == removeMe ) { node->prev->next = node->next; node->next->prev = node->prev; node->next = 0; node->prev = 0; return; } } assert( 0 ); // we tried to remove a non-linked attribute. } #ifdef TIXML_USE_STL TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const { for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) { if ( node->name == name ) return node; } return 0; } TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const std::string& _name ) { TiXmlAttribute* attrib = Find( _name ); if ( !attrib ) { attrib = new TiXmlAttribute(); Add( attrib ); attrib->SetName( _name ); } return attrib; } #endif TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const { for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) { if ( strcmp( node->name.c_str(), name ) == 0 ) return node; } return 0; } TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const char* _name ) { TiXmlAttribute* attrib = Find( _name ); if ( !attrib ) { attrib = new TiXmlAttribute(); Add( attrib ); attrib->SetName( _name ); } return attrib; } #ifdef TIXML_USE_STL std::istream& operator>> (std::istream & in, TiXmlNode & base) { TIXML_STRING tag; tag.reserve( 8 * 1000 ); base.StreamIn( &in, &tag ); base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); return in; } #endif #ifdef TIXML_USE_STL std::ostream& operator<< (std::ostream & out, const TiXmlNode & base) { TiXmlPrinter printer; printer.SetStreamPrinting(); base.Accept( &printer ); out << printer.Str(); return out; } std::string& operator<< (std::string& out, const TiXmlNode& base ) { TiXmlPrinter printer; printer.SetStreamPrinting(); base.Accept( &printer ); out.append( printer.Str() ); return out; } #endif TiXmlHandle TiXmlHandle::FirstChild() const { if ( node ) { TiXmlNode* child = node->FirstChild(); if ( child ) return TiXmlHandle( child ); } return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const { if ( node ) { TiXmlNode* child = node->FirstChild( value ); if ( child ) return TiXmlHandle( child ); } return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::FirstChildElement() const { if ( node ) { TiXmlElement* child = node->FirstChildElement(); if ( child ) return TiXmlHandle( child ); } return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const { if ( node ) { TiXmlElement* child = node->FirstChildElement( value ); if ( child ) return TiXmlHandle( child ); } return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::Child( int count ) const { if ( node ) { int i; TiXmlNode* child = node->FirstChild(); for ( i=0; child && iNextSibling(), ++i ) { // nothing } if ( child ) return TiXmlHandle( child ); } return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const { if ( node ) { int i; TiXmlNode* child = node->FirstChild( value ); for ( i=0; child && iNextSibling( value ), ++i ) { // nothing } if ( child ) return TiXmlHandle( child ); } return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::ChildElement( int count ) const { if ( node ) { int i; TiXmlElement* child = node->FirstChildElement(); for ( i=0; child && iNextSiblingElement(), ++i ) { // nothing } if ( child ) return TiXmlHandle( child ); } return TiXmlHandle( 0 ); } TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const { if ( node ) { int i; TiXmlElement* child = node->FirstChildElement( value ); for ( i=0; child && iNextSiblingElement( value ), ++i ) { // nothing } if ( child ) return TiXmlHandle( child ); } return TiXmlHandle( 0 ); } bool TiXmlPrinter::VisitEnter( const TiXmlDocument& ) { return true; } bool TiXmlPrinter::VisitExit( const TiXmlDocument& ) { return true; } bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) { DoIndent(); buffer += "<"; buffer += element.Value(); for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) { buffer += " "; attrib->Print( 0, 0, &buffer ); } if ( !element.FirstChild() ) { buffer += " />"; DoLineBreak(); } else { buffer += ">"; if ( element.FirstChild()->ToText() && element.LastChild() == element.FirstChild() && element.FirstChild()->ToText()->CDATA() == false ) { simpleTextPrint = true; // no DoLineBreak()! } else { DoLineBreak(); } } ++depth; return true; } bool TiXmlPrinter::VisitExit( const TiXmlElement& element ) { --depth; if ( !element.FirstChild() ) { // nothing. } else { if ( simpleTextPrint ) { simpleTextPrint = false; } else { DoIndent(); } buffer += ""; DoLineBreak(); } return true; } bool TiXmlPrinter::Visit( const TiXmlText& text ) { if ( text.CDATA() ) { DoIndent(); buffer += ""; DoLineBreak(); } else if ( simpleTextPrint ) { TIXML_STRING str; TiXmlBase::EncodeString( text.ValueTStr(), &str ); buffer += str; } else { DoIndent(); TIXML_STRING str; TiXmlBase::EncodeString( text.ValueTStr(), &str ); buffer += str; DoLineBreak(); } return true; } bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) { DoIndent(); declaration.Print( 0, 0, &buffer ); DoLineBreak(); return true; } bool TiXmlPrinter::Visit( const TiXmlComment& comment ) { DoIndent(); buffer += ""; DoLineBreak(); return true; } bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) { DoIndent(); buffer += "<"; buffer += unknown.Value(); buffer += ">"; DoLineBreak(); return true; } tinyxml/tinyxml.h000644 000765 000024 00000176502 11563634571 016146 0ustar00leethomasonstaff000000 000000 /* www.sourceforge.net/projects/tinyxml Original code by Lee Thomason (www.grinninglizard.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef TINYXML_INCLUDED #define TINYXML_INCLUDED #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable : 4530 ) #pragma warning( disable : 4786 ) #endif #include #include #include #include #include // Help out windows: #if defined( _DEBUG ) && !defined( DEBUG ) #define DEBUG #endif #ifdef TIXML_USE_STL #include #include #include #define TIXML_STRING std::string #else #include "tinystr.h" #define TIXML_STRING TiXmlString #endif // Deprecated library function hell. Compilers want to use the // new safe versions. This probably doesn't fully address the problem, // but it gets closer. There are too many compilers for me to fully // test. If you get compilation troubles, undefine TIXML_SAFE #define TIXML_SAFE #ifdef TIXML_SAFE #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) // Microsoft visual studio, version 2005 and higher. #define TIXML_SNPRINTF _snprintf_s #define TIXML_SSCANF sscanf_s #elif defined(_MSC_VER) && (_MSC_VER >= 1200 ) // Microsoft visual studio, version 6 and higher. //#pragma message( "Using _sn* functions." ) #define TIXML_SNPRINTF _snprintf #define TIXML_SSCANF sscanf #elif defined(__GNUC__) && (__GNUC__ >= 3 ) // GCC version 3 and higher.s //#warning( "Using sn* functions." ) #define TIXML_SNPRINTF snprintf #define TIXML_SSCANF sscanf #else #define TIXML_SNPRINTF snprintf #define TIXML_SSCANF sscanf #endif #endif class TiXmlDocument; class TiXmlElement; class TiXmlComment; class TiXmlUnknown; class TiXmlAttribute; class TiXmlText; class TiXmlDeclaration; class TiXmlParsingData; const int TIXML_MAJOR_VERSION = 2; const int TIXML_MINOR_VERSION = 6; const int TIXML_PATCH_VERSION = 2; /* Internal structure for tracking location of items in the XML file. */ struct TiXmlCursor { TiXmlCursor() { Clear(); } void Clear() { row = col = -1; } int row; // 0 based. int col; // 0 based. }; /** Implements the interface to the "Visitor pattern" (see the Accept() method.) If you call the Accept() method, it requires being passed a TiXmlVisitor class to handle callbacks. For nodes that contain other nodes (Document, Element) you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves are simply called with Visit(). If you return 'true' from a Visit method, recursive parsing will continue. If you return false, no children of this node or its sibilings will be Visited. All flavors of Visit methods have a default implementation that returns 'true' (continue visiting). You need to only override methods that are interesting to you. Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting. You should never change the document from a callback. @sa TiXmlNode::Accept() */ class TiXmlVisitor { public: virtual ~TiXmlVisitor() {} /// Visit a document. virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; } /// Visit a document. virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; } /// Visit an element. virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; } /// Visit an element. virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; } /// Visit a declaration virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; } /// Visit a text node virtual bool Visit( const TiXmlText& /*text*/ ) { return true; } /// Visit a comment node virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; } /// Visit an unknown node virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; } }; // Only used by Attribute::Query functions enum { TIXML_SUCCESS, TIXML_NO_ATTRIBUTE, TIXML_WRONG_TYPE }; // Used by the parsing routines. enum TiXmlEncoding { TIXML_ENCODING_UNKNOWN, TIXML_ENCODING_UTF8, TIXML_ENCODING_LEGACY }; const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN; /** TiXmlBase is a base class for every class in TinyXml. It does little except to establish that TinyXml classes can be printed and provide some utility functions. In XML, the document and elements can contain other elements and other types of nodes. @verbatim A Document can contain: Element (container or leaf) Comment (leaf) Unknown (leaf) Declaration( leaf ) An Element can contain: Element (container or leaf) Text (leaf) Attributes (not on tree) Comment (leaf) Unknown (leaf) A Decleration contains: Attributes (not on tree) @endverbatim */ class TiXmlBase { friend class TiXmlNode; friend class TiXmlElement; friend class TiXmlDocument; public: TiXmlBase() : userData(0) {} virtual ~TiXmlBase() {} /** All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.) Either or both cfile and str can be null. This is a formatted print, and will insert tabs and newlines. (For an unformatted stream, use the << operator.) */ virtual void Print( FILE* cfile, int depth ) const = 0; /** The world does not agree on whether white space should be kept or not. In order to make everyone happy, these global, static functions are provided to set whether or not TinyXml will condense all white space into a single space or not. The default is to condense. Note changing this value is not thread safe. */ static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; } /// Return the current white space setting. static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; } /** Return the position, in the original source file, of this node or attribute. The row and column are 1-based. (That is the first row and first column is 1,1). If the returns values are 0 or less, then the parser does not have a row and column value. Generally, the row and column value will be set when the TiXmlDocument::Load(), TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set when the DOM was created from operator>>. The values reflect the initial load. Once the DOM is modified programmatically (by adding or changing nodes and attributes) the new values will NOT update to reflect changes in the document. There is a minor performance cost to computing the row and column. Computation can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value. @sa TiXmlDocument::SetTabSize() */ int Row() const { return location.row + 1; } int Column() const { return location.col + 1; } ///< See Row() void SetUserData( void* user ) { userData = user; } ///< Set a pointer to arbitrary user data. void* GetUserData() { return userData; } ///< Get a pointer to arbitrary user data. const void* GetUserData() const { return userData; } ///< Get a pointer to arbitrary user data. // Table that returs, for a given lead byte, the total number of bytes // in the UTF-8 sequence. static const int utf8ByteTable[256]; virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0; /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, or they will be transformed into entities! */ static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out ); enum { TIXML_NO_ERROR = 0, TIXML_ERROR, TIXML_ERROR_OPENING_FILE, TIXML_ERROR_PARSING_ELEMENT, TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, TIXML_ERROR_READING_ELEMENT_VALUE, TIXML_ERROR_READING_ATTRIBUTES, TIXML_ERROR_PARSING_EMPTY, TIXML_ERROR_READING_END_TAG, TIXML_ERROR_PARSING_UNKNOWN, TIXML_ERROR_PARSING_COMMENT, TIXML_ERROR_PARSING_DECLARATION, TIXML_ERROR_DOCUMENT_EMPTY, TIXML_ERROR_EMBEDDED_NULL, TIXML_ERROR_PARSING_CDATA, TIXML_ERROR_DOCUMENT_TOP_ONLY, TIXML_ERROR_STRING_COUNT }; protected: static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); inline static bool IsWhiteSpace( char c ) { return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); } inline static bool IsWhiteSpace( int c ) { if ( c < 256 ) return IsWhiteSpace( (char) c ); return false; // Again, only truly correct for English/Latin...but usually works. } #ifdef TIXML_USE_STL static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ); static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag ); #endif /* Reads an XML name into the string provided. Returns a pointer just past the last character of the name, or 0 if the function has an error. */ static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding ); /* Reads text. Returns a pointer past the given end tag. Wickedly complex options, but it keeps the (sensitive) code in one place. */ static const char* ReadText( const char* in, // where to start TIXML_STRING* text, // the string read bool ignoreWhiteSpace, // whether to keep the white space const char* endTag, // what ends this text bool ignoreCase, // whether to ignore case in the end tag TiXmlEncoding encoding ); // the current encoding // If an entity has been found, transform it into a character. static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding ); // Get a character, while interpreting entities. // The length can be from 0 to 4 bytes. inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding ) { assert( p ); if ( encoding == TIXML_ENCODING_UTF8 ) { *length = utf8ByteTable[ *((const unsigned char*)p) ]; assert( *length >= 0 && *length < 5 ); } else { *length = 1; } if ( *length == 1 ) { if ( *p == '&' ) return GetEntity( p, _value, length, encoding ); *_value = *p; return p+1; } else if ( *length ) { //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe), // and the null terminator isn't needed for( int i=0; p[i] && i<*length; ++i ) { _value[i] = p[i]; } return p + (*length); } else { // Not valid text. return 0; } } // Return true if the next characters in the stream are any of the endTag sequences. // Ignore case only works for english, and should only be relied on when comparing // to English words: StringEqual( p, "version", true ) is fine. static bool StringEqual( const char* p, const char* endTag, bool ignoreCase, TiXmlEncoding encoding ); static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; TiXmlCursor location; /// Field containing a generic user pointer void* userData; // None of these methods are reliable for any language except English. // Good for approximation, not great for accuracy. static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding ); static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding ); inline static int ToLower( int v, TiXmlEncoding encoding ) { if ( encoding == TIXML_ENCODING_UTF8 ) { if ( v < 128 ) return tolower( v ); return v; } else { return tolower( v ); } } static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); private: TiXmlBase( const TiXmlBase& ); // not implemented. void operator=( const TiXmlBase& base ); // not allowed. struct Entity { const char* str; unsigned int strLength; char chr; }; enum { NUM_ENTITY = 5, MAX_ENTITY_LENGTH = 6 }; static Entity entity[ NUM_ENTITY ]; static bool condenseWhiteSpace; }; /** The parent class for everything in the Document Object Model. (Except for attributes). Nodes have siblings, a parent, and children. A node can be in a document, or stand on its own. The type of a TiXmlNode can be queried, and it can be cast to its more defined type. */ class TiXmlNode : public TiXmlBase { friend class TiXmlDocument; friend class TiXmlElement; public: #ifdef TIXML_USE_STL /** An input stream operator, for every class. Tolerant of newlines and formatting, but doesn't expect them. */ friend std::istream& operator >> (std::istream& in, TiXmlNode& base); /** An output stream operator, for every class. Note that this outputs without any newlines or formatting, as opposed to Print(), which includes tabs and new lines. The operator<< and operator>> are not completely symmetric. Writing a node to a stream is very well defined. You'll get a nice stream of output, without any extra whitespace or newlines. But reading is not as well defined. (As it always is.) If you create a TiXmlElement (for example) and read that from an input stream, the text needs to define an element or junk will result. This is true of all input streams, but it's worth keeping in mind. A TiXmlDocument will read nodes until it reads a root element, and all the children of that root element. */ friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base); /// Appends the XML node or attribute to a std::string. friend std::string& operator<< (std::string& out, const TiXmlNode& base ); #endif /** The types of XML nodes supported by TinyXml. (All the unsupported types are picked up by UNKNOWN.) */ enum NodeType { TINYXML_DOCUMENT, TINYXML_ELEMENT, TINYXML_COMMENT, TINYXML_UNKNOWN, TINYXML_TEXT, TINYXML_DECLARATION, TINYXML_TYPECOUNT }; virtual ~TiXmlNode(); /** The meaning of 'value' changes for the specific type of TiXmlNode. @verbatim Document: filename of the xml file Element: name of the element Comment: the comment text Unknown: the tag contents Text: the text string @endverbatim The subclasses will wrap this function. */ const char *Value() const { return value.c_str (); } #ifdef TIXML_USE_STL /** Return Value() as a std::string. If you only use STL, this is more efficient than calling Value(). Only available in STL mode. */ const std::string& ValueStr() const { return value; } #endif const TIXML_STRING& ValueTStr() const { return value; } /** Changes the value of the node. Defined as: @verbatim Document: filename of the xml file Element: name of the element Comment: the comment text Unknown: the tag contents Text: the text string @endverbatim */ void SetValue(const char * _value) { value = _value;} #ifdef TIXML_USE_STL /// STL std::string form. void SetValue( const std::string& _value ) { value = _value; } #endif /// Delete all the children of this node. Does not affect 'this'. void Clear(); /// One step up the DOM. TiXmlNode* Parent() { return parent; } const TiXmlNode* Parent() const { return parent; } const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. TiXmlNode* FirstChild() { return firstChild; } const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. /// The first child of this node with the matching 'value'. Will be null if none found. TiXmlNode* FirstChild( const char * _value ) { // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe) // call the method, cast the return back to non-const. return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value )); } const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. TiXmlNode* LastChild() { return lastChild; } const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. TiXmlNode* LastChild( const char * _value ) { return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value )); } #ifdef TIXML_USE_STL const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form. TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); } ///< STL std::string form. const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form. TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); } ///< STL std::string form. #endif /** An alternate way to walk the children of a node. One way to iterate over nodes is: @verbatim for( child = parent->FirstChild(); child; child = child->NextSibling() ) @endverbatim IterateChildren does the same thing with the syntax: @verbatim child = 0; while( child = parent->IterateChildren( child ) ) @endverbatim IterateChildren takes the previous child as input and finds the next one. If the previous child is null, it returns the first. IterateChildren will return null when done. */ const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const; TiXmlNode* IterateChildren( const TiXmlNode* previous ) { return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) ); } /// This flavor of IterateChildren searches for children with a particular 'value' const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const; TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) { return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) ); } #ifdef TIXML_USE_STL const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. #endif /** Add a new node related to this. Adds a child past the LastChild. Returns a pointer to the new object or NULL if an error occured. */ TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); /** Add a new node related to this. Adds a child past the LastChild. NOTE: the node to be added is passed by pointer, and will be henceforth owned (and deleted) by tinyXml. This method is efficient and avoids an extra copy, but should be used with care as it uses a different memory model than the other insert functions. @sa InsertEndChild */ TiXmlNode* LinkEndChild( TiXmlNode* addThis ); /** Add a new node related to this. Adds a child before the specified child. Returns a pointer to the new object or NULL if an error occured. */ TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); /** Add a new node related to this. Adds a child after the specified child. Returns a pointer to the new object or NULL if an error occured. */ TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); /** Replace a child of this node. Returns a pointer to the new object or NULL if an error occured. */ TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); /// Delete a child of this node. bool RemoveChild( TiXmlNode* removeThis ); /// Navigate to a sibling node. const TiXmlNode* PreviousSibling() const { return prev; } TiXmlNode* PreviousSibling() { return prev; } /// Navigate to a sibling node. const TiXmlNode* PreviousSibling( const char * ) const; TiXmlNode* PreviousSibling( const char *_prev ) { return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) ); } #ifdef TIXML_USE_STL const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form. TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); } ///< STL std::string form. #endif /// Navigate to a sibling node. const TiXmlNode* NextSibling() const { return next; } TiXmlNode* NextSibling() { return next; } /// Navigate to a sibling node with the given 'value'. const TiXmlNode* NextSibling( const char * ) const; TiXmlNode* NextSibling( const char* _next ) { return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) ); } /** Convenience function to get through elements. Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element. */ const TiXmlElement* NextSiblingElement() const; TiXmlElement* NextSiblingElement() { return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() ); } /** Convenience function to get through elements. Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element. */ const TiXmlElement* NextSiblingElement( const char * ) const; TiXmlElement* NextSiblingElement( const char *_next ) { return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) ); } #ifdef TIXML_USE_STL const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. #endif /// Convenience function to get through elements. const TiXmlElement* FirstChildElement() const; TiXmlElement* FirstChildElement() { return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() ); } /// Convenience function to get through elements. const TiXmlElement* FirstChildElement( const char * _value ) const; TiXmlElement* FirstChildElement( const char * _value ) { return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) ); } #ifdef TIXML_USE_STL const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. #endif /** Query the type (as an enumerated value, above) of this node. The possible types are: TINYXML_DOCUMENT, TINYXML_ELEMENT, TINYXML_COMMENT, TINYXML_UNKNOWN, TINYXML_TEXT, and TINYXML_DECLARATION. */ int Type() const { return type; } /** Return a pointer to the Document this node lives in. Returns null if not in a document. */ const TiXmlDocument* GetDocument() const; TiXmlDocument* GetDocument() { return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() ); } /// Returns true if this node has no children. bool NoChildren() const { return !firstChild; } virtual const TiXmlDocument* ToDocument() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual const TiXmlElement* ToElement() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual const TiXmlComment* ToComment() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual const TiXmlUnknown* ToUnknown() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual const TiXmlText* ToText() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual TiXmlDocument* ToDocument() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual TiXmlElement* ToElement() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual TiXmlComment* ToComment() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual TiXmlUnknown* ToUnknown() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual TiXmlText* ToText() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. /** Create an exact duplicate of this node and return it. The memory must be deleted by the caller. */ virtual TiXmlNode* Clone() const = 0; /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the XML tree will be conditionally visited and the host will be called back via the TiXmlVisitor interface. This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse the XML for the callbacks, so the performance of TinyXML is unchanged by using this interface versus any other.) The interface has been based on ideas from: - http://www.saxproject.org/ - http://c2.com/cgi/wiki?HierarchicalVisitorPattern Which are both good references for "visiting". An example of using Accept(): @verbatim TiXmlPrinter printer; tinyxmlDoc.Accept( &printer ); const char* xmlcstr = printer.CStr(); @endverbatim */ virtual bool Accept( TiXmlVisitor* visitor ) const = 0; protected: TiXmlNode( NodeType _type ); // Copy to the allocated object. Shared functionality between Clone, Copy constructor, // and the assignment operator. void CopyTo( TiXmlNode* target ) const; #ifdef TIXML_USE_STL // The real work of the input operator. virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0; #endif // Figure out what is at *p, and parse it. Returns null if it is not an xml node. TiXmlNode* Identify( const char* start, TiXmlEncoding encoding ); TiXmlNode* parent; NodeType type; TiXmlNode* firstChild; TiXmlNode* lastChild; TIXML_STRING value; TiXmlNode* prev; TiXmlNode* next; private: TiXmlNode( const TiXmlNode& ); // not implemented. void operator=( const TiXmlNode& base ); // not allowed. }; /** An attribute is a name-value pair. Elements have an arbitrary number of attributes, each with a unique name. @note The attributes are not TiXmlNodes, since they are not part of the tinyXML document object model. There are other suggested ways to look at this problem. */ class TiXmlAttribute : public TiXmlBase { friend class TiXmlAttributeSet; public: /// Construct an empty attribute. TiXmlAttribute() : TiXmlBase() { document = 0; prev = next = 0; } #ifdef TIXML_USE_STL /// std::string constructor. TiXmlAttribute( const std::string& _name, const std::string& _value ) { name = _name; value = _value; document = 0; prev = next = 0; } #endif /// Construct an attribute with a name and value. TiXmlAttribute( const char * _name, const char * _value ) { name = _name; value = _value; document = 0; prev = next = 0; } const char* Name() const { return name.c_str(); } ///< Return the name of this attribute. const char* Value() const { return value.c_str(); } ///< Return the value of this attribute. #ifdef TIXML_USE_STL const std::string& ValueStr() const { return value; } ///< Return the value of this attribute. #endif int IntValue() const; ///< Return the value of this attribute, converted to an integer. double DoubleValue() const; ///< Return the value of this attribute, converted to a double. // Get the tinyxml string representation const TIXML_STRING& NameTStr() const { return name; } /** QueryIntValue examines the value string. It is an alternative to the IntValue() method with richer error checking. If the value is an integer, it is stored in 'value' and the call returns TIXML_SUCCESS. If it is not an integer, it returns TIXML_WRONG_TYPE. A specialized but useful call. Note that for success it returns 0, which is the opposite of almost all other TinyXml calls. */ int QueryIntValue( int* _value ) const; /// QueryDoubleValue examines the value string. See QueryIntValue(). int QueryDoubleValue( double* _value ) const; void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. void SetValue( const char* _value ) { value = _value; } ///< Set the value. void SetIntValue( int _value ); ///< Set the value from an integer. void SetDoubleValue( double _value ); ///< Set the value from a double. #ifdef TIXML_USE_STL /// STL std::string form. void SetName( const std::string& _name ) { name = _name; } /// STL std::string form. void SetValue( const std::string& _value ) { value = _value; } #endif /// Get the next sibling attribute in the DOM. Returns null at end. const TiXmlAttribute* Next() const; TiXmlAttribute* Next() { return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); } /// Get the previous sibling attribute in the DOM. Returns null at beginning. const TiXmlAttribute* Previous() const; TiXmlAttribute* Previous() { return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); } bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; } /* Attribute parsing starts: first letter of the name returns: the next char after the value end quote */ virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); // Prints this Attribute to a FILE stream. virtual void Print( FILE* cfile, int depth ) const { Print( cfile, depth, 0 ); } void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; // [internal use] // Set the document pointer so the attribute can report errors. void SetDocument( TiXmlDocument* doc ) { document = doc; } private: TiXmlAttribute( const TiXmlAttribute& ); // not implemented. void operator=( const TiXmlAttribute& base ); // not allowed. TiXmlDocument* document; // A pointer back to a document, for error reporting. TIXML_STRING name; TIXML_STRING value; TiXmlAttribute* prev; TiXmlAttribute* next; }; /* A class used to manage a group of attributes. It is only used internally, both by the ELEMENT and the DECLARATION. The set can be changed transparent to the Element and Declaration classes that use it, but NOT transparent to the Attribute which has to implement a next() and previous() method. Which makes it a bit problematic and prevents the use of STL. This version is implemented with circular lists because: - I like circular lists - it demonstrates some independence from the (typical) doubly linked list. */ class TiXmlAttributeSet { public: TiXmlAttributeSet(); ~TiXmlAttributeSet(); void Add( TiXmlAttribute* attribute ); void Remove( TiXmlAttribute* attribute ); const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } TiXmlAttribute* Find( const char* _name ) const; TiXmlAttribute* FindOrCreate( const char* _name ); # ifdef TIXML_USE_STL TiXmlAttribute* Find( const std::string& _name ) const; TiXmlAttribute* FindOrCreate( const std::string& _name ); # endif private: //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), //*ME: this class must be also use a hidden/disabled copy-constructor !!! TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute) TiXmlAttribute sentinel; }; /** The element is a container class. It has a value, the element name, and can contain other elements, text, comments, and unknowns. Elements also contain an arbitrary number of attributes. */ class TiXmlElement : public TiXmlNode { public: /// Construct an element. TiXmlElement (const char * in_value); #ifdef TIXML_USE_STL /// std::string constructor. TiXmlElement( const std::string& _value ); #endif TiXmlElement( const TiXmlElement& ); TiXmlElement& operator=( const TiXmlElement& base ); virtual ~TiXmlElement(); /** Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. */ const char* Attribute( const char* name ) const; /** Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. If the attribute exists and can be converted to an integer, the integer value will be put in the return 'i', if 'i' is non-null. */ const char* Attribute( const char* name, int* i ) const; /** Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. If the attribute exists and can be converted to an double, the double value will be put in the return 'd', if 'd' is non-null. */ const char* Attribute( const char* name, double* d ) const; /** QueryIntAttribute examines the attribute - it is an alternative to the Attribute() method with richer error checking. If the attribute is an integer, it is stored in 'value' and the call returns TIXML_SUCCESS. If it is not an integer, it returns TIXML_WRONG_TYPE. If the attribute does not exist, then TIXML_NO_ATTRIBUTE is returned. */ int QueryIntAttribute( const char* name, int* _value ) const; /// QueryUnsignedAttribute examines the attribute - see QueryIntAttribute(). int QueryUnsignedAttribute( const char* name, unsigned* _value ) const; /** QueryBoolAttribute examines the attribute - see QueryIntAttribute(). Note that '1', 'true', or 'yes' are considered true, while '0', 'false' and 'no' are considered false. */ int QueryBoolAttribute( const char* name, bool* _value ) const; /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). int QueryDoubleAttribute( const char* name, double* _value ) const; /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(). int QueryFloatAttribute( const char* name, float* _value ) const { double d; int result = QueryDoubleAttribute( name, &d ); if ( result == TIXML_SUCCESS ) { *_value = (float)d; } return result; } #ifdef TIXML_USE_STL /// QueryStringAttribute examines the attribute - see QueryIntAttribute(). int QueryStringAttribute( const char* name, std::string* _value ) const { const char* cstr = Attribute( name ); if ( cstr ) { *_value = std::string( cstr ); return TIXML_SUCCESS; } return TIXML_NO_ATTRIBUTE; } /** Template form of the attribute query which will try to read the attribute into the specified type. Very easy, very powerful, but be careful to make sure to call this with the correct type. NOTE: This method doesn't work correctly for 'string' types that contain spaces. @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE */ template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const { const TiXmlAttribute* node = attributeSet.Find( name ); if ( !node ) return TIXML_NO_ATTRIBUTE; std::stringstream sstream( node->ValueStr() ); sstream >> *outValue; if ( !sstream.fail() ) return TIXML_SUCCESS; return TIXML_WRONG_TYPE; } int QueryValueAttribute( const std::string& name, std::string* outValue ) const { const TiXmlAttribute* node = attributeSet.Find( name ); if ( !node ) return TIXML_NO_ATTRIBUTE; *outValue = node->ValueStr(); return TIXML_SUCCESS; } #endif /** Sets an attribute of name to a given value. The attribute will be created if it does not exist, or changed if it does. */ void SetAttribute( const char* name, const char * _value ); #ifdef TIXML_USE_STL const std::string* Attribute( const std::string& name ) const; const std::string* Attribute( const std::string& name, int* i ) const; const std::string* Attribute( const std::string& name, double* d ) const; int QueryIntAttribute( const std::string& name, int* _value ) const; int QueryDoubleAttribute( const std::string& name, double* _value ) const; /// STL std::string form. void SetAttribute( const std::string& name, const std::string& _value ); ///< STL std::string form. void SetAttribute( const std::string& name, int _value ); ///< STL std::string form. void SetDoubleAttribute( const std::string& name, double value ); #endif /** Sets an attribute of name to a given value. The attribute will be created if it does not exist, or changed if it does. */ void SetAttribute( const char * name, int value ); /** Sets an attribute of name to a given value. The attribute will be created if it does not exist, or changed if it does. */ void SetDoubleAttribute( const char * name, double value ); /** Deletes an attribute with the given name. */ void RemoveAttribute( const char * name ); #ifdef TIXML_USE_STL void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::string form. #endif const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. TiXmlAttribute* FirstAttribute() { return attributeSet.First(); } const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } ///< Access the last attribute in this element. TiXmlAttribute* LastAttribute() { return attributeSet.Last(); } /** Convenience function for easy access to the text inside an element. Although easy and concise, GetText() is limited compared to getting the TiXmlText child and accessing it directly. If the first child of 'this' is a TiXmlText, the GetText() returns the character string of the Text node, else null is returned. This is a convenient method for getting the text of simple contained text: @verbatim This is text const char* str = fooElement->GetText(); @endverbatim 'str' will be a pointer to "This is text". Note that this function can be misleading. If the element foo was created from this XML: @verbatim This is text @endverbatim then the value of str would be null. The first child node isn't a text node, it is another element. From this XML: @verbatim This is text @endverbatim GetText() will return "This is ". WARNING: GetText() accesses a child node - don't become confused with the similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are safe type casts on the referenced node. */ const char* GetText() const; /// Creates a new Element and returns it - the returned element is a copy. virtual TiXmlNode* Clone() const; // Print the Element to a FILE stream. virtual void Print( FILE* cfile, int depth ) const; /* Attribtue parsing starts: next char past '<' returns: next char past '>' */ virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); virtual const TiXmlElement* ToElement() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlElement* ToElement() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* visitor ) const; protected: void CopyTo( TiXmlElement* target ) const; void ClearThis(); // like clear, but initializes 'this' object as well // Used to be public [internal use] #ifdef TIXML_USE_STL virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif /* [internal use] Reads the "value" of the element -- another element, or text. This should terminate with the current end tag. */ const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding ); private: TiXmlAttributeSet attributeSet; }; /** An XML comment. */ class TiXmlComment : public TiXmlNode { public: /// Constructs an empty comment. TiXmlComment() : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {} /// Construct a comment from text. TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) { SetValue( _value ); } TiXmlComment( const TiXmlComment& ); TiXmlComment& operator=( const TiXmlComment& base ); virtual ~TiXmlComment() {} /// Returns a copy of this Comment. virtual TiXmlNode* Clone() const; // Write this Comment to a FILE stream. virtual void Print( FILE* cfile, int depth ) const; /* Attribtue parsing starts: at the ! of the !-- returns: next char past '>' */ virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* visitor ) const; protected: void CopyTo( TiXmlComment* target ) const; // used to be public #ifdef TIXML_USE_STL virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif // virtual void StreamOut( TIXML_OSTREAM * out ) const; private: }; /** XML text. A text node can have 2 ways to output the next. "normal" output and CDATA. It will default to the mode it was parsed from the XML file and you generally want to leave it alone, but you can change the output mode with SetCDATA() and query it with CDATA(). */ class TiXmlText : public TiXmlNode { friend class TiXmlElement; public: /** Constructor for text element. By default, it is treated as normal, encoded text. If you want it be output as a CDATA text element, set the parameter _cdata to 'true' */ TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT) { SetValue( initValue ); cdata = false; } virtual ~TiXmlText() {} #ifdef TIXML_USE_STL /// Constructor. TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT) { SetValue( initValue ); cdata = false; } #endif TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_TEXT ) { copy.CopyTo( this ); } TiXmlText& operator=( const TiXmlText& base ) { base.CopyTo( this ); return *this; } // Write this text object to a FILE stream. virtual void Print( FILE* cfile, int depth ) const; /// Queries whether this represents text using a CDATA section. bool CDATA() const { return cdata; } /// Turns on or off a CDATA representation of text. void SetCDATA( bool _cdata ) { cdata = _cdata; } virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlText* ToText() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* content ) const; protected : /// [internal use] Creates a new Element and returns it. virtual TiXmlNode* Clone() const; void CopyTo( TiXmlText* target ) const; bool Blank() const; // returns true if all white space and new lines // [internal use] #ifdef TIXML_USE_STL virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif private: bool cdata; // true if this should be input and output as a CDATA style text element }; /** In correct XML the declaration is the first entry in the file. @verbatim @endverbatim TinyXml will happily read or write files without a declaration, however. There are 3 possible attributes to the declaration: version, encoding, and standalone. Note: In this version of the code, the attributes are handled as special cases, not generic attributes, simply because there can only be at most 3 and they are always the same. */ class TiXmlDeclaration : public TiXmlNode { public: /// Construct an empty declaration. TiXmlDeclaration() : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) {} #ifdef TIXML_USE_STL /// Constructor. TiXmlDeclaration( const std::string& _version, const std::string& _encoding, const std::string& _standalone ); #endif /// Construct. TiXmlDeclaration( const char* _version, const char* _encoding, const char* _standalone ); TiXmlDeclaration( const TiXmlDeclaration& copy ); TiXmlDeclaration& operator=( const TiXmlDeclaration& copy ); virtual ~TiXmlDeclaration() {} /// Version. Will return an empty string if none was found. const char *Version() const { return version.c_str (); } /// Encoding. Will return an empty string if none was found. const char *Encoding() const { return encoding.c_str (); } /// Is this a standalone document? const char *Standalone() const { return standalone.c_str (); } /// Creates a copy of this Declaration and returns it. virtual TiXmlNode* Clone() const; // Print this declaration to a FILE stream. virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; virtual void Print( FILE* cfile, int depth ) const { Print( cfile, depth, 0 ); } virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlDeclaration* ToDeclaration() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* visitor ) const; protected: void CopyTo( TiXmlDeclaration* target ) const; // used to be public #ifdef TIXML_USE_STL virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif private: TIXML_STRING version; TIXML_STRING encoding; TIXML_STRING standalone; }; /** Any tag that tinyXml doesn't recognize is saved as an unknown. It is a tag of text, but should not be modified. It will be written back to the XML, unchanged, when the file is saved. DTD tags get thrown into TiXmlUnknowns. */ class TiXmlUnknown : public TiXmlNode { public: TiXmlUnknown() : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) {} virtual ~TiXmlUnknown() {} TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) { copy.CopyTo( this ); } TiXmlUnknown& operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); return *this; } /// Creates a copy of this Unknown and returns it. virtual TiXmlNode* Clone() const; // Print this Unknown to a FILE stream. virtual void Print( FILE* cfile, int depth ) const; virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* content ) const; protected: void CopyTo( TiXmlUnknown* target ) const; #ifdef TIXML_USE_STL virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif private: }; /** Always the top level node. A document binds together all the XML pieces. It can be saved, loaded, and printed to the screen. The 'value' of a document node is the xml file name. */ class TiXmlDocument : public TiXmlNode { public: /// Create an empty document, that has no name. TiXmlDocument(); /// Create a document with a name. The name of the document is also the filename of the xml. TiXmlDocument( const char * documentName ); #ifdef TIXML_USE_STL /// Constructor. TiXmlDocument( const std::string& documentName ); #endif TiXmlDocument( const TiXmlDocument& copy ); TiXmlDocument& operator=( const TiXmlDocument& copy ); virtual ~TiXmlDocument() {} /** Load a file using the current document value. Returns true if successful. Will delete any existing document data before loading. */ bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); /// Save a file using the current document value. Returns true if successful. bool SaveFile() const; /// Load a file using the given filename. Returns true if successful. bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); /// Save a file using the given filename. Returns true if successful. bool SaveFile( const char * filename ) const; /** Load a file using the given FILE*. Returns true if successful. Note that this method doesn't stream - the entire object pointed at by the FILE* will be interpreted as an XML file. TinyXML doesn't stream in XML from the current file location. Streaming may be added in the future. */ bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); /// Save a file using the given FILE*. Returns true if successful. bool SaveFile( FILE* ) const; #ifdef TIXML_USE_STL bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version. { return LoadFile( filename.c_str(), encoding ); } bool SaveFile( const std::string& filename ) const ///< STL std::string version. { return SaveFile( filename.c_str() ); } #endif /** Parse the given null terminated block of xml data. Passing in an encoding to this method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml to use that encoding, regardless of what TinyXml might otherwise try to detect. */ virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); /** Get the root element -- the only top level element -- of the document. In well formed XML, there should only be one. TinyXml is tolerant of multiple elements at the document level. */ const TiXmlElement* RootElement() const { return FirstChildElement(); } TiXmlElement* RootElement() { return FirstChildElement(); } /** If an error occurs, Error will be set to true. Also, - The ErrorId() will contain the integer identifier of the error (not generally useful) - The ErrorDesc() method will return the name of the error. (very useful) - The ErrorRow() and ErrorCol() will return the location of the error (if known) */ bool Error() const { return error; } /// Contains a textual (english) description of the error if one occurs. const char * ErrorDesc() const { return errorDesc.c_str (); } /** Generally, you probably want the error string ( ErrorDesc() ). But if you prefer the ErrorId, this function will fetch it. */ int ErrorId() const { return errorId; } /** Returns the location (if known) of the error. The first column is column 1, and the first row is row 1. A value of 0 means the row and column wasn't applicable (memory errors, for example, have no row/column) or the parser lost the error. (An error in the error reporting, in that case.) @sa SetTabSize, Row, Column */ int ErrorRow() const { return errorLocation.row+1; } int ErrorCol() const { return errorLocation.col+1; } ///< The column where the error occured. See ErrorRow() /** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) to report the correct values for row and column. It does not change the output or input in any way. By calling this method, with a tab size greater than 0, the row and column of each node and attribute is stored when the file is loaded. Very useful for tracking the DOM back in to the source file. The tab size is required for calculating the location of nodes. If not set, the default of 4 is used. The tabsize is set per document. Setting the tabsize to 0 disables row/column tracking. Note that row and column tracking is not supported when using operator>>. The tab size needs to be enabled before the parse or load. Correct usage: @verbatim TiXmlDocument doc; doc.SetTabSize( 8 ); doc.Load( "myfile.xml" ); @endverbatim @sa Row, Column */ void SetTabSize( int _tabsize ) { tabsize = _tabsize; } int TabSize() const { return tabsize; } /** If you have handled the error, it can be reset with this call. The error state is automatically cleared if you Parse a new XML block. */ void ClearError() { error = false; errorId = 0; errorDesc = ""; errorLocation.row = errorLocation.col = 0; //errorLocation.last = 0; } /** Write the document to standard out using formatted printing ("pretty print"). */ void Print() const { Print( stdout, 0 ); } /* Write the document to a string using formatted printing ("pretty print"). This will allocate a character array (new char[]) and return it as a pointer. The calling code pust call delete[] on the return char* to avoid a memory leak. */ //char* PrintToMemory() const; /// Print this Document to a FILE stream. virtual void Print( FILE* cfile, int depth = 0 ) const; // [internal use] void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding ); virtual const TiXmlDocument* ToDocument() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. virtual TiXmlDocument* ToDocument() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. /** Walk the XML tree visiting this node and all of its children. */ virtual bool Accept( TiXmlVisitor* content ) const; protected : // [internal use] virtual TiXmlNode* Clone() const; #ifdef TIXML_USE_STL virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif private: void CopyTo( TiXmlDocument* target ) const; bool error; int errorId; TIXML_STRING errorDesc; int tabsize; TiXmlCursor errorLocation; bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write. }; /** A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml DOM structure. It is a separate utility class. Take an example: @verbatim @endverbatim Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very easy to write a *lot* of code that looks like: @verbatim TiXmlElement* root = document.FirstChildElement( "Document" ); if ( root ) { TiXmlElement* element = root->FirstChildElement( "Element" ); if ( element ) { TiXmlElement* child = element->FirstChildElement( "Child" ); if ( child ) { TiXmlElement* child2 = child->NextSiblingElement( "Child" ); if ( child2 ) { // Finally do something useful. @endverbatim And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity of such code. A TiXmlHandle checks for null pointers so it is perfectly safe and correct to use: @verbatim TiXmlHandle docHandle( &document ); TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement(); if ( child2 ) { // do something useful @endverbatim Which is MUCH more concise and useful. It is also safe to copy handles - internally they are nothing more than node pointers. @verbatim TiXmlHandle handleCopy = handle; @endverbatim What they should not be used for is iteration: @verbatim int i=0; while ( true ) { TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement(); if ( !child ) break; // do something ++i; } @endverbatim It seems reasonable, but it is in fact two embedded while loops. The Child method is a linear walk to find the element, so this code would iterate much more than it needs to. Instead, prefer: @verbatim TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement(); for( child; child; child=child->NextSiblingElement() ) { // do something } @endverbatim */ class TiXmlHandle { public: /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. TiXmlHandle( TiXmlNode* _node ) { this->node = _node; } /// Copy constructor TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; } TiXmlHandle operator=( const TiXmlHandle& ref ) { if ( &ref != this ) this->node = ref.node; return *this; } /// Return a handle to the first child node. TiXmlHandle FirstChild() const; /// Return a handle to the first child node with the given name. TiXmlHandle FirstChild( const char * value ) const; /// Return a handle to the first child element. TiXmlHandle FirstChildElement() const; /// Return a handle to the first child element with the given name. TiXmlHandle FirstChildElement( const char * value ) const; /** Return a handle to the "index" child with the given name. The first child is 0, the second 1, etc. */ TiXmlHandle Child( const char* value, int index ) const; /** Return a handle to the "index" child. The first child is 0, the second 1, etc. */ TiXmlHandle Child( int index ) const; /** Return a handle to the "index" child element with the given name. The first child element is 0, the second 1, etc. Note that only TiXmlElements are indexed: other types are not counted. */ TiXmlHandle ChildElement( const char* value, int index ) const; /** Return a handle to the "index" child element. The first child element is 0, the second 1, etc. Note that only TiXmlElements are indexed: other types are not counted. */ TiXmlHandle ChildElement( int index ) const; #ifdef TIXML_USE_STL TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); } TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); } TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); } TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); } #endif /** Return the handle as a TiXmlNode. This may return null. */ TiXmlNode* ToNode() const { return node; } /** Return the handle as a TiXmlElement. This may return null. */ TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } /** Return the handle as a TiXmlText. This may return null. */ TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); } /** Return the handle as a TiXmlUnknown. This may return null. */ TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } /** @deprecated use ToNode. Return the handle as a TiXmlNode. This may return null. */ TiXmlNode* Node() const { return ToNode(); } /** @deprecated use ToElement. Return the handle as a TiXmlElement. This may return null. */ TiXmlElement* Element() const { return ToElement(); } /** @deprecated use ToText() Return the handle as a TiXmlText. This may return null. */ TiXmlText* Text() const { return ToText(); } /** @deprecated use ToUnknown() Return the handle as a TiXmlUnknown. This may return null. */ TiXmlUnknown* Unknown() const { return ToUnknown(); } private: TiXmlNode* node; }; /** Print to memory functionality. The TiXmlPrinter is useful when you need to: -# Print to memory (especially in non-STL mode) -# Control formatting (line endings, etc.) When constructed, the TiXmlPrinter is in its default "pretty printing" mode. Before calling Accept() you can call methods to control the printing of the XML document. After TiXmlNode::Accept() is called, the printed document can be accessed via the CStr(), Str(), and Size() methods. TiXmlPrinter uses the Visitor API. @verbatim TiXmlPrinter printer; printer.SetIndent( "\t" ); doc.Accept( &printer ); fprintf( stdout, "%s", printer.CStr() ); @endverbatim */ class TiXmlPrinter : public TiXmlVisitor { public: TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ), buffer(), indent( " " ), lineBreak( "\n" ) {} virtual bool VisitEnter( const TiXmlDocument& doc ); virtual bool VisitExit( const TiXmlDocument& doc ); virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ); virtual bool VisitExit( const TiXmlElement& element ); virtual bool Visit( const TiXmlDeclaration& declaration ); virtual bool Visit( const TiXmlText& text ); virtual bool Visit( const TiXmlComment& comment ); virtual bool Visit( const TiXmlUnknown& unknown ); /** Set the indent characters for printing. By default 4 spaces but tab (\t) is also useful, or null/empty string for no indentation. */ void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; } /// Query the indention string. const char* Indent() { return indent.c_str(); } /** Set the line breaking string. By default set to newline (\n). Some operating systems prefer other characters, or can be set to the null/empty string for no indenation. */ void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; } /// Query the current line breaking string. const char* LineBreak() { return lineBreak.c_str(); } /** Switch over to "stream printing" which is the most dense formatting without linebreaks. Common when the XML is needed for network transmission. */ void SetStreamPrinting() { indent = ""; lineBreak = ""; } /// Return the result. const char* CStr() { return buffer.c_str(); } /// Return the length of the result string. size_t Size() { return buffer.size(); } #ifdef TIXML_USE_STL /// Return the result. const std::string& Str() { return buffer; } #endif private: void DoIndent() { for( int i=0; i Debug Win32 Release Win32 tinyxml {C406DAEC-0886-4771-8DEA-9D7329B46CC1} StaticLibrary false MultiByte StaticLibrary false MultiByte <_ProjectFileVersion>10.0.30319.1 $(IncludePath) $(LibraryPath) $(IncludePath) $(LibraryPath) $(SolutionDir)$(Configuration)$(ProjectName)\ $(SolutionDir)$(Configuration)$(ProjectName)\ $(SolutionDir)$(Configuration)$(ProjectName)\ $(SolutionDir)$(Configuration)$(ProjectName)\ MaxSpeed OnlyExplicitInline WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) true MultiThreaded true Level3 true NDEBUG;%(PreprocessorDefinitions) 0x0407 true true Disabled WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug true Level4 true EditAndContinue _DEBUG;%(PreprocessorDefinitions) 0x0407 true true %(PreprocessorDefinitions) %(PreprocessorDefinitions) %(PreprocessorDefinitions) %(PreprocessorDefinitions) %(PreprocessorDefinitions) %(PreprocessorDefinitions) %(PreprocessorDefinitions) %(PreprocessorDefinitions) tinyxml/tinyxmlerror.cpp000644 000765 000024 00000003377 11563634571 017552 0ustar00leethomasonstaff000000 000000 /* www.sourceforge.net/projects/tinyxml Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "tinyxml.h" // The goal of the seperate error file is to make the first // step towards localization. tinyxml (currently) only supports // english error messages, but the could now be translated. // // It also cleans up the code a bit. // const char* TiXmlBase::errorString[ TiXmlBase::TIXML_ERROR_STRING_COUNT ] = { "No error", "Error", "Failed to open file", "Error parsing Element.", "Failed to read Element name", "Error reading Element value.", "Error reading Attributes.", "Error: empty tag.", "Error reading end tag.", "Error parsing Unknown.", "Error parsing Comment.", "Error parsing Declaration.", "Error document empty.", "Error null (0) or unexpected EOF found in input stream.", "Error parsing CDATA.", "Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.", }; tinyxml/tinyxmlparser.cpp000644 000765 000024 00000110572 11563634571 017711 0ustar00leethomasonstaff000000 000000 /* www.sourceforge.net/projects/tinyxml Original code by Lee Thomason (www.grinninglizard.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include #include #include "tinyxml.h" //#define DEBUG_PARSER #if defined( DEBUG_PARSER ) # if defined( DEBUG ) && defined( _MSC_VER ) # include # define TIXML_LOG OutputDebugString # else # define TIXML_LOG printf # endif #endif // Note tha "PutString" hardcodes the same list. This // is less flexible than it appears. Changing the entries // or order will break putstring. TiXmlBase::Entity TiXmlBase::entity[ TiXmlBase::NUM_ENTITY ] = { { "&", 5, '&' }, { "<", 4, '<' }, { ">", 4, '>' }, { """, 6, '\"' }, { "'", 6, '\'' } }; // Bunch of unicode info at: // http://www.unicode.org/faq/utf_bom.html // Including the basic of this table, which determines the #bytes in the // sequence from the lead byte. 1 placed for invalid sequences -- // although the result will be junk, pass it through as much as possible. // Beware of the non-characters in UTF-8: // ef bb bf (Microsoft "lead bytes") // ef bf be // ef bf bf const unsigned char TIXML_UTF_LEAD_0 = 0xefU; const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; const int TiXmlBase::utf8ByteTable[256] = { // 0 1 2 3 4 5 6 7 8 9 a b c d e f 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid }; void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) { const unsigned long BYTE_MASK = 0xBF; const unsigned long BYTE_MARK = 0x80; const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; if (input < 0x80) *length = 1; else if ( input < 0x800 ) *length = 2; else if ( input < 0x10000 ) *length = 3; else if ( input < 0x200000 ) *length = 4; else { *length = 0; return; } // This code won't covert this correctly anyway. output += *length; // Scary scary fall throughs. switch (*length) { case 4: --output; *output = (char)((input | BYTE_MARK) & BYTE_MASK); input >>= 6; case 3: --output; *output = (char)((input | BYTE_MARK) & BYTE_MASK); input >>= 6; case 2: --output; *output = (char)((input | BYTE_MARK) & BYTE_MASK); input >>= 6; case 1: --output; *output = (char)(input | FIRST_BYTE_MARK[*length]); } } /*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) { // This will only work for low-ascii, everything else is assumed to be a valid // letter. I'm not sure this is the best approach, but it is quite tricky trying // to figure out alhabetical vs. not across encoding. So take a very // conservative approach. // if ( encoding == TIXML_ENCODING_UTF8 ) // { if ( anyByte < 127 ) return isalpha( anyByte ); else return 1; // What else to do? The unicode set is huge...get the english ones right. // } // else // { // return isalpha( anyByte ); // } } /*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) { // This will only work for low-ascii, everything else is assumed to be a valid // letter. I'm not sure this is the best approach, but it is quite tricky trying // to figure out alhabetical vs. not across encoding. So take a very // conservative approach. // if ( encoding == TIXML_ENCODING_UTF8 ) // { if ( anyByte < 127 ) return isalnum( anyByte ); else return 1; // What else to do? The unicode set is huge...get the english ones right. // } // else // { // return isalnum( anyByte ); // } } class TiXmlParsingData { friend class TiXmlDocument; public: void Stamp( const char* now, TiXmlEncoding encoding ); const TiXmlCursor& Cursor() const { return cursor; } private: // Only used by the document! TiXmlParsingData( const char* start, int _tabsize, int row, int col ) { assert( start ); stamp = start; tabsize = _tabsize; cursor.row = row; cursor.col = col; } TiXmlCursor cursor; const char* stamp; int tabsize; }; void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding ) { assert( now ); // Do nothing if the tabsize is 0. if ( tabsize < 1 ) { return; } // Get the current row, column. int row = cursor.row; int col = cursor.col; const char* p = stamp; assert( p ); while ( p < now ) { // Treat p as unsigned, so we have a happy compiler. const unsigned char* pU = (const unsigned char*)p; // Code contributed by Fletcher Dunn: (modified by lee) switch (*pU) { case 0: // We *should* never get here, but in case we do, don't // advance past the terminating null character, ever return; case '\r': // bump down to the next line ++row; col = 0; // Eat the character ++p; // Check for \r\n sequence, and treat this as a single character if (*p == '\n') { ++p; } break; case '\n': // bump down to the next line ++row; col = 0; // Eat the character ++p; // Check for \n\r sequence, and treat this as a single // character. (Yes, this bizarre thing does occur still // on some arcane platforms...) if (*p == '\r') { ++p; } break; case '\t': // Eat the character ++p; // Skip to next tab stop col = (col / tabsize + 1) * tabsize; break; case TIXML_UTF_LEAD_0: if ( encoding == TIXML_ENCODING_UTF8 ) { if ( *(p+1) && *(p+2) ) { // In these cases, don't advance the column. These are // 0-width spaces. if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) p += 3; else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) p += 3; else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) p += 3; else { p +=3; ++col; } // A normal character. } } else { ++p; ++col; } break; default: if ( encoding == TIXML_ENCODING_UTF8 ) { // Eat the 1 to 4 byte utf8 character. int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)]; if ( step == 0 ) step = 1; // Error case from bad encoding, but handle gracefully. p += step; // Just advance one column, of course. ++col; } else { ++p; ++col; } break; } } cursor.row = row; cursor.col = col; assert( cursor.row >= -1 ); assert( cursor.col >= -1 ); stamp = p; assert( stamp ); } const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) { if ( !p || !*p ) { return 0; } if ( encoding == TIXML_ENCODING_UTF8 ) { while ( *p ) { const unsigned char* pU = (const unsigned char*)p; // Skip the stupid Microsoft UTF-8 Byte order marks if ( *(pU+0)==TIXML_UTF_LEAD_0 && *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) { p += 3; continue; } else if(*(pU+0)==TIXML_UTF_LEAD_0 && *(pU+1)==0xbfU && *(pU+2)==0xbeU ) { p += 3; continue; } else if(*(pU+0)==TIXML_UTF_LEAD_0 && *(pU+1)==0xbfU && *(pU+2)==0xbfU ) { p += 3; continue; } if ( IsWhiteSpace( *p ) ) // Still using old rules for white space. ++p; else break; } } else { while ( *p && IsWhiteSpace( *p ) ) ++p; } return p; } #ifdef TIXML_USE_STL /*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ) { for( ;; ) { if ( !in->good() ) return false; int c = in->peek(); // At this scope, we can't get to a document. So fail silently. if ( !IsWhiteSpace( c ) || c <= 0 ) return true; *tag += (char) in->get(); } } /*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag ) { //assert( character > 0 && character < 128 ); // else it won't work in utf-8 while ( in->good() ) { int c = in->peek(); if ( c == character ) return true; if ( c <= 0 ) // Silent failure: can't get document at this scope return false; in->get(); *tag += (char) c; } return false; } #endif // One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The // "assign" optimization removes over 10% of the execution time. // const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding ) { // Oddly, not supported on some comilers, //name->clear(); // So use this: *name = ""; assert( p ); // Names start with letters or underscores. // Of course, in unicode, tinyxml has no idea what a letter *is*. The // algorithm is generous. // // After that, they can be letters, underscores, numbers, // hyphens, or colons. (Colons are valid ony for namespaces, // but tinyxml can't tell namespaces from names.) if ( p && *p && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) { const char* start = p; while( p && *p && ( IsAlphaNum( (unsigned char ) *p, encoding ) || *p == '_' || *p == '-' || *p == '.' || *p == ':' ) ) { //(*name) += *p; // expensive ++p; } if ( p-start > 0 ) { name->assign( start, p-start ); } return p; } return 0; } const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) { // Presume an entity, and pull it out. TIXML_STRING ent; int i; *length = 0; if ( *(p+1) && *(p+1) == '#' && *(p+2) ) { unsigned long ucs = 0; ptrdiff_t delta = 0; unsigned mult = 1; if ( *(p+2) == 'x' ) { // Hexadecimal. if ( !*(p+3) ) return 0; const char* q = p+3; q = strchr( q, ';' ); if ( !q || !*q ) return 0; delta = q-p; --q; while ( *q != 'x' ) { if ( *q >= '0' && *q <= '9' ) ucs += mult * (*q - '0'); else if ( *q >= 'a' && *q <= 'f' ) ucs += mult * (*q - 'a' + 10); else if ( *q >= 'A' && *q <= 'F' ) ucs += mult * (*q - 'A' + 10 ); else return 0; mult *= 16; --q; } } else { // Decimal. if ( !*(p+2) ) return 0; const char* q = p+2; q = strchr( q, ';' ); if ( !q || !*q ) return 0; delta = q-p; --q; while ( *q != '#' ) { if ( *q >= '0' && *q <= '9' ) ucs += mult * (*q - '0'); else return 0; mult *= 10; --q; } } if ( encoding == TIXML_ENCODING_UTF8 ) { // convert the UCS to UTF-8 ConvertUTF32ToUTF8( ucs, value, length ); } else { *value = (char)ucs; *length = 1; } return p + delta + 1; } // Now try to match it. for( i=0; iappend( cArr, len ); } } else { bool whitespace = false; // Remove leading white space: p = SkipWhiteSpace( p, encoding ); while ( p && *p && !StringEqual( p, endTag, caseInsensitive, encoding ) ) { if ( *p == '\r' || *p == '\n' ) { whitespace = true; ++p; } else if ( IsWhiteSpace( *p ) ) { whitespace = true; ++p; } else { // If we've found whitespace, add it before the // new character. Any whitespace just becomes a space. if ( whitespace ) { (*text) += ' '; whitespace = false; } int len; char cArr[4] = { 0, 0, 0, 0 }; p = GetChar( p, cArr, &len, encoding ); if ( len == 1 ) (*text) += cArr[0]; // more efficient else text->append( cArr, len ); } } } if ( p && *p ) p += strlen( endTag ); return ( p && *p ) ? p : 0; } #ifdef TIXML_USE_STL void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) { // The basic issue with a document is that we don't know what we're // streaming. Read something presumed to be a tag (and hope), then // identify it, and call the appropriate stream method on the tag. // // This "pre-streaming" will never read the closing ">" so the // sub-tag can orient itself. if ( !StreamTo( in, '<', tag ) ) { SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); return; } while ( in->good() ) { int tagIndex = (int) tag->length(); while ( in->good() && in->peek() != '>' ) { int c = in->get(); if ( c <= 0 ) { SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); break; } (*tag) += (char) c; } if ( in->good() ) { // We now have something we presume to be a node of // some sort. Identify it, and call the node to // continue streaming. TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING ); if ( node ) { node->StreamIn( in, tag ); bool isElement = node->ToElement() != 0; delete node; node = 0; // If this is the root element, we're done. Parsing will be // done by the >> operator. if ( isElement ) { return; } } else { SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); return; } } } // We should have returned sooner. SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); } #endif const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding ) { ClearError(); // Parse away, at the document level. Since a document // contains nothing but other tags, most of what happens // here is skipping white space. if ( !p || !*p ) { SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } // Note that, for a document, this needs to come // before the while space skip, so that parsing // starts from the pointer we are given. location.Clear(); if ( prevData ) { location.row = prevData->cursor.row; location.col = prevData->cursor.col; } else { location.row = 0; location.col = 0; } TiXmlParsingData data( p, TabSize(), location.row, location.col ); location = data.Cursor(); if ( encoding == TIXML_ENCODING_UNKNOWN ) { // Check for the Microsoft UTF-8 lead bytes. const unsigned char* pU = (const unsigned char*)p; if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0 && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1 && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 ) { encoding = TIXML_ENCODING_UTF8; useMicrosoftBOM = true; } } p = SkipWhiteSpace( p, encoding ); if ( !p ) { SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; } while ( p && *p ) { TiXmlNode* node = Identify( p, encoding ); if ( node ) { p = node->Parse( p, &data, encoding ); LinkEndChild( node ); } else { break; } // Did we get encoding info? if ( encoding == TIXML_ENCODING_UNKNOWN && node->ToDeclaration() ) { TiXmlDeclaration* dec = node->ToDeclaration(); const char* enc = dec->Encoding(); assert( enc ); if ( *enc == 0 ) encoding = TIXML_ENCODING_UTF8; else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) ) encoding = TIXML_ENCODING_UTF8; else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) ) encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice else encoding = TIXML_ENCODING_LEGACY; } p = SkipWhiteSpace( p, encoding ); } // Was this empty? if ( !firstChild ) { SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); return 0; } // All is well. return p; } void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding ) { // The first error in a chain is more accurate - don't set again! if ( error ) return; assert( err > 0 && err < TIXML_ERROR_STRING_COUNT ); error = true; errorId = err; errorDesc = errorString[ errorId ]; errorLocation.Clear(); if ( pError && data ) { data->Stamp( pError, encoding ); errorLocation = data->Cursor(); } } TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding ) { TiXmlNode* returnNode = 0; p = SkipWhiteSpace( p, encoding ); if( !p || !*p || *p != '<' ) { return 0; } p = SkipWhiteSpace( p, encoding ); if ( !p || !*p ) { return 0; } // What is this thing? // - Elements start with a letter or underscore, but xml is reserved. // - Comments: "; if ( !StringEqual( p, startTag, false, encoding ) ) { if ( document ) document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); return 0; } p += strlen( startTag ); // [ 1475201 ] TinyXML parses entities in comments // Oops - ReadText doesn't work, because we don't want to parse the entities. // p = ReadText( p, &value, false, endTag, false, encoding ); // // from the XML spec: /* [Definition: Comments may appear anywhere in a document outside other markup; in addition, they may appear within the document type declaration at places allowed by the grammar. They are not part of the document's character data; an XML processor MAY, but need not, make it possible for an application to retrieve the text of comments. For compatibility, the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity references MUST NOT be recognized within comments. An example of a comment: */ value = ""; // Keep all the white space. while ( p && *p && !StringEqual( p, endTag, false, encoding ) ) { value.append( p, 1 ); ++p; } if ( p && *p ) p += strlen( endTag ); return p; } const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) { p = SkipWhiteSpace( p, encoding ); if ( !p || !*p ) return 0; if ( data ) { data->Stamp( p, encoding ); location = data->Cursor(); } // Read the name, the '=' and the value. const char* pErr = p; p = ReadName( p, &name, encoding ); if ( !p || !*p ) { if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); return 0; } p = SkipWhiteSpace( p, encoding ); if ( !p || !*p || *p != '=' ) { if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); return 0; } ++p; // skip '=' p = SkipWhiteSpace( p, encoding ); if ( !p || !*p ) { if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); return 0; } const char* end; const char SINGLE_QUOTE = '\''; const char DOUBLE_QUOTE = '\"'; if ( *p == SINGLE_QUOTE ) { ++p; end = "\'"; // single quote in string p = ReadText( p, &value, false, end, false, encoding ); } else if ( *p == DOUBLE_QUOTE ) { ++p; end = "\""; // double quote in string p = ReadText( p, &value, false, end, false, encoding ); } else { // All attribute values should be in single or double quotes. // But this is such a common error that the parser will try // its best, even without them. value = ""; while ( p && *p // existence && !IsWhiteSpace( *p ) // whitespace && *p != '/' && *p != '>' ) // tag end { if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) { // [ 1451649 ] Attribute values with trailing quotes not handled correctly // We did not have an opening quote but seem to have a // closing one. Give up and throw an error. if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); return 0; } value += *p; ++p; } } return p; } #ifdef TIXML_USE_STL void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag ) { while ( in->good() ) { int c = in->peek(); if ( !cdata && (c == '<' ) ) { return; } if ( c <= 0 ) { TiXmlDocument* document = GetDocument(); if ( document ) document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); return; } (*tag) += (char) c; in->get(); // "commits" the peek made above if ( cdata && c == '>' && tag->size() >= 3 ) { size_t len = tag->size(); if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) { // terminator of cdata. return; } } } } #endif const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) { value = ""; TiXmlDocument* document = GetDocument(); if ( data ) { data->Stamp( p, encoding ); location = data->Cursor(); } const char* const startTag = ""; if ( cdata || StringEqual( p, startTag, false, encoding ) ) { cdata = true; if ( !StringEqual( p, startTag, false, encoding ) ) { if ( document ) document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); return 0; } p += strlen( startTag ); // Keep all the white space, ignore the encoding, etc. while ( p && *p && !StringEqual( p, endTag, false, encoding ) ) { value += *p; ++p; } TIXML_STRING dummy; p = ReadText( p, &dummy, false, endTag, false, encoding ); return p; } else { bool ignoreWhite = true; const char* end = "<"; p = ReadText( p, &value, ignoreWhite, end, false, encoding ); if ( p && *p ) return p-1; // don't truncate the '<' return 0; } } #ifdef TIXML_USE_STL void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag ) { while ( in->good() ) { int c = in->get(); if ( c <= 0 ) { TiXmlDocument* document = GetDocument(); if ( document ) document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); return; } (*tag) += (char) c; if ( c == '>' ) { // All is well. return; } } } #endif const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding ) { p = SkipWhiteSpace( p, _encoding ); // Find the beginning, find the end, and look for // the stuff in-between. TiXmlDocument* document = GetDocument(); if ( !p || !*p || !StringEqual( p, "SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); return 0; } if ( data ) { data->Stamp( p, _encoding ); location = data->Cursor(); } p += 5; version = ""; encoding = ""; standalone = ""; while ( p && *p ) { if ( *p == '>' ) { ++p; return p; } p = SkipWhiteSpace( p, _encoding ); if ( StringEqual( p, "version", true, _encoding ) ) { TiXmlAttribute attrib; p = attrib.Parse( p, data, _encoding ); version = attrib.Value(); } else if ( StringEqual( p, "encoding", true, _encoding ) ) { TiXmlAttribute attrib; p = attrib.Parse( p, data, _encoding ); encoding = attrib.Value(); } else if ( StringEqual( p, "standalone", true, _encoding ) ) { TiXmlAttribute attrib; p = attrib.Parse( p, data, _encoding ); standalone = attrib.Value(); } else { // Read over whatever it is. while( p && *p && *p != '>' && !IsWhiteSpace( *p ) ) ++p; } } return 0; } bool TiXmlText::Blank() const { for ( unsigned i=0; i Debug Win32 Release Win32 {A3A84737-5017-4577-B8A2-79429A25B8B6} StaticLibrary false MultiByte StaticLibrary false MultiByte <_ProjectFileVersion>10.0.30319.1 $(IncludePath) $(LibraryPath) $(IncludePath) $(LibraryPath) $(SolutionDir)$(Configuration)$(ProjectName)\ $(SolutionDir)$(Configuration)$(ProjectName)\ $(SolutionDir)$(Configuration)$(ProjectName)\ $(SolutionDir)$(Configuration)$(ProjectName)\ Disabled WIN32;_DEBUG;_LIB;TIXML_USE_STL;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug true Level4 true EditAndContinue _DEBUG;%(PreprocessorDefinitions) 0x0409 true true MaxSpeed OnlyExplicitInline WIN32;NDEBUG;_LIB;TIXML_USE_STL;%(PreprocessorDefinitions) true MultiThreaded true true Level3 true NDEBUG;%(PreprocessorDefinitions) 0x0409 true true %(PreprocessorDefinitions) %(PreprocessorDefinitions) %(PreprocessorDefinitions) %(PreprocessorDefinitions) %(PreprocessorDefinitions) %(PreprocessorDefinitions) %(PreprocessorDefinitions) %(PreprocessorDefinitions) tinyxml/tinyXmlTest.vcxproj000600 000765 000024 00000015553 11563634571 020200 0ustar00leethomasonstaff000000 000000  Debug Win32 Release Win32 {34719950-09E8-457E-BE23-8F1CE3A1F1F6} Application false MultiByte Application false MultiByte <_ProjectFileVersion>10.0.30319.1 true $(SolutionDir)$(Configuration)$(ProjectName)\ $(SolutionDir)$(Configuration)$(ProjectName)\ false $(IncludePath) $(LibraryPath) $(SolutionDir)$(Configuration)$(ProjectName)\ $(SolutionDir)$(Configuration)$(ProjectName)\ .\tinyXmlTest___Win32_Debug/tinyXmlTest.tlb Disabled WIN32;_DEBUG;_CONSOLE;TUNE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug true Level4 true EditAndContinue _DEBUG;%(PreprocessorDefinitions) 0x0409 %(AdditionalDependencies) true true Console false MachineX86 true .\tinyXmlTest___Win32_Release/tinyXmlTest.tlb MaxSpeed OnlyExplicitInline WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true MultiThreaded true true Level3 true NDEBUG;%(PreprocessorDefinitions) 0x0409 %(AdditionalDependencies) true Console false MachineX86 true %(PreprocessorDefinitions) %(PreprocessorDefinitions) {c406daec-0886-4771-8dea-9d7329b46cc1} false tinyxml/tinyXmlTestSTL.vcxproj000600 000765 000024 00000016066 11563634571 020563 0ustar00leethomasonstaff000000 000000  Debug Win32 Release Win32 {53ED5965-5BCA-47B5-9EB0-EDD20882F22F} Application false MultiByte Application false MultiByte <_ProjectFileVersion>10.0.30319.1 false false $(IncludePath) $(LibraryPath) $(IncludePath) $(LibraryPath) $(SolutionDir)$(Configuration)$(ProjectName)\ $(SolutionDir)$(Configuration)$(ProjectName)\ $(SolutionDir)$(Configuration)$(ProjectName)\ $(SolutionDir)$(Configuration)$(ProjectName)\ .\tinyXmlTestSTL___Win32_Debug/tinyXmlTestSTL.tlb Disabled WIN32;_DEBUG;_CONSOLE;TIXML_USE_STL;TUNE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug true Level4 true EditAndContinue _DEBUG;%(PreprocessorDefinitions) 0x0409 %(AdditionalDependencies) true true Console false MachineX86 true .\tinyXmlTestSTL___Win32_Release/tinyXmlTestSTL.tlb MaxSpeed OnlyExplicitInline WIN32;NDEBUG;_CONSOLE;TIXML_USE_STL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true MultiThreaded true Level3 true NDEBUG;%(PreprocessorDefinitions) 0x0409 %(AdditionalDependencies) true Console false MachineX86 true %(PreprocessorDefinitions) %(PreprocessorDefinitions) {a3a84737-5017-4577-b8a2-79429a25b8b6} false tinyxml/utf8test.gif000644 000765 000024 00000034734 11563634571 016546 0ustar00leethomasonstaff000000 000000 GIF89aņÕ’’įį’øNNhh’NNNכ›Ü§§|||§§§Ė||ģŠŠśńńŅhhh››’óįįńńńšŁŁŠŠ’öééå½½½½½ĆhhŠŠŠ³³³ŁŁŁéééįįįŁŁ’›››éĒĒį³³||’ĒĒĒNN’§§’³³’éé’ńń’½½’’ĒĒ’™’’’!ł,ņ’@—pH,Č¤rÉl:ŸŠØtJ­ZÆŲ¬vĖķzæą°xL.›Ļč“zĶn»ßšø|NÆŪļų¼~Ļļū’€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ”¢£¤„¦§Ø©Ŗ«¬­®Æ°±²³“µ¶·ø¹ŗ»¼½¾æĄĮĀĆÄÅĘĒČÉŹĖĢĶĪĻŠŃŅ‘•Õ.Ų^ŲŚÓŽßąĆC%"Õ)ŪÖlŻc.ļGėK%$$%DņņHåēŅ ® Įƒž€'$ĮLti—†b˜\`,‚"…E#"HŒ@BЍ‘8Q¢+ʜIS‘B’ä›XOŹ’ŒCŖ ]²@N!¬h˜1%“C&Ą$X³ŖÕ«uš°D½BčķĖ@=`'˜CKä£s0)$jØVCŃŚŠÕH<8Ś/>}(‚8ql”`!q{rń€J–ÜÄ¢ŒT±ŠMŒŚ˜J<:Ž ÉH\”ÄlEĒ’MRT Ē„.BŽCWHµ˜¹…(\§  #IHLöAbŗÉ ŻŽ³kw#)/QD”ˆ£„Ó«_ļ„@Ž&&ņQw!·DüŠŪö„ŗÉkŗę$z˜9ÖEciWBx@‚ū‘Ą“wEˆ—D|Ó)aVlģuč’įzī…†Ä]@į Ą·ßŠł%AqŽįS!s=Ąųé'„ŒmI؟Š*ŽwLČĆ&©äh§‰8#üŁ¢”?‘”ĘŻPUŗpPäØĶTV¹åvOXHfš‡Ž’pĘ)“V ‚Gd ųTęõXH‚ &ųč“‰‚ō0¤ ”ĘłČgI6f%¦Idƒ É©é¦Żō¦†¤‘^,Nia ˆ Ū€Pö”]6Ž®Ćjƒīyi…^R)b!jœ+¬47=YÄ]®Į6„™}ŽŖ\5”…”ā@S|Z įœHōIGŻ£\XŌÜ’Ä”„FL5’ģŗģB#"Eb±Ä³:–9ā¹.¤°Vfµƒ(>hÕYŲ—ˆ-k”„[.ėåaÆ¢[„“ķF,ńÄWlńÅg¬ńĘwģńĒ ‡,ņČ$—lņÉ(§¬ņŹ,·ģņĖ0Ē,óĢ4×lóĶ8cĢ 9÷ģsÄ ±ó!C?üóŃHR,EŅōź&-õŌ•xŖÄӃ`TŌTwķõ!tqĄ, p@Ó Œ]ö QĮ;+‚Š<Ńōΰ³., ĄŽE¼½7v³@Ž,šM÷Όń°_G.9M"”Ą!AŃ pį 0@Ū.\¾€ę ŠMÄŻ,4Š6e»īģ q’9į üMø {·] µ«®aēMnüńp„˜Ä٧.ÄŁ™k¼ Ģń4ė«×-ōϳм $.üöĪł¾Č§Æ>*“ļ¾ I(ŁEM’źÜßoÄõŚóŸ½śž’ʧ”ó­ļ€lĀūܧ„ŹķO{„ ļx¦5bÆ|dœ-Ų? ĮM ”±¶’™0€¼ĖŸ9ˆĮ žp…,$ ć25ĀŚP V‚Ž¢'¼źIÆv>BĮ Ę0ˆõ+b­Äµ:ń‰KXX €¶Q œčD×¶Ī  y!ØŪنČĵp€„†°€Ō¹ƒc<ä HĒ:’*ų[⦨½“‘Ķl¤{ÜĒó%.|K<#+ ĒÖ ńT[Ł”cĒJZņ’˜Ģ¤&7ÉÉNzņ“  „(GIŹRšņ”ØL„*WÉŹVŗņ•°Œ„,9VĮ«Į°ÜpVrŁ…ZŖ£KTh0µĄK.³8¦”yfrĀ™­P–|É“[Š&4ÜąŒ˜j¢čK<ü±onœY€¦Š9%óļ‚:õ0O"ŌÓ÷“D>?ᤤød‚Ł“¦øYM Uei2ĢA­'PAüäå‚9µŃ+ģ Ē‡ĻŽŹs˜~Ųē=/: ’j”C GŽ YĪDŚR ’M,H[؅‰špCN±`S,ģt &mBN4Ž‚ŌžGåƒH“ŠTdv"ؖ˜i[8ŌÓ'T•„LÜh4J˜ÄjpDP›ŁŒŲ4`±lhŽĪ¾*¾nqŠÓį /0·Āå p~ė·ĒĒDf5nj@ Š‚X€ @Ą1pX£¶€f\ Xa~ p€0°”ž5 ŗĀ םŃõ¦ht_ °»'lĘ1ŠmĮ†0‚Ķ !±‹m,> Mhfv³ Ėgšø¢Ī3°ƒ-¬n…šŪp ± ® ūX!lĄ¶B°€f[ą€å*3¹»uź’[€ŒT˜‚%’¬a[ē.w8&4„cBV²”5o .;Žö2Ö±éU®b;Ūģ ĶL*n7«[äŖw¹.H®ōėŌŽuĮī-‚„)L„ę>wš•/}†‘:ĮŸ7M"[ćś¼?ƒe=ėŅJ·#”øŽp C«ißMO—‹ŽČZ7ډ‹tė±jĢP%’.x.h@ōž\8ŁĮnVfņķ\;“öL\ŖoG…9āš¾³Ģcv.uń;ąŽJ· °{äļÖå)3™›MŪr—æ fge».ˆm> Ļ;ÓĀāmļ1ß|$ā}ŠŠFHs ʬha2Zµ“žLfę ³Ą•v®c’×^"„š©Žķ(šUm`"!ĶXs &Kč3×ŗŠ.ą“†°ŻAG:©c6tšĖ,ėx–ڱ©>&±Ó<„P×c&‚Ž‘•bµpNÖ2ę„0d—ĶČ.€’'˜m(ŠŃѐŸ[jAīQĻ{ØM$ւw=wļŲnöīj É÷īļ…ÅĮ¦Æ”]X^·‡f\p]…3\˜ø­Ć9č&0€Š@fA ć­Čīł»­V n( qƒ į Møx­ß…S\ŌQ@RŽ+šVG<ĀÆų" Ģ]» ¾=ĀvG®_ZŠ G¶Ä;ņc’ŗ/¹ŠĪĢĄnŚē nĮĀ®’õ‡|ź'ÆzĶ]@š›Swį(ĒśĢ“źŖ§|ģe_:š.ö•;³ķa©~ēiœwżå tÓ3€uu'į9Id7K'ŁoŽG°ō.b¾ sgžŽ|”¾!Y4,6`Ųüµ;.Ś4€lxV"Ep»•Ą€¬•ītfŖ:¬Č!`zŌ{[õ.@įU N_ÓB€½ģ­ņ¦ įöØ6¾hīz§Bå¦F/Ļg-Ll?šÓEƶsu:Sä“_{õ‡ üهŸ» AÓ_ĶŪś‹·żĢ6H >YżśśéD€uē|ļ7H{Rč×w×÷|=óļ”’ņ*µ4@Ā÷{Bąy 'zŽTyĪ0m¬GzXCdC I‡“o™W>C¦z©gBÕ8*fī¤NÅi®V{öwkĘöC&›Ó<-ų‚œēRo4ƒMÓgŗ“}»6t›Ęl<ø~fOPBØ~(iHi#P[GXĄi†h}G{f˜u؃V˜kõY8…QmNwlŪ×ä'fāņłG…i˜†|x€}Ē…nOp(‚D° #C%؁-Ę8z‹wKXH,%†yØ{d‚DĄ 7 ‚™HDƒåƒBZ†Ō%rx†¶}Q0!öF6„čˆĀƒŠZtĒ_’ļNJ‚ØŠ°Č8FŲW‡ÆxŒH°} Yōe^Yxč€ÓųQåĒTē‡ƒĘH€«8rĪЌR§†®Ø€ŸęoG…. Ūaų‹čXaŚų~[8ŻxlŌōĆŽāųuwt‰F +8Iø‰ø(žŠ¢ˆ)Zå. ń)|;äxodn)“$|“hBH”Šóh_.€rāÕ|}§_0xjēp ehŌ4T4©\giŽÅ!)ˆŌÕX\·t'yuL@T7xŒih’(™ŠE]8Łp„~~gtlf~G%“֓ä8ˆŻ—“ …¾–‡ŪXŽņX]"y†N'’ā÷•’į…“c‰Œ E•Ö•Œ—Cg}ćFV†Ņøƒ$ét§&|ŌZœÉež9>qTFy¦FlDšW°]ÜE§Ł†Īt|thĮ9" łŽéēL«Ł…Ē„uŗY`mON)•÷׀Wyl½Ł‡¶†–$y‚X‡ŗIkhɝéH€/G‡ĄéjāéT幃ÉlĆńab C >’y„BӖ o‚łÅ Ų4ƒū&zÄZœų‰Øg<”˜)Ö4p…HŸÉR’ŒÄ8 šH„9~W:ˆ†=8Š^ąœPp”HŹM†‰O3”;S”Z@p²„a·”uØź•wH*_"JyO@}ƹ£Ö£Dp‡Ī œF ]=ē]ؘTt\y^źØ_ŹL#t-€p‡©I„4š†­V]zˆX3ŚĪŌŅ„Ge£……£Īä„gš¦4š] Z`W*_[ZP#(Ł£xhD ƒs   š™E,p³”1҈`hą’w|¾˜›‘jYd€ ³‰*3Ÿ‡XŌZ‹š1w˜tg0f€“éŌQ§JŲĀ ›^Ę©Ø7c’Ŗ£_)YŠ^’W°«Ė‰£ep]pz;C«¶š¬Źŗ¬ĢŚ¬Īś¬Š­Ņ:­ŌZ­Öz­Ųš­QLŸĄiŽj@·„ÜZS ELÖp00® $MĖ Œ£ßćƧģä @X¹JšUXÆäjžŠ žz؎‡Vł5ż…ó®ńŚKåz$„Š˜Śs6u%Æė?• įŖŽJ[ó:; SO÷­ėˆ{5ƒRaa²Éė°Y`²z U‹7y¹0²•ą„l…L”•¢P{: CE³µ†Ŗw،?c³ĘAU’Ē‹Y³9ŠūfVĒJc³#cZė s³kW¶dcC`’_›=w%>yrB4H¬åW.Ąl)^ö_Ģ…„°jš„wż•[Ē9žo™TöfWfNg•ņśoz{˜%LŗõZ «į†qƒy¶…™b«ŖM¹`‰YŪõasK–Ф¤ÜåŽBś_\xOœ;CõN“£#yTˆki±ŗq8»YŖø‚ū¹Œ6ø>XO‰;§)ŗIEŗŻÕTmHvŪu¼J\É{‹„·_ÉLOZ¼Ėˤ{{iōQµ'¦°Ÿ‰FX‹V;3†™ek¹5&¶GPŒv€ˆ>¤9@ą&n<3æćÖ4R&Dw–8>f‘ŁSnCæK꒭ó:±cĄP¦g”Uƒg2”ļčž’Uˆ]ivsæ+l~R@jĻłNŅt¤zl\w1j—N•žE€r( g, g,@gLe“©‘ ,¹ŚŃĄĖŌ”¼hÄ–ļjN)œV˜ŗĆŲ•Hhńõ|XŖt!œŽõĮä©ĮļT`5ŁlnFÅšŌY„Ø~#<Å”›Ć€&…>œ&ü»ą'„}×^VüNŃiŖ'&ÅYm7æ¤gæõūcō;>/¼æ\čF—·‚¹3µ:@ó†U‘WPķęVųƒČży‘'’†`Ź·k ©É'uĢō}D@Éf øŗy—9sōH€Ÿ\küś~鈪4GĮNpq¤U:‡y¦D‘lQ8Ür.x’;¼ĖO¹tP™„#×? ¦U‚ĒōgšgsŹL„^Į„_“JŹŲyŹī‡Ėŗģw.WqKq#ē~EÉfGW‡¾<ĪY§ŹGeɹŒÉ°8€ēIĪįœÉ÷Ēy.œs9ƒ |…\Č£‡ŸųE4ņܧǺqāµe­Ó7Å{ĘjŠ˜Ų4 ķ{j?)ÉYœ€ÕĒ]ę O«Ź~±ēĶ„ØLI™ŒØŁ¤Č4ŅéØYP|ŗI‡O 7BWMƒüœ‹m˱+^Ō)iaI‡ č• ÓŖ žWųϐV {rˆŅ<œ~ĪēŌ„¦Ņ,MŅmHdłtTĶ]"ģjA­ĪĒųÕžX’J™Õļä}֍ÕÕ¢\€ćÖļŌŃ/1IP‰7Š Z7M{½Š½gÓ ś0H-īŪC-œ×'č{‘ųˆ{#‰ES„0ˆ„¾4@}ӂ©„ŚĆ„CI‡ˆƒÜ•t’ękżÓ®vLśUžæ‹Ć„vŚug–kyž?ÕM„CČmTd„œ˜AŠWĆ sĆ;lŲYŚ!ż‘ĆˆhšdŌV<Īw|ō„r¬ øYķXĻ–®ĶÖ֍”YWŻL,ÜL”ŲŻaR˜jŚĆvl¬ö·¤żN‡čĘE„ˆy؟‰‚‹M=ŠķŲuSŁ}nŹm\uSsĻ)ĘeŸČ%А^¢}‹jµ¶x¹’¤§‹M…÷8O/wā…rfwŽęMÜnjĆ˜Č uŽLŅxYo:œÖ8²H‹CŠą1üąCū£8 āD Ż^»•į8®…JTģė|ŪÉ6h‚ȳYWsXā7Ž4^Øäl}g™ćŃ=Ō|)£;€`=cYw™ÖuŌh€_w¦W¾½[q¹y’½ą Iąxą8­ąłćx`³h#:-|‡É={žx>ŸŒØ‘©%“üiL>— …ĪkIꩬ•O•Q©wv”BąĮČKkX>ŌeāL…ĀS°’-ł½Ś“bTč[Š„“ž—8įüź«.ĢĘI½enS Ó’`9k>~±eø—¾ėÓµé~÷“¹ęsxYģʙ…šģ% Ī‘~Œ°®ėLn©wēk‹~T>ā)[XMķ˜Žķ÷$Uõ1^”ēY?|Žī~žā4uė| ±D°9Æ<›’Y™Bp™¼£Ÿ÷Ο›¹Ā°*Ł·4@ÆÉ±ŁČµ)šmį8Ę,i#Ęšž­Čœ…ŪToćgtā||īŲ­Y¶žNšFDļ›œķÉį=ÜQ?üÉŲ]Ž0õŸ@jÄJkzxńN{É ÄÉ+Ī<^źĘŃĶ󋅔ÆrŁ)i‡u€Ÿ›ĘEŸŚČĒĒš ņÉRņŽ=dTļśīųnļ\Ļļu3š’ŸZHūīĆ) ”.€ {=lOHt¢ÆČqßŲł½¢ä¢:żŽp RwŹ`Ą]ŗdZX_JÜj7ŗuŗs’Q‡ń„Fa/½ÉS$ZrßBi÷j”UąÓ:šų]LĢĘkŗ±å†kÜK ±L0ó»ÕųaI^Ƚv®݈ϣŸoū²ģŚž~£ÆūŁu½Iłgų÷Fƾv€å ž½ųĢE{ЉÜ=‡T4oÆ š3Øm_÷Ó?÷ķ­›ūLC| *{2˜Ŗ­ƒpÆcmźå«˜PžÆ’%ÓŖč/į®c73ņO2Ä .įX4‘Iå’Łt>”Qé”Zµ^±’Yķ–Ūõ~Įań˜\6ŸŃiõšŻvæįqłœ^·ßńyżžß÷’ !#%')+-/13579;=?ACEGIKMOQS™XX\^Zhēh[øde¹XĶta›n愭~¹ˆń³”™Įœ‰ˆ”ųz1ˆ(X$ʰ•Č ¬Ńgk妩ŌÕy[Ėą­ƒŁ»Üź‰“­ōįT¢Lą”‚XōIĆ×Ē‘ L įę8qbĢ!ÉX¤a"칐P‚ ꅣhd„”\¼\‡«ŻB,2eŹ3ƒę=šłlJįI„@€ŽQ²Ijd©¢¦ažĘł’rČ'L’4‰r\Ź$-…=:hź"X0(r XBC}Ś jī·\ź.‰Źd.&ˆŅ·L_Ā„oIœ¦ģ‘jCŠŖ%ĀĪŻĄF } ą„×Ī xSpх“,.„ Ā 4+«S‚hĄj€BXp]ŽEkƇ˜f•6Żæ],@‰œH…ÓJByšĄÅō"ŠB°aˆ»[hQĄB Ł[8(‡“øOėCwZó[l·+üOģŚ¹Ā:ė@):*B8ŌT‚sĢqε螐:"žĖ/@¦A€–†A;!šP»õ8“鳚lAČ*]$ĀXļ»%»|²E"6Ąą 4@‚™%ˤ‰9»¼Å½1ƒ$¢Ä[ڤÓNZš4B3ĪŽx("Ü<+"7ŃH[8{;8J‡6Ū(õķSmd0;b6$묁’0Pˆ.Ŗ€Ź\pM-]yÅ„]…€`6JauŲÆ~ū•Ų[s}¶WPkŲŖuaX^€V[…xEÜqQĀÄ)ōnŹ)óā\D]\ńn‰ÆJzoé`Čń’ˆy—0™¶!tZ‚„}Š+rŗż– É%— [Hw.2Ń]Z2Ų—Ż}‰ żš}ā#Ģ y݊ANbeķšż±å–_¦„](ĘGd—WFsŠ-~łf y^yŽ)ķ%Hēž«\yh£‡°ąe=ŹŁĻŖ”ŽOޘķmś–v„fZˆU[E¢„«†x5VK©u8:\¶YežgŪb6Łe‘89å=xąF‰–£ö€Ū8%b¤SÕĮψ2!×hįŹ;kÜqÜ*?€Ä] €9+ŹŌ—Õm”cĀ.€Ä1](³ė|]Ų€vŪĒŪ7Ą2…¤}ˆŅ]8=?(HŠ”’ÖÖ\aŲ„štŃŸxįGöłz#ׅp ĄŠüvŁ÷Õw izŌ/.æöŪ·ŸŁē[Vożõü²÷™üŲaÓJdÖ7¼*Õ/~üké4ę?}įī€ļĖõōĒØģu zō‚ż hÆż}GpÕ~R&ä/|÷Ó`’ąG‹ŠŽųŲĮAŒ}0,‚c ØBĀ5ąpĢĀāŽ°¼ĒEĪ3“»ÜŠG<npŠ«€–3 lĪq8@(’iq³iĄ¦čC*²MŒVÄ"+ø(Ęi Įd¼BĢØĮ"(&ŲBXˆ =ʐH|“’ ąŲŻąęSfĢ’¢ņ66Ŗ‘ ōc4`3/IRŠb63;jļ}Iāyµ?Ī{eš HŒMśl“x| ’P ȚÉO•³į~p™Jv¬2—-keé倌 °Ā*K(K#Ż1„tęO,‰É8s˜Åt—ą”ĄxbƘlš[£ć¼F7ŽŃQéėٚhĻ]`Œ½X@E$0E!nŽŻ@£Ā™Hfłšž£Ńg͉ 4.”—^l™:Tұ—¦¤å#ćµ®(ÜS#A\AóyN‘n‘R mØCwQ4¦¹Ć•DOž265ėQTŽNš[FćČ£ŸXT—§Ģ%M’ijĢ™Õ̧4³„Py Ō¹(õģˆé”VĒ”gNtŖ­ŖĻžŖQŒ­,Ŗ€aUĻ©$̳ž­éAŠPųÓ5ed?€2@<Ź õ ēXķs¤ža€tCO‘vēŌ+"ՈEv^·t¬/ļcīĶ“ŖČh©ü”‰…„ ˜;,?ÕjŲJe”±B=Ā¢Āv&zs~ų@f'Ū‡„• ”Ó©U‹ŚŚ¦Ö±¼]ę&+ÕŻÖv”õķxŖ[TņҸnj,p‡ |=Įeiś“×N6¹µlk-;Żź:ź%b% HŠ»Z*ÆiAģ{‡š×ĄRq%³§3’^ŗZT¼'[HJ_„ī·W• p:X¾Ųy^(`JC‰ęrū£ģN1%Ķ&ްpp¤Us‹=gƒ»ąįJ8¶ ü×~8ąµĀ°KŹe§āb–”ö±s[°6×>²×3hĀ¢m€\1‘uģĮ¢įČB&†Š)åńĮ«s„u{id! ¹É2KņP+Ū÷ĖĖ,äHžęls-F(^üK¬ļyĘ«€‹€cDLÅAdN"EJ]DP€‚X00Ģ&“Bl›Bš9@[·ŗ‘4„I¬¹nL Ą3rĘć^ZogTĪ®¼V½1±’=A N¤]0é}zNŅĒĀØ‡`ź,¤ŗ¦E@Ozˆą£•b ÖŖ>‚`Ģ%ÓŪ¢™&‘Œho+ʟe ‹†2ˆTb#µŖÖ–i —=\YO©z^£¤p‡ĄmC°ÕŌĪ„²µ*4%Z&€y{ehDw+ Œv4¤?½`„^Ś™F܁ÆIŪAK$”fŠ^wåģ×S¢«4BKā…%GĒ®Ę ģp`YXӝ@Tl"_=srµn}ĤXŖé\ˆy. Ų[’ĘćęōŃ#Är-¼œQ1HŲ¾«¤ķ=³€Śł¾ĄōųÜŁöž™”WęXT—Tó.”’?ČžSĻŽķØĮ}Ź^÷RŲĒĪsµ+جS;Fąm tµĒD0»vØ.G«Ē2¹e*@ā'Ā÷mHo(Pq4¦ćžÜ8PžńʅÜ5$O°ī;‰»Ø‚õ­wżėaŸ‡Š9 «½]F{{Żļž÷½÷żüēŗęž÷X°}ń‘Ÿ|å/(ŽĻ|éOŸśÕ·žõ±Ÿ}ķoŸūŻ÷ž÷Į~ńŸüå7’łŃŸ~õƟżķw’ūįł+¦ø<óD‘[„`xHž#ź@ō=¤ ¶Ŗ€ØpžPĄ¢³¢Įž UĮØ)ōOqĻ`!„ģCkźīb, œ©’¤’jEpłžOøāh‹ Ć "¬ ś 0ó #&āĀĮœ.pst„åkųŠ€BģB@2Ą¢;üO«<ĘŁ { ¤łČS„Æ)Ø"õJš Y0 KŠŻ PÅP Ѱ}jįØž° ™`,$E"ŲŹ"xP öéėP½üŖ+āŁ)ĖĄ mõ@⇓B$øāO­Šā­ōĄŃ-o’ųLį/Ęp 0ń ”p ž 3± 0&`"'ĀBāĀÄ ‹ õołĻ ­  ų¬+DāO"“¦—Ą"q4L‚‰ļ±Ś’±oąģ,Ük2Č %”QŒ`„NæQ÷B1(l… gŠńā{b½ńšļ M±‚{Ģ›J m«³p źŪPŠIń” æŠą] 2ź¬+8mć åiß@К®6#sŠRŒc7”c7840彊Š$ä7(d­4īčōKÓ,ĒTÄ(70r>:B…ŅjtZ2$Ł%ƒć46…"=%9–ƒqf2 ,—öH„f-FŒ²@lĶäŃJ'“Tī9h’ ‚Rkźoٰ*QEæšjV±+AčÜšÆRpÉpÉ+"#"„±Æ*9.rt¦E#ń’‰#Ź#„r2F²ŸLĮl““`öRDÆH…0'äģė!į Ōę §%[®…2ėfVr \öéĄ&3“²[ £Įö¦n8„4¹Å[<³$īF)ó¦3k%);5Ó&ZäĘ2±ÅZ¤6Į%Pźł|Āe1 aH nčFnBķxT36!ę7O0ÓŃ+ŃŠ¦āJųĪŠ,­R,cE,U-WP;©ą1“ąltŃ"Ó)7-ó6Ż*79ć“9C3%Ņrh“ö“>WS[žÅXę7eóĶä*±) txtś*±0Ē€čA7 ÅB9,”B%³Ąą‹Cן/”’‡°ŲĀBC”=9G2!īĻ>ōyčR žB8 x˜yL4åVT"Zt0†Ņ;sŠ;Mʝd‘<ĶP !ūŃĒvK-³Ó+aŌT phv؇:”rĢiB73ĮHC’RCMŌC½TE·ō5$ēF… DūHēļI“Ą› ˆ6Üj>½ōœ²Ō‡Llī”Æ$R>L‘īŖŅ)ŒŲčO7”ČÉF'Oɑł±š¬`z„®čųT“ ‹ ʓ:IIµ”(½s8—jٰµB yŌćŃGŁ”1iωŽÆā“OS’P54ĄÕr•!ł,Ōr5P‰`WÓT‰āĻ<›€¬ĀōōÄ’iź”ˆLŖ–2FsOo5Įž؊č¦åY uĪ*Y}čZSā73,SU©€£<ŖŌš ­*Õ®ø5\ óYń+×ńÆ3 ‹ņ łµ^7•ļQSuė ŒÕĀj Qēt½Ž•Yƕ°D3yK­L\›'‹j[MŹtéźĮµC=“Y5÷¢µyŗŌä,6ĮīŌĪ 5tuQ}u4V±hvńń+Ó²T›`³:k>«Zķ4guŌ_’Õg• 1y¢Ø£†“`Ÿ¶HõQI|XdņZęŲ®¶²'“  ›ŹŪ¼;‰¤Ó»ņbJ•Š“Ę;GoWĒéöČÜn‚ÜS_œZU"gƒBb:/%Z-ńĄų¼j .ė„:čŚ8¾ćKwßĪÓCĪ«¤L„G”fģ€ <ßŲP½ʆƏ aē5ōżsśż©¾(>¦> nŖŽ¢¼†2ąœwŻ-ēžŗ”ģ“Źžą7mh7b$¬;TśKķ’yZĪg‡AīV+{ŗ«Ŗ°k ¬ÓŁŗh…ŻļĒ<—Q‹>ˆ ¼ –¦ö ˜ö\ģVµcĀĒGźĆ»`ńĆŪĪęTūøöRĻ¢ėæ~“:ÄŽAÉŽĄøhīG«ń±ŽāķµA'CĘöAåō9压x/Vq‰ˆy€½Æ~q}sÕMP¢<ęy*ŹhH5ēp’¾ĖÃWYų{ˆ°ĄÅXf_b,Ķ­‡^¬Œ Ÿ š 6`³£ i²ė˜øēʜlĒ Āž,Ö2ą“Ł›¼&®”K(‰,V² \ÄKJ¬øØÖ!Öµt-–Ūetų5³Ź^frBš’ņ9½næćóś=æļ’ ö $Ń± $1 X…0=FM¢ …U”5(±­yf.‚® °`14œ@p±ˆ*VÄŗ Ŗ²‚*šv~) €-ˆ ¶'· }(;/)IG#!<[ėķī kŹ–*r³U¾B@2øTJŠ»O±„9(;$5gCS»hčkcĖvēM>4Ц Ć4küBsš‘‰Ī’i«V@C„B‡ˆ˜ąAĪ.’ˆ°»D R»Q›¬,)6®ÖØ!ēįĢ©s'Ļž>ā,XsĪ…r\Xb@Ā”¤,–Ö|¹F]Ķ%TyĶ!GÕS gB( cĶ’4’ņN)õŖėš«»*„ŁÅXF~ ŽČĄoÆĀŒ&bĮ§,į²WāĘź¢uØ"0:p5‹Sؾ>•½0—e‚“Üm‘—ŚC„¢Dxųwįē:B’d@ŠšÄjkY},pŻ-x殘AP$²–’Sōhe¦C*u®HŖÕĖS­Ŗ};÷īŽæƒwĀ‚BųņęĻ£÷S2=ūöīßó9qĈńšļćĻÆ?ŠG ų €X X Ö’|ų‡ ƒB” Øl!”…b˜”†€n¢ˆ#’X¢‰'¢˜¢Š+²Ų¢‹/Ā£Œ3ŅX£7☣Ž;ņŲ£?’¤CY¤‘G"™¤’K2٤“O²—ÜRʘ•‹šŲW5süsQ}y›`āŌ%™P¢™fŽWzŃ›ŚńfVƒąałŻy甉“IŠ‚äé!!j§ }héĀ™‰**fgʁL—\ Di˜Žž"bÉg멪Ø;½ĘKaė±qŖœ‰ØŹŖŖ§ņA"²ęG+­{šĮ)Ižę묛Bh ¶›]‰.£šé喍>źh]˜nłO“ĶBŚD©.L€ ¬’EŲ®k&Ƕ£¢›n†릻øīA„8y¬šDøpo~śź§®½ŗłj½Mš‹ļ ŁöQp7݁’,¦Ų†‰Ē²Šb¤,µt L»r<Ą ž ² «[²ÉI°»ą®ó~Śjœņ¾ o ćGó§óŠsŸ;ļa3]'ŒoæDøĘŲ>Ä(¤C+©µ¶5 tŕuˆŹIh:'ˤĄŚDŃēž6”†0RĄ¹n}³ĪgȦĄ<š€ qCA `h! 7D䓀 vóAŌÓA7Ż-óóĪ_ˆŪ‡ćrKtLk##› šķ7³ĮNā3>Äåsxp/Ų[ś,őNJūģ²_‹{Ä·Cōōd›-G·ßŽĀDŚ ³ŁŗŃb3ļä",Ƶ®Vrņž ś+’GŪsčŃśhŠ»2įŪö  )#ų5٤ļÖRŽ#¹ Żwo‡^ŠWtĢpĢ:C>_·ńĆ"Ēhßŗ ‚«ÉĪ!k„¤å@Ż‘ÉKɂ!ž½9”Ąc|ŅEČ 3½;ā€Ķ!’š°Å,U"ć`äüŌ‡ķAūėŒhˆą€ŌuąpĮ”±ĆÖšsĒŲ!:7ž±šOk)×<Š×‘ŌŃ7Bh1Z#4D4b!Š. MwS³]“ŹG‘ņMP°cZLˆB" ]Sįœ>ŲB”y‘„z’ńĄ²+•Ė0Ų× aĆiE„ĄśśrEÜ4ņŒŪ@¢õ&'’æ@ų£įĖ$ł\ HFJŠ‘B$µä# ć*[YF3å.jcĀāµ`™FŖ”všĄ|$GG’ˆKrB„÷hLYšŌS[[&°7½‰~Ük"‡p?Ŗż7µ;¢S(?inļP¼Gā:ā‚kž1›Śō]EXF3.4¦T Ń(KŽ‘.‚Ōbć’Y‡ ƃncęļ ˆĄc"TGĄŁŚ¦×5ä4trϬÜĻFéō #ź,]éŠGˆ÷5ÓeóĄĄ1hh8RjN£V̧5<śå½Njė|–°ōIF+:Ši¬Ä©)‰sƀĀń8ćŹY Ś˜&4©?JŁ%=ø²Č’Õ ŁŪIҬČTń‘PŪjh0`ΠІ›s é%De“OWĶźV/ZŅ!œu]żjXėš5;šS•¬¼eO)¶R‰ žzåk_µe5”õ’ØäĀ’ń.yW„BÖGėąP.c%z1“¬Ć"4ņMQ¶U€yķę—HŃy$®uõl:µ‘I}ä—s Łīų0±zŗ²•·mą„ngSÜŗę#C P”ZŁāɏ¶‘]īŽ^“6TQ֏™Uģ<Ŗ‘ŠŒ“U `ZÆĮLg†Ä [ą]!ŠęšmķŽPĆ]րp–ˆ¢%^ųNŠd«°zp÷ś»\ ՗„äÕeQĘÜ )’Uņ¤Q)Ņ€·DælhŃf#¤½3·±³ē-c)ŪcĮ¶–!ŽOb=*ģ=Į*NšŠ I¹`¶xC "hŒklćć˜CŽĖ1{ģć9ČB2‘‹lä##9ÉJ^2“›ģä'C9ŹRž2•«lå+c9ĖZf‘4 āexaݘ-£9ĶLrī2ĖóĘõÉž³Ķžąj]Žāy¾œĶ_œń‡‡m ;pņĪ›ÕlčC»Yø•¤v”Ū’2Ņc<{H™ö68’–“&›„Ž}lŃʉ£mźSk‡©>®w+‡fÖS»źąōĖ[1W“-ˆõ®ƒK€ƒĪÆX%’a“v\źc#{ &ŪøP™WœĀ)8ĖĀm°ą?.‹s$m9 µ ŃŪø§¦¾ņŠétŠKk„@§ŒdĄ‰[éźÖr—Ū\?„C ż–goEŚŌŽ6 ®żm‚wūąIw²īš<ųӅÖĘ+`ķ!4Ą9“‹ źÓZ|# g™D…PfŠK“””$͈hSb¤¹<#œ†8ōޘĮP‹śØųÅ]qXpÜć°y“A©‘`š§±(xĆ0xĀ-¬C.4¶\VōŸM\ĘŅśPĶŹIk‰éÉӞ‚§³ Ų‚ĆģįBIx!“¹IŗJįŖ›…\”EtW€Z(ĒŠĮrhK°č“˜ųpČśŠFh8łŒĒ€¢\ EW¬Ē0"Qø`”b+ŗāŌĒó‰|a{Äā+āb.Bƒ Ɍµ/źb0 £€H ķzć0*ć22c3:ć3Bc4Jć4Rc5Zć5bc6jć’6rc7zć7‚#‹œ™†c9šc‹š· žƒ¬+žć;j#ŖŽ…"‚¬‡Āc>Z£ bM1±š€Š źć@J£üy:Nd €‚c(¤d$A8…œÅb¬ "ÄEķ9›RčįP@F†‹ģ¹€äI.£÷}=nŪ$\9@Į9¤CµY‚ H@8 XLØC} @ģ¤åéĻ}į€:lœ é›ū”äRębźM ° !/PsŲ$PF%vĢÄŖ1 JŻS0FąŪdS’„+:åQ%ҟ•4‚ZbåZhå¶™E†eģ^YāåŖd€_ĪUį 1\¾åHVł]SōåebF”AÕŖ­åŗ€[ę`^†dNę?–ä*ęfJ!?A-ĪUJ%' ·ETvf%e^%e¦@rfl¾Š„śe›:P®$ČäØCJø&dA*¬Wø&VŠ!ą¤uPĮfōįŹftĀ_qTą@ĄFz!J-ŗg|ʧNųā|Śē}öA‡ąē~ņgśēh€ č€hč"h‚*č‚2hƒ:čƒBh„Jč„Rh…Zč…bh†jč†rh‡z臂hˆŠčˆ’h‰šč‰¢č†;tinyxml/utf8test.xml000644 000765 000024 00000001262 11563634571 016567 0ustar00leethomasonstaff000000 000000  The world has many languages ŠœŠøŃ€ имеет много ŃŠ·Ń‹ŠŗŠ¾Š² el mundo tiene muchos idiomas äø–ē•Œęœ‰å¾ˆå¤ščÆ­čØ€ <Русский название="name" Ń†ŠµŠ½Š½Š¾ŃŃ‚ŃŒ="value"><имеет> <汉语 名字="name" 价值="value">äø–ē•Œęœ‰å¾ˆå¤ščÆ­čØ€ "Mëtæl!" <Ƥ>Umlaut Element tinyxml/utf8testverify.xml000644 000765 000024 00000001264 11563634571 020016 0ustar00leethomasonstaff000000 000000  The world has many languages ŠœŠøŃ€ имеет много ŃŠ·Ń‹ŠŗŠ¾Š² el mundo tiene muchos idiomas äø–ē•Œęœ‰å¾ˆå¤ščÆ­čØ€ <Русский название="name" Ń†ŠµŠ½Š½Š¾ŃŃ‚ŃŒ="value"><имеет> <汉语 名字="name" 价值="value">äø–ē•Œęœ‰å¾ˆå¤ščÆ­čØ€ "MĆ«tƦl!" <Ƥ>Umlaut Element tinyxml/xmltest.cpp000644 000765 000024 00000122102 11563634571 016460 0ustar00leethomasonstaff000000 000000 /* Test program for TinyXML. */ #ifdef TIXML_USE_STL #include #include using namespace std; #else #include #endif #if defined( WIN32 ) && defined( TUNE ) #include _CrtMemState startMemState; _CrtMemState endMemState; #endif #include "tinyxml.h" bool XmlTest (const char* testString, const char* expected, const char* found, bool noEcho = false); bool XmlTest( const char* testString, int expected, int found, bool noEcho = false ); static int gPass = 0; static int gFail = 0; bool XmlTest (const char* testString, const char* expected, const char* found, bool noEcho ) { bool pass = !strcmp( expected, found ); if ( pass ) printf ("[pass]"); else printf ("[fail]"); if ( noEcho ) printf (" %s\n", testString); else printf (" %s [%s][%s]\n", testString, expected, found); if ( pass ) ++gPass; else ++gFail; return pass; } bool XmlTest( const char* testString, int expected, int found, bool noEcho ) { bool pass = ( expected == found ); if ( pass ) printf ("[pass]"); else printf ("[fail]"); if ( noEcho ) printf (" %s\n", testString); else printf (" %s [%d][%d]\n", testString, expected, found); if ( pass ) ++gPass; else ++gFail; return pass; } void NullLineEndings( char* p ) { while( p && *p ) { if ( *p == '\n' || *p == '\r' ) { *p = 0; return; } ++p; } } // // This file demonstrates some basic functionality of TinyXml. // Note that the example is very contrived. It presumes you know // what is in the XML file. But it does test the basic operations, // and show how to add and remove nodes. // int main() { // // We start with the 'demoStart' todo list. Process it. And // should hopefully end up with the todo list as illustrated. // const char* demoStart = "\n" "" "\n" "\n" " Go to the Toy store!" " Do bills " " Look for Evil Dinosaurs! " ""; { #ifdef TIXML_USE_STL // What the todo list should look like after processing. // In stream (no formatting) representation. const char* demoEnd = "" "" "" "" "Go to the" "Toy store!" "" "" "Talk to:" "" "" "" "" "" "" "Do bills" "" ""; #endif // The example parses from the character string (above): #if defined( WIN32 ) && defined( TUNE ) _CrtMemCheckpoint( &startMemState ); #endif { // Write to a file and read it back, to check file I/O. TiXmlDocument doc( "demotest.xml" ); doc.Parse( demoStart ); if ( doc.Error() ) { printf( "Error in %s: %s\n", doc.Value(), doc.ErrorDesc() ); exit( 1 ); } doc.SaveFile(); } TiXmlDocument doc( "demotest.xml" ); bool loadOkay = doc.LoadFile(); if ( !loadOkay ) { printf( "Could not load test file 'demotest.xml'. Error='%s'. Exiting.\n", doc.ErrorDesc() ); exit( 1 ); } printf( "** Demo doc read from disk: ** \n\n" ); printf( "** Printing via doc.Print **\n" ); doc.Print( stdout ); { printf( "** Printing via TiXmlPrinter **\n" ); TiXmlPrinter printer; doc.Accept( &printer ); fprintf( stdout, "%s", printer.CStr() ); } #ifdef TIXML_USE_STL { printf( "** Printing via operator<< **\n" ); std::cout << doc; } #endif TiXmlNode* node = 0; TiXmlElement* todoElement = 0; TiXmlElement* itemElement = 0; // -------------------------------------------------------- // An example of changing existing attributes, and removing // an element from the document. // -------------------------------------------------------- // Get the "ToDo" element. // It is a child of the document, and can be selected by name. node = doc.FirstChild( "ToDo" ); assert( node ); todoElement = node->ToElement(); assert( todoElement ); // Going to the toy store is now our second priority... // So set the "priority" attribute of the first item in the list. node = todoElement->FirstChildElement(); // This skips the "PDA" comment. assert( node ); itemElement = node->ToElement(); assert( itemElement ); itemElement->SetAttribute( "priority", 2 ); // Change the distance to "doing bills" from // "none" to "here". It's the next sibling element. itemElement = itemElement->NextSiblingElement(); assert( itemElement ); itemElement->SetAttribute( "distance", "here" ); // Remove the "Look for Evil Dinosaurs!" item. // It is 1 more sibling away. We ask the parent to remove // a particular child. itemElement = itemElement->NextSiblingElement(); todoElement->RemoveChild( itemElement ); itemElement = 0; // -------------------------------------------------------- // What follows is an example of created elements and text // nodes and adding them to the document. // -------------------------------------------------------- // Add some meetings. TiXmlElement item( "Item" ); item.SetAttribute( "priority", "1" ); item.SetAttribute( "distance", "far" ); TiXmlText text( "Talk to:" ); TiXmlElement meeting1( "Meeting" ); meeting1.SetAttribute( "where", "School" ); TiXmlElement meeting2( "Meeting" ); meeting2.SetAttribute( "where", "Lunch" ); TiXmlElement attendee1( "Attendee" ); attendee1.SetAttribute( "name", "Marple" ); attendee1.SetAttribute( "position", "teacher" ); TiXmlElement attendee2( "Attendee" ); attendee2.SetAttribute( "name", "Voel" ); attendee2.SetAttribute( "position", "counselor" ); // Assemble the nodes we've created: meeting1.InsertEndChild( attendee1 ); meeting1.InsertEndChild( attendee2 ); item.InsertEndChild( text ); item.InsertEndChild( meeting1 ); item.InsertEndChild( meeting2 ); // And add the node to the existing list after the first child. node = todoElement->FirstChild( "Item" ); assert( node ); itemElement = node->ToElement(); assert( itemElement ); todoElement->InsertAfterChild( itemElement, item ); printf( "\n** Demo doc processed: ** \n\n" ); doc.Print( stdout ); #ifdef TIXML_USE_STL printf( "** Demo doc processed to stream: ** \n\n" ); cout << doc << endl << endl; #endif // -------------------------------------------------------- // Different tests...do we have what we expect? // -------------------------------------------------------- int count = 0; TiXmlElement* element; ////////////////////////////////////////////////////// #ifdef TIXML_USE_STL cout << "** Basic structure. **\n"; ostringstream outputStream( ostringstream::out ); outputStream << doc; XmlTest( "Output stream correct.", string( demoEnd ).c_str(), outputStream.str().c_str(), true ); #endif node = doc.RootElement(); assert( node ); XmlTest( "Root element exists.", true, ( node != 0 && node->ToElement() ) ); XmlTest ( "Root element value is 'ToDo'.", "ToDo", node->Value()); node = node->FirstChild(); XmlTest( "First child exists & is a comment.", true, ( node != 0 && node->ToComment() ) ); node = node->NextSibling(); XmlTest( "Sibling element exists & is an element.", true, ( node != 0 && node->ToElement() ) ); XmlTest ( "Value is 'Item'.", "Item", node->Value() ); node = node->FirstChild(); XmlTest ( "First child exists.", true, ( node != 0 && node->ToText() ) ); XmlTest ( "Value is 'Go to the'.", "Go to the", node->Value() ); ////////////////////////////////////////////////////// printf ("\n** Iterators. **\n"); // Walk all the top level nodes of the document. count = 0; for( node = doc.FirstChild(); node; node = node->NextSibling() ) { count++; } XmlTest( "Top level nodes, using First / Next.", 3, count ); count = 0; for( node = doc.LastChild(); node; node = node->PreviousSibling() ) { count++; } XmlTest( "Top level nodes, using Last / Previous.", 3, count ); // Walk all the top level nodes of the document, // using a different syntax. count = 0; for( node = doc.IterateChildren( 0 ); node; node = doc.IterateChildren( node ) ) { count++; } XmlTest( "Top level nodes, using IterateChildren.", 3, count ); // Walk all the elements in a node. count = 0; for( element = todoElement->FirstChildElement(); element; element = element->NextSiblingElement() ) { count++; } XmlTest( "Children of the 'ToDo' element, using First / Next.", 3, count ); // Walk all the elements in a node by value. count = 0; for( node = todoElement->FirstChild( "Item" ); node; node = node->NextSibling( "Item" ) ) { count++; } XmlTest( "'Item' children of the 'ToDo' element, using First/Next.", 3, count ); count = 0; for( node = todoElement->LastChild( "Item" ); node; node = node->PreviousSibling( "Item" ) ) { count++; } XmlTest( "'Item' children of the 'ToDo' element, using Last/Previous.", 3, count ); #ifdef TIXML_USE_STL { cout << "\n** Parsing. **\n"; istringstream parse0( "" ); TiXmlElement element0( "default" ); parse0 >> element0; XmlTest ( "Element parsed, value is 'Element0'.", "Element0", element0.Value() ); XmlTest ( "Reads attribute 'attribute0=\"foo0\"'.", "foo0", element0.Attribute( "attribute0" )); XmlTest ( "Reads incorrectly formatted 'attribute1=noquotes'.", "noquotes", element0.Attribute( "attribute1" ) ); XmlTest ( "Read attribute with entity value '>'.", ">", element0.Attribute( "attribute2" ) ); } #endif { const char* error = "\n" "\n" " \n" ""; TiXmlDocument docTest; docTest.Parse( error ); XmlTest( "Error row", docTest.ErrorRow(), 3 ); XmlTest( "Error column", docTest.ErrorCol(), 17 ); //printf( "error=%d id='%s' row %d col%d\n", (int) doc.Error(), doc.ErrorDesc(), doc.ErrorRow()+1, doc.ErrorCol() + 1 ); } #ifdef TIXML_USE_STL { ////////////////////////////////////////////////////// cout << "\n** Streaming. **\n"; // Round trip check: stream in, then stream back out to verify. The stream // out has already been checked, above. We use the output istringstream inputStringStream( outputStream.str() ); TiXmlDocument document0; inputStringStream >> document0; ostringstream outputStream0( ostringstream::out ); outputStream0 << document0; XmlTest( "Stream round trip correct.", string( demoEnd ).c_str(), outputStream0.str().c_str(), true ); std::string str; str << document0; XmlTest( "String printing correct.", string( demoEnd ).c_str(), str.c_str(), true ); } #endif } { const char* str = ""; TiXmlDocument doc; doc.Parse( str ); TiXmlElement* ele = doc.FirstChildElement(); int iVal, result; double dVal; result = ele->QueryDoubleAttribute( "attr0", &dVal ); XmlTest( "Query attribute: int as double", result, TIXML_SUCCESS ); XmlTest( "Query attribute: int as double", (int)dVal, 1 ); result = ele->QueryDoubleAttribute( "attr1", &dVal ); XmlTest( "Query attribute: double as double", (int)dVal, 2 ); result = ele->QueryIntAttribute( "attr1", &iVal ); XmlTest( "Query attribute: double as int", result, TIXML_SUCCESS ); XmlTest( "Query attribute: double as int", iVal, 2 ); result = ele->QueryIntAttribute( "attr2", &iVal ); XmlTest( "Query attribute: not a number", result, TIXML_WRONG_TYPE ); result = ele->QueryIntAttribute( "bar", &iVal ); XmlTest( "Query attribute: does not exist", result, TIXML_NO_ATTRIBUTE ); } { const char* str = ""; TiXmlDocument doc; doc.Parse( str ); TiXmlElement* ele = doc.FirstChildElement(); int iVal; double dVal; ele->SetAttribute( "str", "strValue" ); ele->SetAttribute( "int", 1 ); ele->SetDoubleAttribute( "double", -1.0 ); const char* cStr = ele->Attribute( "str" ); ele->QueryIntAttribute( "int", &iVal ); ele->QueryDoubleAttribute( "double", &dVal ); XmlTest( "Attribute round trip. c-string.", "strValue", cStr ); XmlTest( "Attribute round trip. int.", 1, iVal ); XmlTest( "Attribute round trip. double.", -1, (int)dVal ); } { const char* str = "\t\t\n" ""; TiXmlDocument doc; doc.SetTabSize( 8 ); doc.Parse( str ); TiXmlHandle docHandle( &doc ); TiXmlHandle roomHandle = docHandle.FirstChildElement( "room" ); assert( docHandle.Node() ); assert( roomHandle.Element() ); TiXmlElement* room = roomHandle.Element(); assert( room ); TiXmlAttribute* doors = room->FirstAttribute(); assert( doors ); XmlTest( "Location tracking: Tab 8: room row", room->Row(), 1 ); XmlTest( "Location tracking: Tab 8: room col", room->Column(), 49 ); XmlTest( "Location tracking: Tab 8: doors row", doors->Row(), 1 ); XmlTest( "Location tracking: Tab 8: doors col", doors->Column(), 55 ); } { const char* str = "\t\t\n" " \n" " A great door!\n" "\t" ""; TiXmlDocument doc; doc.Parse( str ); TiXmlHandle docHandle( &doc ); TiXmlHandle roomHandle = docHandle.FirstChildElement( "room" ); TiXmlHandle commentHandle = docHandle.FirstChildElement( "room" ).FirstChild(); TiXmlHandle textHandle = docHandle.FirstChildElement( "room" ).ChildElement( "door", 0 ).FirstChild(); TiXmlHandle door0Handle = docHandle.FirstChildElement( "room" ).ChildElement( 0 ); TiXmlHandle door1Handle = docHandle.FirstChildElement( "room" ).ChildElement( 1 ); assert( docHandle.Node() ); assert( roomHandle.Element() ); assert( commentHandle.Node() ); assert( textHandle.Text() ); assert( door0Handle.Element() ); assert( door1Handle.Element() ); TiXmlDeclaration* declaration = doc.FirstChild()->ToDeclaration(); assert( declaration ); TiXmlElement* room = roomHandle.Element(); assert( room ); TiXmlAttribute* doors = room->FirstAttribute(); assert( doors ); TiXmlText* text = textHandle.Text(); TiXmlComment* comment = commentHandle.Node()->ToComment(); assert( comment ); TiXmlElement* door0 = door0Handle.Element(); TiXmlElement* door1 = door1Handle.Element(); XmlTest( "Location tracking: Declaration row", declaration->Row(), 1 ); XmlTest( "Location tracking: Declaration col", declaration->Column(), 5 ); XmlTest( "Location tracking: room row", room->Row(), 1 ); XmlTest( "Location tracking: room col", room->Column(), 45 ); XmlTest( "Location tracking: doors row", doors->Row(), 1 ); XmlTest( "Location tracking: doors col", doors->Column(), 51 ); XmlTest( "Location tracking: Comment row", comment->Row(), 2 ); XmlTest( "Location tracking: Comment col", comment->Column(), 3 ); XmlTest( "Location tracking: text row", text->Row(), 3 ); XmlTest( "Location tracking: text col", text->Column(), 24 ); XmlTest( "Location tracking: door0 row", door0->Row(), 3 ); XmlTest( "Location tracking: door0 col", door0->Column(), 5 ); XmlTest( "Location tracking: door1 row", door1->Row(), 4 ); XmlTest( "Location tracking: door1 col", door1->Column(), 5 ); } // -------------------------------------------------------- // UTF-8 testing. It is important to test: // 1. Making sure name, value, and text read correctly // 2. Row, Col functionality // 3. Correct output // -------------------------------------------------------- printf ("\n** UTF-8 **\n"); { TiXmlDocument doc( "utf8test.xml" ); doc.LoadFile(); if ( doc.Error() && doc.ErrorId() == TiXmlBase::TIXML_ERROR_OPENING_FILE ) { printf( "WARNING: File 'utf8test.xml' not found.\n" "(Are you running the test from the wrong directory?)\n" "Could not test UTF-8 functionality.\n" ); } else { TiXmlHandle docH( &doc ); // Get the attribute "value" from the "Russian" element and check it. TiXmlElement* element = docH.FirstChildElement( "document" ).FirstChildElement( "Russian" ).Element(); const unsigned char correctValue[] = { 0xd1U, 0x86U, 0xd0U, 0xb5U, 0xd0U, 0xbdU, 0xd0U, 0xbdU, 0xd0U, 0xbeU, 0xd1U, 0x81U, 0xd1U, 0x82U, 0xd1U, 0x8cU, 0 }; XmlTest( "UTF-8: Russian value.", (const char*)correctValue, element->Attribute( "value" ), true ); XmlTest( "UTF-8: Russian value row.", 4, element->Row() ); XmlTest( "UTF-8: Russian value column.", 5, element->Column() ); const unsigned char russianElementName[] = { 0xd0U, 0xa0U, 0xd1U, 0x83U, 0xd1U, 0x81U, 0xd1U, 0x81U, 0xd0U, 0xbaU, 0xd0U, 0xb8U, 0xd0U, 0xb9U, 0 }; const char russianText[] = "<\xD0\xB8\xD0\xBC\xD0\xB5\xD0\xB5\xD1\x82>"; TiXmlText* text = docH.FirstChildElement( "document" ).FirstChildElement( (const char*) russianElementName ).Child( 0 ).Text(); XmlTest( "UTF-8: Browsing russian element name.", russianText, text->Value(), true ); XmlTest( "UTF-8: Russian element name row.", 7, text->Row() ); XmlTest( "UTF-8: Russian element name column.", 47, text->Column() ); TiXmlDeclaration* dec = docH.Child( 0 ).Node()->ToDeclaration(); XmlTest( "UTF-8: Declaration column.", 1, dec->Column() ); XmlTest( "UTF-8: Document column.", 1, doc.Column() ); // Now try for a round trip. doc.SaveFile( "utf8testout.xml" ); // Check the round trip. char savedBuf[256]; char verifyBuf[256]; int okay = 1; FILE* saved = fopen( "utf8testout.xml", "r" ); FILE* verify = fopen( "utf8testverify.xml", "r" ); //bool firstLineBOM=true; if ( saved && verify ) { while ( fgets( verifyBuf, 256, verify ) ) { fgets( savedBuf, 256, saved ); NullLineEndings( verifyBuf ); NullLineEndings( savedBuf ); if ( /*!firstLineBOM && */ strcmp( verifyBuf, savedBuf ) ) { printf( "verify:%s<\n", verifyBuf ); printf( "saved :%s<\n", savedBuf ); okay = 0; break; } //firstLineBOM = false; } } if ( saved ) fclose( saved ); if ( verify ) fclose( verify ); XmlTest( "UTF-8: Verified multi-language round trip.", 1, okay ); // On most Western machines, this is an element that contains // the word "resume" with the correct accents, in a latin encoding. // It will be something else completely on non-wester machines, // which is why TinyXml is switching to UTF-8. const char latin[] = "r\x82sum\x82"; TiXmlDocument latinDoc; latinDoc.Parse( latin, 0, TIXML_ENCODING_LEGACY ); text = latinDoc.FirstChildElement()->FirstChild()->ToText(); XmlTest( "Legacy encoding: Verify text element.", "r\x82sum\x82", text->Value() ); } } ////////////////////// // Copy and assignment ////////////////////// printf ("\n** Copy and Assignment **\n"); { TiXmlElement element( "foo" ); element.Parse( "", 0, TIXML_ENCODING_UNKNOWN ); TiXmlElement elementCopy( element ); TiXmlElement elementAssign( "foo" ); elementAssign.Parse( "", 0, TIXML_ENCODING_UNKNOWN ); elementAssign = element; XmlTest( "Copy/Assign: element copy #1.", "element", elementCopy.Value() ); XmlTest( "Copy/Assign: element copy #2.", "value", elementCopy.Attribute( "name" ) ); XmlTest( "Copy/Assign: element assign #1.", "element", elementAssign.Value() ); XmlTest( "Copy/Assign: element assign #2.", "value", elementAssign.Attribute( "name" ) ); XmlTest( "Copy/Assign: element assign #3.", true, ( 0 == elementAssign.Attribute( "foo" )) ); TiXmlComment comment; comment.Parse( "", 0, TIXML_ENCODING_UNKNOWN ); TiXmlComment commentCopy( comment ); TiXmlComment commentAssign; commentAssign = commentCopy; XmlTest( "Copy/Assign: comment copy.", "comment", commentCopy.Value() ); XmlTest( "Copy/Assign: comment assign.", "comment", commentAssign.Value() ); TiXmlUnknown unknown; unknown.Parse( "<[unknown]>", 0, TIXML_ENCODING_UNKNOWN ); TiXmlUnknown unknownCopy( unknown ); TiXmlUnknown unknownAssign; unknownAssign.Parse( "incorrect", 0, TIXML_ENCODING_UNKNOWN ); unknownAssign = unknownCopy; XmlTest( "Copy/Assign: unknown copy.", "[unknown]", unknownCopy.Value() ); XmlTest( "Copy/Assign: unknown assign.", "[unknown]", unknownAssign.Value() ); TiXmlText text( "TextNode" ); TiXmlText textCopy( text ); TiXmlText textAssign( "incorrect" ); textAssign = text; XmlTest( "Copy/Assign: text copy.", "TextNode", textCopy.Value() ); XmlTest( "Copy/Assign: text assign.", "TextNode", textAssign.Value() ); TiXmlDeclaration dec; dec.Parse( "", 0, TIXML_ENCODING_UNKNOWN ); TiXmlDeclaration decCopy( dec ); TiXmlDeclaration decAssign; decAssign = dec; XmlTest( "Copy/Assign: declaration copy.", "UTF-8", decCopy.Encoding() ); XmlTest( "Copy/Assign: text assign.", "UTF-8", decAssign.Encoding() ); TiXmlDocument doc; elementCopy.InsertEndChild( textCopy ); doc.InsertEndChild( decAssign ); doc.InsertEndChild( elementCopy ); doc.InsertEndChild( unknownAssign ); TiXmlDocument docCopy( doc ); TiXmlDocument docAssign; docAssign = docCopy; #ifdef TIXML_USE_STL std::string original, copy, assign; original << doc; copy << docCopy; assign << docAssign; XmlTest( "Copy/Assign: document copy.", original.c_str(), copy.c_str(), true ); XmlTest( "Copy/Assign: document assign.", original.c_str(), assign.c_str(), true ); #endif } ////////////////////////////////////////////////////// #ifdef TIXML_USE_STL printf ("\n** Parsing, no Condense Whitespace **\n"); TiXmlBase::SetCondenseWhiteSpace( false ); { istringstream parse1( "This is \ntext" ); TiXmlElement text1( "text" ); parse1 >> text1; XmlTest ( "Condense white space OFF.", "This is \ntext", text1.FirstChild()->Value(), true ); } TiXmlBase::SetCondenseWhiteSpace( true ); #endif ////////////////////////////////////////////////////// // GetText(); { const char* str = "This is text"; TiXmlDocument doc; doc.Parse( str ); const TiXmlElement* element = doc.RootElement(); XmlTest( "GetText() normal use.", "This is text", element->GetText() ); str = "This is text"; doc.Clear(); doc.Parse( str ); element = doc.RootElement(); XmlTest( "GetText() contained element.", element->GetText() == 0, true ); str = "This is text"; doc.Clear(); TiXmlBase::SetCondenseWhiteSpace( false ); doc.Parse( str ); TiXmlBase::SetCondenseWhiteSpace( true ); element = doc.RootElement(); XmlTest( "GetText() partial.", "This is ", element->GetText() ); } ////////////////////////////////////////////////////// // CDATA { const char* str = "" " the rules!\n" "...since I make symbolic puns" "]]>" ""; TiXmlDocument doc; doc.Parse( str ); doc.Print(); XmlTest( "CDATA parse.", doc.FirstChildElement()->FirstChild()->Value(), "I am > the rules!\n...since I make symbolic puns", true ); #ifdef TIXML_USE_STL //cout << doc << '\n'; doc.Clear(); istringstream parse0( str ); parse0 >> doc; //cout << doc << '\n'; XmlTest( "CDATA stream.", doc.FirstChildElement()->FirstChild()->Value(), "I am > the rules!\n...since I make symbolic puns", true ); #endif TiXmlDocument doc1 = doc; //doc.Print(); XmlTest( "CDATA copy.", doc1.FirstChildElement()->FirstChild()->Value(), "I am > the rules!\n...since I make symbolic puns", true ); } { // [ 1482728 ] Wrong wide char parsing char buf[256]; buf[255] = 0; for( int i=0; i<255; ++i ) { buf[i] = (char)((i>=32) ? i : 32); } TIXML_STRING str( ""; TiXmlDocument doc; doc.Parse( str.c_str() ); TiXmlPrinter printer; printer.SetStreamPrinting(); doc.Accept( &printer ); XmlTest( "CDATA with all bytes #1.", str.c_str(), printer.CStr(), true ); #ifdef TIXML_USE_STL doc.Clear(); istringstream iss( printer.Str() ); iss >> doc; std::string out; out << doc; XmlTest( "CDATA with all bytes #2.", out.c_str(), printer.CStr(), true ); #endif } { // [ 1480107 ] Bug-fix for STL-streaming of CDATA that contains tags // CDATA streaming had a couple of bugs, that this tests for. const char* str = "" "I am > the rules!\n" "...since I make symbolic puns" "]]>" ""; TiXmlDocument doc; doc.Parse( str ); doc.Print(); XmlTest( "CDATA parse. [ 1480107 ]", doc.FirstChildElement()->FirstChild()->Value(), "I am > the rules!\n...since I make symbolic puns", true ); #ifdef TIXML_USE_STL doc.Clear(); istringstream parse0( str ); parse0 >> doc; XmlTest( "CDATA stream. [ 1480107 ]", doc.FirstChildElement()->FirstChild()->Value(), "I am > the rules!\n...since I make symbolic puns", true ); #endif TiXmlDocument doc1 = doc; //doc.Print(); XmlTest( "CDATA copy. [ 1480107 ]", doc1.FirstChildElement()->FirstChild()->Value(), "I am > the rules!\n...since I make symbolic puns", true ); } ////////////////////////////////////////////////////// // Visit() ////////////////////////////////////////////////////// printf( "\n** Fuzzing... **\n" ); const int FUZZ_ITERATION = 300; // The only goal is not to crash on bad input. int len = (int) strlen( demoStart ); for( int i=0; i" "" " " ""; TiXmlDocument doc( "passages.xml" ); doc.Parse( passages ); TiXmlElement* psg = doc.RootElement()->FirstChildElement(); const char* context = psg->Attribute( "context" ); const char* expected = "Line 5 has \"quotation marks\" and 'apostrophe marks'. It also has <, >, and &, as well as a fake copyright \xC2\xA9."; XmlTest( "Entity transformation: read. ", expected, context, true ); FILE* textfile = fopen( "textfile.txt", "w" ); if ( textfile ) { psg->Print( textfile, 0 ); fclose( textfile ); } textfile = fopen( "textfile.txt", "r" ); assert( textfile ); if ( textfile ) { char buf[ 1024 ]; fgets( buf, 1024, textfile ); XmlTest( "Entity transformation: write. ", "", buf, true ); } fclose( textfile ); } { FILE* textfile = fopen( "test5.xml", "w" ); if ( textfile ) { fputs("", textfile); fclose(textfile); TiXmlDocument doc; doc.LoadFile( "test5.xml" ); XmlTest( "dot in element attributes and names", doc.Error(), 0); } } { FILE* textfile = fopen( "test6.xml", "w" ); if ( textfile ) { fputs("1.1 Start easy ignore fin thickness ", textfile ); fclose(textfile); TiXmlDocument doc; bool result = doc.LoadFile( "test6.xml" ); XmlTest( "Entity with one digit.", result, true ); TiXmlText* text = doc.FirstChildElement()->FirstChildElement()->FirstChild()->ToText(); XmlTest( "Entity with one digit.", text->Value(), "1.1 Start easy ignore fin thickness\n" ); } } { // DOCTYPE not preserved (950171) // const char* doctype = "" "" "" "" ""; TiXmlDocument doc; doc.Parse( doctype ); doc.SaveFile( "test7.xml" ); doc.Clear(); doc.LoadFile( "test7.xml" ); TiXmlHandle docH( &doc ); TiXmlUnknown* unknown = docH.Child( 1 ).Unknown(); XmlTest( "Correct value of unknown.", "!DOCTYPE PLAY SYSTEM 'play.dtd'", unknown->Value() ); #ifdef TIXML_USE_STL TiXmlNode* node = docH.Child( 2 ).Node(); std::string str; str << (*node); XmlTest( "Correct streaming of unknown.", "", str.c_str() ); #endif } { // [ 791411 ] Formatting bug // Comments do not stream out correctly. const char* doctype = ""; TiXmlDocument doc; doc.Parse( doctype ); TiXmlHandle docH( &doc ); TiXmlComment* comment = docH.Child( 0 ).Node()->ToComment(); XmlTest( "Comment formatting.", " Somewhat ", comment->Value() ); #ifdef TIXML_USE_STL std::string str; str << (*comment); XmlTest( "Comment streaming.", "", str.c_str() ); #endif } { // [ 870502 ] White space issues TiXmlDocument doc; TiXmlText* text; TiXmlHandle docH( &doc ); const char* doctype0 = " This has leading and trailing space "; const char* doctype1 = "This has internal space"; const char* doctype2 = " This has leading, trailing, and internal space "; TiXmlBase::SetCondenseWhiteSpace( false ); doc.Clear(); doc.Parse( doctype0 ); text = docH.FirstChildElement( "element" ).Child( 0 ).Text(); XmlTest( "White space kept.", " This has leading and trailing space ", text->Value() ); doc.Clear(); doc.Parse( doctype1 ); text = docH.FirstChildElement( "element" ).Child( 0 ).Text(); XmlTest( "White space kept.", "This has internal space", text->Value() ); doc.Clear(); doc.Parse( doctype2 ); text = docH.FirstChildElement( "element" ).Child( 0 ).Text(); XmlTest( "White space kept.", " This has leading, trailing, and internal space ", text->Value() ); TiXmlBase::SetCondenseWhiteSpace( true ); doc.Clear(); doc.Parse( doctype0 ); text = docH.FirstChildElement( "element" ).Child( 0 ).Text(); XmlTest( "White space condensed.", "This has leading and trailing space", text->Value() ); doc.Clear(); doc.Parse( doctype1 ); text = docH.FirstChildElement( "element" ).Child( 0 ).Text(); XmlTest( "White space condensed.", "This has internal space", text->Value() ); doc.Clear(); doc.Parse( doctype2 ); text = docH.FirstChildElement( "element" ).Child( 0 ).Text(); XmlTest( "White space condensed.", "This has leading, trailing, and internal space", text->Value() ); } { // Double attributes const char* doctype = ""; TiXmlDocument doc; doc.Parse( doctype ); XmlTest( "Parsing repeated attributes.", true, doc.Error() ); // is an error to tinyxml (didn't use to be, but caused issues) //XmlTest( "Parsing repeated attributes.", "blue", doc.FirstChildElement( "element" )->Attribute( "attr" ) ); } { // Embedded null in stream. const char* doctype = ""; TiXmlDocument doc; doc.Parse( doctype ); XmlTest( "Embedded null throws error.", true, doc.Error() ); #ifdef TIXML_USE_STL istringstream strm( doctype ); doc.Clear(); doc.ClearError(); strm >> doc; XmlTest( "Embedded null throws error.", true, doc.Error() ); #endif } { // Legacy mode test. (This test may only pass on a western system) const char* str = "" "<ä>" "CöntäntßäöüÄÖÜ" ""; TiXmlDocument doc; doc.Parse( str ); TiXmlHandle docHandle( &doc ); TiXmlHandle aHandle = docHandle.FirstChildElement( "ä" ); TiXmlHandle tHandle = aHandle.Child( 0 ); assert( aHandle.Element() ); assert( tHandle.Text() ); XmlTest( "ISO-8859-1 Parsing.", "CöntäntßäöüÄÖÜ", tHandle.Text()->Value() ); } { // Empty documents should return TIXML_ERROR_PARSING_EMPTY, bug 1070717 const char* str = " "; TiXmlDocument doc; doc.Parse( str ); XmlTest( "Empty document error TIXML_ERROR_DOCUMENT_EMPTY", TiXmlBase::TIXML_ERROR_DOCUMENT_EMPTY, doc.ErrorId() ); } #ifndef TIXML_USE_STL { // String equality. [ 1006409 ] string operator==/!= no worky in all cases TiXmlString temp; XmlTest( "Empty tinyxml string compare equal", ( temp == "" ), true ); TiXmlString foo; TiXmlString bar( "" ); XmlTest( "Empty tinyxml string compare equal", ( foo == bar ), true ); } #endif { // Bug [ 1195696 ] from marlonism TiXmlBase::SetCondenseWhiteSpace(false); TiXmlDocument xml; xml.Parse("This hangs"); XmlTest( "Test safe error return.", xml.Error(), false ); } { // Bug [ 1243992 ] - another infinite loop TiXmlDocument doc; doc.SetCondenseWhiteSpace(false); doc.Parse("

test

"); } { // Low entities TiXmlDocument xml; xml.Parse( "" ); const char result[] = { 0x0e, 0 }; XmlTest( "Low entities.", xml.FirstChildElement()->GetText(), result ); xml.Print(); } { // Bug [ 1451649 ] Attribute values with trailing quotes not handled correctly TiXmlDocument xml; xml.Parse( "" ); XmlTest( "Throw error with bad end quotes.", xml.Error(), true ); } #ifdef TIXML_USE_STL { // Bug [ 1449463 ] Consider generic query TiXmlDocument xml; xml.Parse( "" ); TiXmlElement* ele = xml.FirstChildElement(); double d; int i; float f; bool b; std::string str; XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &d ), TIXML_SUCCESS ); XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &i ), TIXML_SUCCESS ); XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &f ), TIXML_SUCCESS ); XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "bar", &b ), TIXML_WRONG_TYPE ); XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "nobar", &b ), TIXML_NO_ATTRIBUTE ); XmlTest( "QueryValueAttribute", ele->QueryValueAttribute( "barStr", &str ), TIXML_SUCCESS ); XmlTest( "QueryValueAttribute", (d==3.0), true ); XmlTest( "QueryValueAttribute", (i==3), true ); XmlTest( "QueryValueAttribute", (f==3.0f), true ); XmlTest( "QueryValueAttribute", (str==std::string( "a string" )), true ); } #endif #ifdef TIXML_USE_STL { // [ 1505267 ] redundant malloc in TiXmlElement::Attribute TiXmlDocument xml; xml.Parse( "" ); TiXmlElement* ele = xml.FirstChildElement(); double d; int i; std::string bar = "bar"; const std::string* atrrib = ele->Attribute( bar ); ele->Attribute( bar, &d ); ele->Attribute( bar, &i ); XmlTest( "Attribute", atrrib->empty(), false ); XmlTest( "Attribute", (d==3.0), true ); XmlTest( "Attribute", (i==3), true ); } #endif { // [ 1356059 ] Allow TiXMLDocument to only be at the top level TiXmlDocument xml, xml2; xml.InsertEndChild( xml2 ); XmlTest( "Document only at top level.", xml.Error(), true ); XmlTest( "Document only at top level.", xml.ErrorId(), TiXmlBase::TIXML_ERROR_DOCUMENT_TOP_ONLY ); } { // [ 1663758 ] Failure to report error on bad XML TiXmlDocument xml; xml.Parse(""); XmlTest("Missing end tag at end of input", xml.Error(), true); xml.Parse(" "); XmlTest("Missing end tag with trailing whitespace", xml.Error(), true); } { // [ 1635701 ] fail to parse files with a tag separated into two lines // I'm not sure this is a bug. Marked 'pending' for feedback. TiXmlDocument xml; xml.Parse( "<p>text</p\n><title>" ); //xml.Print(); //XmlTest( "Tag split by newline", xml.Error(), false ); } #ifdef TIXML_USE_STL { // [ 1475201 ] TinyXML parses entities in comments TiXmlDocument xml; istringstream parse1( "<!-- declarations for <head> & <body> -->" "<!-- far & away -->" ); parse1 >> xml; TiXmlNode* e0 = xml.FirstChild(); TiXmlNode* e1 = e0->NextSibling(); TiXmlComment* c0 = e0->ToComment(); TiXmlComment* c1 = e1->ToComment(); XmlTest( "Comments ignore entities.", " declarations for <head> & <body> ", c0->Value(), true ); XmlTest( "Comments ignore entities.", " far & away ", c1->Value(), true ); } #endif { // [ 1475201 ] TinyXML parses entities in comments TiXmlDocument xml; xml.Parse("<!-- declarations for <head> & <body> -->" "<!-- far & away -->" ); TiXmlNode* e0 = xml.FirstChild(); TiXmlNode* e1 = e0->NextSibling(); TiXmlComment* c0 = e0->ToComment(); TiXmlComment* c1 = e1->ToComment(); XmlTest( "Comments ignore entities.", " declarations for <head> & <body> ", c0->Value(), true ); XmlTest( "Comments ignore entities.", " far & away ", c1->Value(), true ); } { TiXmlDocument xml; xml.Parse( "<Parent>" "<child1 att=''/>" "<!-- With this comment, child2 will not be parsed! -->" "<child2 att=''/>" "</Parent>" ); int count = 0; TiXmlNode* ele = 0; while ( (ele = xml.FirstChildElement( "Parent" )->IterateChildren( ele ) ) != 0 ) { ++count; } XmlTest( "Comments iterate correctly.", 3, count ); } { // trying to repro ]1874301]. If it doesn't go into an infinite loop, all is well. unsigned char buf[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?><feed><![CDATA[Test XMLblablablalblbl"; buf[60] = 239; buf[61] = 0; TiXmlDocument doc; doc.Parse( (const char*)buf); } { // bug 1827248 Error while parsing a little bit malformed file // Actually not malformed - should work. TiXmlDocument xml; xml.Parse( "<attributelist> </attributelist >" ); XmlTest( "Handle end tag whitespace", false, xml.Error() ); } { // This one must not result in an infinite loop TiXmlDocument xml; xml.Parse( "<infinite>loop" ); XmlTest( "Infinite loop test.", true, true ); } { // 1709904 - can not repro the crash { TiXmlDocument xml; xml.Parse( "<tag>/</tag>" ); XmlTest( "Odd XML parsing.", xml.FirstChild()->Value(), "tag" ); } /* Could not repro. { TiXmlDocument xml; xml.LoadFile( "EQUI_Inventory.xml" ); //XmlTest( "Odd XML parsing.", xml.FirstChildElement()->Value(), "XML" ); TiXmlPrinter printer; xml.Accept( &printer ); fprintf( stdout, "%s", printer.CStr() ); }*/ } /* 1417717 experiment { TiXmlDocument xml; xml.Parse("<text>Dan & Tracie</text>"); xml.Print(stdout); } { TiXmlDocument xml; xml.Parse("<text>Dan &foo; Tracie</text>"); xml.Print(stdout); } */ #if defined( WIN32 ) && defined( TUNE ) _CrtMemCheckpoint( &endMemState ); //_CrtMemDumpStatistics( &endMemState ); _CrtMemState diffMemState; _CrtMemDifference( &diffMemState, &startMemState, &endMemState ); _CrtMemDumpStatistics( &diffMemState ); #endif printf ("\nPass %d, Fail %d\n", gPass, gFail); return gFail; } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������tinyxml/docs/annotated.html�������������������������������������������������������������������������000664 �000765 �000024 �00000007324 11563634571 020061� 0����������������������������������������������������������������������������������������������������ustar�00leethomason���������������������staff���������������������������000000 �000000 ������������������������������������������������������������������������������������������������������������������������������������������������������������������������<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>TinyXml: Class List

Class List

Here are the classes, structs, unions and interfaces with brief descriptions:
TiXmlAttributeAn attribute is a name-value pair
TiXmlBaseTiXmlBase is a base class for every class in TinyXml
TiXmlCommentAn XML comment
TiXmlDeclarationIn correct XML the declaration is the first entry in the file
TiXmlDocumentAlways the top level node
TiXmlElementThe element is a container class
TiXmlHandleA TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thing
TiXmlNodeThe parent class for everything in the Document Object Model
TiXmlPrinterPrint to memory functionality
TiXmlTextXML text
TiXmlUnknownAny tag that tinyXml doesn't recognize is saved as an unknown
TiXmlVisitorImplements the interface to the "Visitor pattern" (see the Accept() method

Generated by  doxygen 1.6.2
tinyxml/docs/classes.html000664 000765 000024 00000005371 11563634571 017541 0ustar00leethomasonstaff000000 000000 TinyXml: Alphabetical List

Class Index

  T  
TiXmlComment   TiXmlElement   TiXmlPrinter   TiXmlUnknown   
TiXmlAttribute   TiXmlDeclaration   TiXmlHandle   TiXmlText   TiXmlVisitor   
TiXmlBase   TiXmlDocument   TiXmlNode   

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlAttribute-members.html000664 000765 000024 00000020160 11563634571 023474 0ustar00leethomasonstaff000000 000000 TinyXml: Member List

TiXmlAttribute Member List

This is the complete list of members for TiXmlAttribute, including all inherited members.
Column() const TiXmlBase [inline]
DoubleValue() const TiXmlAttribute
EncodeString(const TIXML_STRING &str, TIXML_STRING *out)TiXmlBase [static]
GetUserData()TiXmlBase [inline]
GetUserData() const TiXmlBase [inline]
IntValue() const TiXmlAttribute
IsWhiteSpaceCondensed()TiXmlBase [inline, static]
Name() const TiXmlAttribute [inline]
Next() const TiXmlAttribute
Previous() const TiXmlAttribute
Print(FILE *cfile, int depth) const TiXmlAttribute [inline, virtual]
QueryDoubleValue(double *_value) const TiXmlAttribute
QueryIntValue(int *_value) const TiXmlAttribute
Row() const TiXmlBase [inline]
SetCondenseWhiteSpace(bool condense)TiXmlBase [inline, static]
SetDoubleValue(double _value)TiXmlAttribute
SetIntValue(int _value)TiXmlAttribute
SetName(const char *_name)TiXmlAttribute [inline]
SetName(const std::string &_name)TiXmlAttribute [inline]
SetUserData(void *user)TiXmlBase [inline]
SetValue(const char *_value)TiXmlAttribute [inline]
SetValue(const std::string &_value)TiXmlAttribute [inline]
TiXmlAttribute()TiXmlAttribute [inline]
TiXmlAttribute(const std::string &_name, const std::string &_value)TiXmlAttribute [inline]
TiXmlAttribute(const char *_name, const char *_value)TiXmlAttribute [inline]
userDataTiXmlBase [protected]
Value() const TiXmlAttribute [inline]
ValueStr() const TiXmlAttribute [inline]

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlAttribute.html000664 000765 000024 00000036243 11563634571 022055 0ustar00leethomasonstaff000000 000000 TinyXml: TiXmlAttribute Class Reference

TiXmlAttribute Class Reference

An attribute is a name-value pair. More...

#include <tinyxml.h>

Inheritance diagram for TiXmlAttribute:
TiXmlBase

List of all members.

Public Member Functions

 TiXmlAttribute ()
 Construct an empty attribute.
 TiXmlAttribute (const std::string &_name, const std::string &_value)
 std::string constructor.
 TiXmlAttribute (const char *_name, const char *_value)
 Construct an attribute with a name and value.
const char * Name () const
 Return the name of this attribute.
const char * Value () const
 Return the value of this attribute.
const std::string & ValueStr () const
 Return the value of this attribute.
int IntValue () const
 Return the value of this attribute, converted to an integer.
double DoubleValue () const
 Return the value of this attribute, converted to a double.
int QueryIntValue (int *_value) const
 QueryIntValue examines the value string.
int QueryDoubleValue (double *_value) const
 QueryDoubleValue examines the value string. See QueryIntValue().
void SetName (const char *_name)
 Set the name of this attribute.
void SetValue (const char *_value)
 Set the value.
void SetIntValue (int _value)
 Set the value from an integer.
void SetDoubleValue (double _value)
 Set the value from a double.
void SetName (const std::string &_name)
 STL std::string form.
void SetValue (const std::string &_value)
 STL std::string form.
const TiXmlAttributeNext () const
 Get the next sibling attribute in the DOM. Returns null at end.
const TiXmlAttributePrevious () const
 Get the previous sibling attribute in the DOM. Returns null at beginning.
virtual void Print (FILE *cfile, int depth) const
 All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.

Detailed Description

An attribute is a name-value pair.

Elements have an arbitrary number of attributes, each with a unique name.

Note:
The attributes are not TiXmlNodes, since they are not part of the tinyXML document object model. There are other suggested ways to look at this problem.

Member Function Documentation

virtual void TiXmlAttribute::Print ( FILE *  cfile,
int  depth 
) const [inline, virtual]

All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.

) Either or both cfile and str can be null.

This is a formatted print, and will insert tabs and newlines.

(For an unformatted stream, use the << operator.)

Implements TiXmlBase.

int TiXmlAttribute::QueryIntValue ( int *  _value  )  const

QueryIntValue examines the value string.

It is an alternative to the IntValue() method with richer error checking. If the value is an integer, it is stored in 'value' and the call returns TIXML_SUCCESS. If it is not an integer, it returns TIXML_WRONG_TYPE.

A specialized but useful call. Note that for success it returns 0, which is the opposite of almost all other TinyXml calls.


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlAttribute.png000664 000765 000024 00000000621 11563634571 021664 0ustar00leethomasonstaff000000 000000 ‰PNG  IHDRZP®ķ’VPLTE’’’’’ĄŸŸ`ĄĄĄ{Ā’ätRNS’’’’’’’ÕŹT2 IDATxķŪĆ †Į&¾’#ļ‚ƒŠźŖMŁ”Lk…}ĄÆé5la[ ²DdKAڰNö_®Z’‰;²ę›bт„ĮL‹ęāe>f{‹&f)ˆE%gĖŌ^VŠmn?£µ;E“T½+P”‡œżE­čVØÖ~3ś¢Ö”Mļrł—nH~Cżt˜Į’Õµšß@×ʎC×ĘD’é It¢čD':щ¾aÕa¢?6‡Ź.ČĶā2KשŚ-\šHĻ[A –s š›/šhD iˆÖšDfP ZņC¦ć.ŚÉ:@»å<ŚÉŖeR«gh;ÕŚÓ;Mt«ž:Ęst ˜ä(“Ū¤K”©©}>īŃ ÉoH¢Ÿ„³XHŻŠĄIEND®B`‚tinyxml/docs/classTiXmlBase-members.html000664 000765 000024 00000007462 11563634571 022415 0ustar00leethomasonstaff000000 000000 TinyXml: Member List

TiXmlBase Member List

This is the complete list of members for TiXmlBase, including all inherited members.
Column() const TiXmlBase [inline]
EncodeString(const TIXML_STRING &str, TIXML_STRING *out)TiXmlBase [static]
GetUserData()TiXmlBase [inline]
GetUserData() const TiXmlBase [inline]
IsWhiteSpaceCondensed()TiXmlBase [inline, static]
Print(FILE *cfile, int depth) const =0TiXmlBase [pure virtual]
Row() const TiXmlBase [inline]
SetCondenseWhiteSpace(bool condense)TiXmlBase [inline, static]
SetUserData(void *user)TiXmlBase [inline]
userDataTiXmlBase [protected]

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlBase.html000664 000765 000024 00000037241 11563634571 020763 0ustar00leethomasonstaff000000 000000 TinyXml: TiXmlBase Class Reference

TiXmlBase Class Reference

TiXmlBase is a base class for every class in TinyXml. More...

#include <tinyxml.h>

Inheritance diagram for TiXmlBase:
TiXmlAttribute TiXmlNode TiXmlComment TiXmlDeclaration TiXmlDocument TiXmlElement TiXmlText TiXmlUnknown

List of all members.

Public Member Functions

virtual void Print (FILE *cfile, int depth) const =0
 All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.
int Row () const
 Return the position, in the original source file, of this node or attribute.
int Column () const
 See Row().
void SetUserData (void *user)
 Set a pointer to arbitrary user data.
void * GetUserData ()
 Get a pointer to arbitrary user data.
const void * GetUserData () const
 Get a pointer to arbitrary user data.

Static Public Member Functions

static void SetCondenseWhiteSpace (bool condense)
 The world does not agree on whether white space should be kept or not.
static bool IsWhiteSpaceCondensed ()
 Return the current white space setting.
static void EncodeString (const TIXML_STRING &str, TIXML_STRING *out)
 Expands entities in a string.

Protected Attributes

void * userData
 Field containing a generic user pointer.

Friends

class TiXmlNode
class TiXmlElement
class TiXmlDocument

Detailed Description

TiXmlBase is a base class for every class in TinyXml.

It does little except to establish that TinyXml classes can be printed and provide some utility functions.

In XML, the document and elements can contain other elements and other types of nodes.

	A Document can contain:	Element	(container or leaf)
							Comment (leaf)
							Unknown (leaf)
							Declaration( leaf )

	An Element can contain:	Element (container or leaf)
							Text	(leaf)
							Attributes (not on tree)
							Comment (leaf)
							Unknown (leaf)

	A Decleration contains: Attributes (not on tree)
	

Member Function Documentation

static void TiXmlBase::EncodeString ( const TIXML_STRING &  str,
TIXML_STRING *  out 
) [static]

Expands entities in a string.

Note this should not contian the tag's '<', '>', etc, or they will be transformed into entities!

virtual void TiXmlBase::Print ( FILE *  cfile,
int  depth 
) const [pure virtual]

All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.

) Either or both cfile and str can be null.

This is a formatted print, and will insert tabs and newlines.

(For an unformatted stream, use the << operator.)

Implemented in TiXmlAttribute, TiXmlElement, TiXmlComment, TiXmlText, TiXmlDeclaration, TiXmlUnknown, and TiXmlDocument.

int TiXmlBase::Row (  )  const [inline]

Return the position, in the original source file, of this node or attribute.

The row and column are 1-based. (That is the first row and first column is 1,1). If the returns values are 0 or less, then the parser does not have a row and column value.

Generally, the row and column value will be set when the TiXmlDocument::Load(), TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set when the DOM was created from operator>>.

The values reflect the initial load. Once the DOM is modified programmatically (by adding or changing nodes and attributes) the new values will NOT update to reflect changes in the document.

There is a minor performance cost to computing the row and column. Computation can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value.

See also:
TiXmlDocument::SetTabSize()
static void TiXmlBase::SetCondenseWhiteSpace ( bool  condense  )  [inline, static]

The world does not agree on whether white space should be kept or not.

In order to make everyone happy, these global, static functions are provided to set whether or not TinyXml will condense all white space into a single space or not. The default is to condense. Note changing this value is not thread safe.


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlBase.png000664 000765 000024 00000002676 11563634571 020607 0ustar00leethomasonstaff000000 000000 ‰PNG  IHDRŗˆ?ø¤PLTE’’’’’ĄŸŸ`ĄĄĄ{Ā’ätRNS’’’’’’’ÕŹT2MIDATxķŻŃr« …įā™éū?ņ¹@mbÓä[ÓŲF,˽öļööėnŌ+ÖOV7ņ]‚.t ŗŠ%č]ē)D}…tIya˜×”K/9uóRX_—x>#téNt¶ń33[¢;ßtyˆnB72ūõĀWHų¦Å…äå téUŠ]ŽĖOX&l"ŗōŖSw5`#Ŗįł°š ]ś}t‹ĻŻeŠęŁ ]śCč.'M]ztĖ”ŗü„ā!Äļé té·ŃżĆV]čt”KŠ%‚.Aŗ]"čŅ£{£¤Mæ®ot‰n$÷»]¢;ÉÅ.A—čNxE@Š%‚.t ŗDŠ%‚.A—ŗDŠ„ᄆ„#NL¤'bŅ“žˆ‰ōDL¤'bŅ1‘žˆ‰ōDLzBbŅ1‘žˆ‰ōDLz"&Ņ1}ŗž]Ņ÷„’Ó»ĒtoO¦Ūō§Ń“žˆ ŗz"&載˜ōŗŠżž„Ø)LSˆ'ŹÅś˜–Š?Ėė>Ż£ø¶'»é@÷ē=ÉцuĪ!ę_åŚ§¢{WHYA÷6tSāgę“@wž6SH«”ø:„)>Ż^\sX1°8¦ĖoŠ}ŗyĄ†9ńŗAsņt)¶Aļn+®Œn‘L'č>ŻåXóX·£īĢ£ŪˆkŻ*9č>{źVł‡ų²;Bw¾ģ§ī†Ųm@t ū@tk4—^4†psź¾SOŠķÅÕB·»toGw¹ ^ƒnޤ؏/tŒīŠŅ5ŗ”nI|†8bā;ń³¦ī~\)P+č>®'×{¢+&=tõDLŠÕ1é t”«'b"=“ž@WLw÷äF‰éŻc¢wŃ·ŗD7’ū]‚.ѝäb— Kt'¼" čA—ŗ]"čA— K]"č~dOˆ§÷'\¹*‘+t¹r….W®JäŹU°\”Ė•+t¹rU"Wčrå ]®\•Č•«`¹B—+Wčrż`×—ō}éæør} ėæé6•%råśSWĮr…®`¹B—+WčrżtCŌ¦)Äåbŗb|ūśŅM‰Gvqõ`×ņśį`/:W»ÓĪ!ļ^5ū9ŒAtpiy ó}×ĆBės'óŽNݼAXļ–OŒ{ {d×qė¢{.Ų ĪAwČ{Äž*ŗ‡]Īüų1=ņcŠMFń3»Tƒ >–ÅZ¾•“ēĒŗūv!ļš7_NĢc*–…čŒīē”jŠ= ¹Ŗę8Żóčön —Ÿg’ž;误BcœĖ™Ō¹lžžk};čF—i aŹCż-kÅEó÷ķ|ݾ]]ė²[»:[ū”{Īy°ŚAt÷B>åwŻÖ ŌÄõ¼Ī”Ū-“,§čhĘ<żÕ ©oVõƃnė§9„ŃķŚm¶+~ÕmŽų”{Īy¬ŚQt[Ž!¹ĘS¹—īEt7°–›—żt{!×d{JÕ =1uĻ”›cæ:u›-».oŅåõVtś ŗ»Īūčv«=;u!Wū§ūĆ©Ū@7eüt{…>ŻāsrźÖ70ˆnß®5nW’ń£©{č¼?uŪÕ¢»rµ’qŗ×ŠmXĖuē/¢Ū-“Ģø¾( AwėÖB÷ŅŌŻ«­ł(>ݶóXµCw4ݧ ›gå-č6øžŒ [ĪŅ)¾D¦ü¾Ž$›ß/ł0‚nÓ.½²Ņ®åę!?ŒóßńDķ?‚īēŁd Ś1tūŽėżÓ½„nÆĖKé ŻvŠmūĢ!W“– >‰ī5,W®®‚å ]Įr….W®Šå ]Įr….W®Šåś¹čŽØ¢D®\Ø’§Œ¾Ł]®ŹIEND®B`‚tinyxml/docs/classTiXmlComment-members.html000664 000765 000024 00000045530 11563634571 023143 0ustar00leethomasonstaff000000 000000 TinyXml: Member List

TiXmlComment Member List

This is the complete list of members for TiXmlComment, including all inherited members.
Accept(TiXmlVisitor *visitor) const TiXmlComment [virtual]
Clear()TiXmlNode
Clone() const TiXmlComment [virtual]
Column() const TiXmlBase [inline]
EncodeString(const TIXML_STRING &str, TIXML_STRING *out)TiXmlBase [static]
FirstChild() const TiXmlNode [inline]
FirstChild(const char *value) const TiXmlNode
FirstChild(const char *_value)TiXmlNode [inline]
FirstChild(const std::string &_value) const TiXmlNode [inline]
FirstChild(const std::string &_value)TiXmlNode [inline]
FirstChildElement() const TiXmlNode
FirstChildElement(const char *_value) const TiXmlNode
FirstChildElement(const std::string &_value) const TiXmlNode [inline]
FirstChildElement(const std::string &_value)TiXmlNode [inline]
GetDocument() const TiXmlNode
GetUserData()TiXmlBase [inline]
GetUserData() const TiXmlBase [inline]
InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)TiXmlNode
InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)TiXmlNode
InsertEndChild(const TiXmlNode &addThis)TiXmlNode
IsWhiteSpaceCondensed()TiXmlBase [inline, static]
IterateChildren(const TiXmlNode *previous) const TiXmlNode
IterateChildren(const char *value, const TiXmlNode *previous) const TiXmlNode
IterateChildren(const std::string &_value, const TiXmlNode *previous) const TiXmlNode [inline]
IterateChildren(const std::string &_value, const TiXmlNode *previous)TiXmlNode [inline]
LastChild()TiXmlNode [inline]
LastChild(const char *_value)TiXmlNode [inline]
LastChild(const std::string &_value) const TiXmlNode [inline]
LastChild(const std::string &_value)TiXmlNode [inline]
LinkEndChild(TiXmlNode *addThis)TiXmlNode
NextSibling(const std::string &_value) const TiXmlNode [inline]
NextSibling(const std::string &_value)TiXmlNode [inline]
NextSibling() const TiXmlNode [inline]
NextSibling(const char *) const TiXmlNode
NextSiblingElement() const TiXmlNode
NextSiblingElement(const char *) const TiXmlNode
NextSiblingElement(const std::string &_value) const TiXmlNode [inline]
NextSiblingElement(const std::string &_value)TiXmlNode [inline]
NoChildren() const TiXmlNode [inline]
NodeType enum nameTiXmlNode
operator<<(std::ostream &out, const TiXmlNode &base)TiXmlNode [friend]
operator<<(std::string &out, const TiXmlNode &base)TiXmlNode [friend]
operator>>(std::istream &in, TiXmlNode &base)TiXmlNode [friend]
Parent()TiXmlNode [inline]
PreviousSibling() const TiXmlNode [inline]
PreviousSibling(const char *) const TiXmlNode
PreviousSibling(const std::string &_value) const TiXmlNode [inline]
PreviousSibling(const std::string &_value)TiXmlNode [inline]
Print(FILE *cfile, int depth) const TiXmlComment [virtual]
RemoveChild(TiXmlNode *removeThis)TiXmlNode
ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)TiXmlNode
Row() const TiXmlBase [inline]
SetCondenseWhiteSpace(bool condense)TiXmlBase [inline, static]
SetUserData(void *user)TiXmlBase [inline]
SetValue(const char *_value)TiXmlNode [inline]
SetValue(const std::string &_value)TiXmlNode [inline]
TiXmlComment()TiXmlComment [inline]
TiXmlComment(const char *_value)TiXmlComment [inline]
ToComment() const TiXmlComment [inline, virtual]
ToComment()TiXmlComment [inline, virtual]
ToDeclaration() const TiXmlNode [inline, virtual]
ToDeclaration()TiXmlNode [inline, virtual]
ToDocument() const TiXmlNode [inline, virtual]
ToDocument()TiXmlNode [inline, virtual]
ToElement() const TiXmlNode [inline, virtual]
ToElement()TiXmlNode [inline, virtual]
ToText() const TiXmlNode [inline, virtual]
ToText()TiXmlNode [inline, virtual]
ToUnknown() const TiXmlNode [inline, virtual]
ToUnknown()TiXmlNode [inline, virtual]
Type() const TiXmlNode [inline]
userDataTiXmlBase [protected]
Value() const TiXmlNode [inline]
ValueStr() const TiXmlNode [inline]

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlComment.html000664 000765 000024 00000017071 11563634571 021512 0ustar00leethomasonstaff000000 000000 TinyXml: TiXmlComment Class Reference

TiXmlComment Class Reference

An XML comment. More...

#include <tinyxml.h>

Inheritance diagram for TiXmlComment:
TiXmlNode TiXmlBase

List of all members.

Public Member Functions

 TiXmlComment ()
 Constructs an empty comment.
 TiXmlComment (const char *_value)
 Construct a comment from text.
virtual TiXmlNodeClone () const
 Returns a copy of this Comment.
virtual void Print (FILE *cfile, int depth) const
 All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.
virtual const TiXmlCommentToComment () const
 Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlCommentToComment ()
 Cast to a more defined type. Will return null not of the requested type.
virtual bool Accept (TiXmlVisitor *visitor) const
 Walk the XML tree visiting this node and all of its children.

Detailed Description

An XML comment.


Member Function Documentation

virtual void TiXmlComment::Print ( FILE *  cfile,
int  depth 
) const [virtual]

All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.

) Either or both cfile and str can be null.

This is a formatted print, and will insert tabs and newlines.

(For an unformatted stream, use the << operator.)

Implements TiXmlBase.


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlComment.png000664 000765 000024 00000001006 11563634571 021321 0ustar00leethomasonstaff000000 000000 ‰PNG  IHDR^ˆYk¬nPLTE’’’’’ĄŸŸ`ĄĄĄ{Ā’ätRNS’’’’’’’ÕŹT2•IDATxķŻŻ’ƒ `gx’GŽ‹$kS7³Ś=±ņć'DźuŁR£lœąoœ3IƒļŌžK³owÓ¤·g¾éæą–¢®ēuv^=ń„—™ˆ[ŗ¬³?­W¢|?÷Ćå~x?š6ūi¢–ł±żp!÷{¾Oø­!æūEā]ģĻŽ9ųꀒz>5J0jō†;ńµ¦ś¹|­©~2’šėmd×kމJK×¼“ŽēiŻ_ņżģ‘_ūÕ¾œ}Œ—wĪ»œżŠįżz®%ē ń¶ļmƒģmė°7Œoų’˧ĘH'¤å‹h‹IEND®B`‚tinyxml/docs/classTiXmlDeclaration-members.html000664 000765 000024 00000050025 11563634571 023761 0ustar00leethomasonstaff000000 000000 TinyXml: Member List

TiXmlDeclaration Member List

This is the complete list of members for TiXmlDeclaration, including all inherited members.
Accept(TiXmlVisitor *visitor) const TiXmlDeclaration [virtual]
Clear()TiXmlNode
Clone() const TiXmlDeclaration [virtual]
Column() const TiXmlBase [inline]
EncodeString(const TIXML_STRING &str, TIXML_STRING *out)TiXmlBase [static]
Encoding() const TiXmlDeclaration [inline]
FirstChild() const TiXmlNode [inline]
FirstChild(const char *value) const TiXmlNode
FirstChild(const char *_value)TiXmlNode [inline]
FirstChild(const std::string &_value) const TiXmlNode [inline]
FirstChild(const std::string &_value)TiXmlNode [inline]
FirstChildElement() const TiXmlNode
FirstChildElement(const char *_value) const TiXmlNode
FirstChildElement(const std::string &_value) const TiXmlNode [inline]
FirstChildElement(const std::string &_value)TiXmlNode [inline]
GetDocument() const TiXmlNode
GetUserData()TiXmlBase [inline]
GetUserData() const TiXmlBase [inline]
InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)TiXmlNode
InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)TiXmlNode
InsertEndChild(const TiXmlNode &addThis)TiXmlNode
IsWhiteSpaceCondensed()TiXmlBase [inline, static]
IterateChildren(const TiXmlNode *previous) const TiXmlNode
IterateChildren(const char *value, const TiXmlNode *previous) const TiXmlNode
IterateChildren(const std::string &_value, const TiXmlNode *previous) const TiXmlNode [inline]
IterateChildren(const std::string &_value, const TiXmlNode *previous)TiXmlNode [inline]
LastChild()TiXmlNode [inline]
LastChild(const char *_value)TiXmlNode [inline]
LastChild(const std::string &_value) const TiXmlNode [inline]
LastChild(const std::string &_value)TiXmlNode [inline]
LinkEndChild(TiXmlNode *addThis)TiXmlNode
NextSibling(const std::string &_value) const TiXmlNode [inline]
NextSibling(const std::string &_value)TiXmlNode [inline]
NextSibling() const TiXmlNode [inline]
NextSibling(const char *) const TiXmlNode
NextSiblingElement() const TiXmlNode
NextSiblingElement(const char *) const TiXmlNode
NextSiblingElement(const std::string &_value) const TiXmlNode [inline]
NextSiblingElement(const std::string &_value)TiXmlNode [inline]
NoChildren() const TiXmlNode [inline]
NodeType enum nameTiXmlNode
operator<<(std::ostream &out, const TiXmlNode &base)TiXmlNode [friend]
operator<<(std::string &out, const TiXmlNode &base)TiXmlNode [friend]
operator>>(std::istream &in, TiXmlNode &base)TiXmlNode [friend]
Parent()TiXmlNode [inline]
PreviousSibling() const TiXmlNode [inline]
PreviousSibling(const char *) const TiXmlNode
PreviousSibling(const std::string &_value) const TiXmlNode [inline]
PreviousSibling(const std::string &_value)TiXmlNode [inline]
Print(FILE *cfile, int depth) const TiXmlDeclaration [inline, virtual]
RemoveChild(TiXmlNode *removeThis)TiXmlNode
ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)TiXmlNode
Row() const TiXmlBase [inline]
SetCondenseWhiteSpace(bool condense)TiXmlBase [inline, static]
SetUserData(void *user)TiXmlBase [inline]
SetValue(const char *_value)TiXmlNode [inline]
SetValue(const std::string &_value)TiXmlNode [inline]
Standalone() const TiXmlDeclaration [inline]
TiXmlDeclaration()TiXmlDeclaration [inline]
TiXmlDeclaration(const std::string &_version, const std::string &_encoding, const std::string &_standalone)TiXmlDeclaration
TiXmlDeclaration(const char *_version, const char *_encoding, const char *_standalone)TiXmlDeclaration
ToComment() const TiXmlNode [inline, virtual]
ToComment()TiXmlNode [inline, virtual]
ToDeclaration() const TiXmlDeclaration [inline, virtual]
ToDeclaration()TiXmlDeclaration [inline, virtual]
ToDocument() const TiXmlNode [inline, virtual]
ToDocument()TiXmlNode [inline, virtual]
ToElement() const TiXmlNode [inline, virtual]
ToElement()TiXmlNode [inline, virtual]
ToText() const TiXmlNode [inline, virtual]
ToText()TiXmlNode [inline, virtual]
ToUnknown() const TiXmlNode [inline, virtual]
ToUnknown()TiXmlNode [inline, virtual]
Type() const TiXmlNode [inline]
userDataTiXmlBase [protected]
Value() const TiXmlNode [inline]
ValueStr() const TiXmlNode [inline]
Version() const TiXmlDeclaration [inline]

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlDeclaration.html000664 000765 000024 00000025107 11563634571 022334 0ustar00leethomasonstaff000000 000000 TinyXml: TiXmlDeclaration Class Reference

TiXmlDeclaration Class Reference

In correct XML the declaration is the first entry in the file. More...

#include <tinyxml.h>

Inheritance diagram for TiXmlDeclaration:
TiXmlNode TiXmlBase

List of all members.

Public Member Functions

 TiXmlDeclaration ()
 Construct an empty declaration.
 TiXmlDeclaration (const std::string &_version, const std::string &_encoding, const std::string &_standalone)
 Constructor.
 TiXmlDeclaration (const char *_version, const char *_encoding, const char *_standalone)
 Construct.
const char * Version () const
 Version. Will return an empty string if none was found.
const char * Encoding () const
 Encoding. Will return an empty string if none was found.
const char * Standalone () const
 Is this a standalone document?
virtual TiXmlNodeClone () const
 Creates a copy of this Declaration and returns it.
virtual void Print (FILE *cfile, int depth) const
 All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.
virtual const TiXmlDeclarationToDeclaration () const
 Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlDeclarationToDeclaration ()
 Cast to a more defined type. Will return null not of the requested type.
virtual bool Accept (TiXmlVisitor *visitor) const
 Walk the XML tree visiting this node and all of its children.

Detailed Description

In correct XML the declaration is the first entry in the file.

		<?xml version="1.0" standalone="yes"?>
	

TinyXml will happily read or write files without a declaration, however. There are 3 possible attributes to the declaration: version, encoding, and standalone.

Note: In this version of the code, the attributes are handled as special cases, not generic attributes, simply because there can only be at most 3 and they are always the same.


Member Function Documentation

virtual void TiXmlDeclaration::Print ( FILE *  cfile,
int  depth 
) const [inline, virtual]

All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.

) Either or both cfile and str can be null.

This is a formatted print, and will insert tabs and newlines.

(For an unformatted stream, use the << operator.)

Implements TiXmlBase.


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlDeclaration.png000664 000765 000024 00000001055 11563634571 022150 0ustar00leethomasonstaff000000 000000 ‰PNG  IHDRlˆ5mžkPLTE’’’’’ĄŸŸ`ĄĄĄ{Ā’ätRNS’’’’’’’ÕŹT2¼IDATxķŻŻ’Ć `!3¾’#ļ(hH»I,ÓͦłÓčWŠöŗl‰Q6N `OĀH‚‰™¤Įwj’ĀĢś\4YżœÓŽc ’Ci‚ķüĀ’& 3÷¶N³ķįfgūø5Öõ6Ö2›’he”KŪUĖÖlY2=æcĖÖ,X0W±öc¼¹ńß Ų*,1ʵØĒ}=Vk¢–‰ÕšØ„bŽĄ€ 0`Ąž¶%FŁ8-€=# &f’ß5ĪOē2ėcižˆ˜‰>€5HM‰ō^uµEž®c:3锳 ŁÓĢĪįgY‘ŁĪŲcō¢Ž'×ģ=¶pƒŒ˜_„Ukv“`Kw#ž[†%F¹õāøÆĒjMŌ2±ZµTģĮ»0`Ą€ ŲæĆ(1 å•ŲßÅÜvцį%é†Ē“Ę.³įfx¹ ŽĻpˆ½+cŸĻU†t5C¹ų-€œ¬ƒJ/I„µF¢Ņ Ū1‡[L=µ¶+jˆ ScV0_ųę_{‘YˆÉNńŠUTļĻ`īˆ3RšFœĶģ;ę5»„… fæ³p7öÆC$ŪĻļĘĆ#0`ŸĆćŪ©-\ĄøIEND®B`‚tinyxml/docs/classTiXmlDocument-members.html000664 000765 000024 00000056771 11563634571 023330 0ustar00leethomasonstaff000000 000000 TinyXml: Member List

TiXmlDocument Member List

This is the complete list of members for TiXmlDocument, including all inherited members.
Accept(TiXmlVisitor *content) const TiXmlDocument [virtual]
Clear()TiXmlNode
ClearError()TiXmlDocument [inline]
Clone() const TiXmlDocument [protected, virtual]
Column() const TiXmlBase [inline]
EncodeString(const TIXML_STRING &str, TIXML_STRING *out)TiXmlBase [static]
Error() const TiXmlDocument [inline]
ErrorCol() const TiXmlDocument [inline]
ErrorDesc() const TiXmlDocument [inline]
ErrorId() const TiXmlDocument [inline]
ErrorRow() const TiXmlDocument [inline]
FirstChild() const TiXmlNode [inline]
FirstChild(const char *value) const TiXmlNode
FirstChild(const char *_value)TiXmlNode [inline]
FirstChild(const std::string &_value) const TiXmlNode [inline]
FirstChild(const std::string &_value)TiXmlNode [inline]
FirstChildElement() const TiXmlNode
FirstChildElement(const char *_value) const TiXmlNode
FirstChildElement(const std::string &_value) const TiXmlNode [inline]
FirstChildElement(const std::string &_value)TiXmlNode [inline]
GetDocument() const TiXmlNode
GetUserData()TiXmlBase [inline]
GetUserData() const TiXmlBase [inline]
InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)TiXmlNode
InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)TiXmlNode
InsertEndChild(const TiXmlNode &addThis)TiXmlNode
IsWhiteSpaceCondensed()TiXmlBase [inline, static]
IterateChildren(const TiXmlNode *previous) const TiXmlNode
IterateChildren(const char *value, const TiXmlNode *previous) const TiXmlNode
IterateChildren(const std::string &_value, const TiXmlNode *previous) const TiXmlNode [inline]
IterateChildren(const std::string &_value, const TiXmlNode *previous)TiXmlNode [inline]
LastChild()TiXmlNode [inline]
LastChild(const char *_value)TiXmlNode [inline]
LastChild(const std::string &_value) const TiXmlNode [inline]
LastChild(const std::string &_value)TiXmlNode [inline]
LinkEndChild(TiXmlNode *addThis)TiXmlNode
LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)TiXmlDocument
LoadFile(const char *filename, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)TiXmlDocument
LoadFile(FILE *, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)TiXmlDocument
LoadFile(const std::string &filename, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)TiXmlDocument [inline]
NextSibling(const std::string &_value) const TiXmlNode [inline]
NextSibling(const std::string &_value)TiXmlNode [inline]
NextSibling() const TiXmlNode [inline]
NextSibling(const char *) const TiXmlNode
NextSiblingElement() const TiXmlNode
NextSiblingElement(const char *) const TiXmlNode
NextSiblingElement(const std::string &_value) const TiXmlNode [inline]
NextSiblingElement(const std::string &_value)TiXmlNode [inline]
NoChildren() const TiXmlNode [inline]
NodeType enum nameTiXmlNode
operator<<(std::ostream &out, const TiXmlNode &base)TiXmlNode [friend]
operator<<(std::string &out, const TiXmlNode &base)TiXmlNode [friend]
operator>>(std::istream &in, TiXmlNode &base)TiXmlNode [friend]
Parent()TiXmlNode [inline]
Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)TiXmlDocument [virtual]
PreviousSibling() const TiXmlNode [inline]
PreviousSibling(const char *) const TiXmlNode
PreviousSibling(const std::string &_value) const TiXmlNode [inline]
PreviousSibling(const std::string &_value)TiXmlNode [inline]
Print() const TiXmlDocument [inline]
Print(FILE *cfile, int depth=0) const TiXmlDocument [virtual]
RemoveChild(TiXmlNode *removeThis)TiXmlNode
ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)TiXmlNode
RootElement() const TiXmlDocument [inline]
Row() const TiXmlBase [inline]
SaveFile() const TiXmlDocument
SaveFile(const char *filename) const TiXmlDocument
SaveFile(FILE *) const TiXmlDocument
SaveFile(const std::string &filename) const TiXmlDocument [inline]
SetCondenseWhiteSpace(bool condense)TiXmlBase [inline, static]
SetTabSize(int _tabsize)TiXmlDocument [inline]
SetUserData(void *user)TiXmlBase [inline]
SetValue(const char *_value)TiXmlNode [inline]
SetValue(const std::string &_value)TiXmlNode [inline]
TiXmlDocument()TiXmlDocument
TiXmlDocument(const char *documentName)TiXmlDocument
TiXmlDocument(const std::string &documentName)TiXmlDocument
ToComment() const TiXmlNode [inline, virtual]
ToComment()TiXmlNode [inline, virtual]
ToDeclaration() const TiXmlNode [inline, virtual]
ToDeclaration()TiXmlNode [inline, virtual]
ToDocument() const TiXmlDocument [inline, virtual]
ToDocument()TiXmlDocument [inline, virtual]
ToElement() const TiXmlNode [inline, virtual]
ToElement()TiXmlNode [inline, virtual]
ToText() const TiXmlNode [inline, virtual]
ToText()TiXmlNode [inline, virtual]
ToUnknown() const TiXmlNode [inline, virtual]
ToUnknown()TiXmlNode [inline, virtual]
Type() const TiXmlNode [inline]
userDataTiXmlBase [protected]
Value() const TiXmlNode [inline]
ValueStr() const TiXmlNode [inline]

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlDocument.html000664 000765 000024 00000074026 11563634571 021671 0ustar00leethomasonstaff000000 000000 TinyXml: TiXmlDocument Class Reference

TiXmlDocument Class Reference

Always the top level node. More...

#include <tinyxml.h>

Inheritance diagram for TiXmlDocument:
TiXmlNode TiXmlBase

List of all members.

Public Member Functions

 TiXmlDocument ()
 Create an empty document, that has no name.
 TiXmlDocument (const char *documentName)
 Create a document with a name. The name of the document is also the filename of the xml.
 TiXmlDocument (const std::string &documentName)
 Constructor.
bool LoadFile (TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
 Load a file using the current document value.
bool SaveFile () const
 Save a file using the current document value. Returns true if successful.
bool LoadFile (const char *filename, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
 Load a file using the given filename. Returns true if successful.
bool SaveFile (const char *filename) const
 Save a file using the given filename. Returns true if successful.
bool LoadFile (FILE *, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
 Load a file using the given FILE*.
bool SaveFile (FILE *) const
 Save a file using the given FILE*. Returns true if successful.
bool LoadFile (const std::string &filename, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
bool SaveFile (const std::string &filename) const
 < STL std::string version.
virtual const char * Parse (const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
 Parse the given null terminated block of xml data.
const TiXmlElementRootElement () const
 Get the root element -- the only top level element -- of the document.
bool Error () const
 If an error occurs, Error will be set to true.
const char * ErrorDesc () const
 Contains a textual (english) description of the error if one occurs.
int ErrorId () const
 Generally, you probably want the error string ( ErrorDesc() ).
int ErrorRow () const
 Returns the location (if known) of the error.
int ErrorCol () const
 The column where the error occured. See ErrorRow().
void SetTabSize (int _tabsize)
 SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) to report the correct values for row and column.
void ClearError ()
 If you have handled the error, it can be reset with this call.
void Print () const
 Write the document to standard out using formatted printing ("pretty print").
virtual void Print (FILE *cfile, int depth=0) const
 Print this Document to a FILE stream.
virtual const TiXmlDocumentToDocument () const
 Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlDocumentToDocument ()
 Cast to a more defined type. Will return null not of the requested type.
virtual bool Accept (TiXmlVisitor *content) const
 Walk the XML tree visiting this node and all of its children.

Protected Member Functions

virtual TiXmlNodeClone () const
 Create an exact duplicate of this node and return it.

Detailed Description

Always the top level node.

A document binds together all the XML pieces. It can be saved, loaded, and printed to the screen. The 'value' of a document node is the xml file name.


Member Function Documentation

void TiXmlDocument::ClearError (  )  [inline]

If you have handled the error, it can be reset with this call.

The error state is automatically cleared if you Parse a new XML block.

virtual TiXmlNode* TiXmlDocument::Clone (  )  const [protected, virtual]

Create an exact duplicate of this node and return it.

The memory must be deleted by the caller.

Implements TiXmlNode.

bool TiXmlDocument::Error (  )  const [inline]

If an error occurs, Error will be set to true.

Also,

  • The ErrorId() will contain the integer identifier of the error (not generally useful)
  • The ErrorDesc() method will return the name of the error. (very useful)
  • The ErrorRow() and ErrorCol() will return the location of the error (if known)
int TiXmlDocument::ErrorId (  )  const [inline]

Generally, you probably want the error string ( ErrorDesc() ).

But if you prefer the ErrorId, this function will fetch it.

int TiXmlDocument::ErrorRow (  )  const [inline]

Returns the location (if known) of the error.

The first column is column 1, and the first row is row 1. A value of 0 means the row and column wasn't applicable (memory errors, for example, have no row/column) or the parser lost the error. (An error in the error reporting, in that case.)

See also:
SetTabSize, Row, Column
bool TiXmlDocument::LoadFile ( const std::string &  filename,
TiXmlEncoding  encoding = TIXML_DEFAULT_ENCODING 
) [inline]
Parameters:
encoding STL std::string version.

References LoadFile().

bool TiXmlDocument::LoadFile ( FILE *  ,
TiXmlEncoding  encoding = TIXML_DEFAULT_ENCODING 
)

Load a file using the given FILE*.

Returns true if successful. Note that this method doesn't stream - the entire object pointed at by the FILE* will be interpreted as an XML file. TinyXML doesn't stream in XML from the current file location. Streaming may be added in the future.

bool TiXmlDocument::LoadFile ( TiXmlEncoding  encoding = TIXML_DEFAULT_ENCODING  ) 

Load a file using the current document value.

Returns true if successful. Will delete any existing document data before loading.

Referenced by LoadFile().

virtual const char* TiXmlDocument::Parse ( const char *  p,
TiXmlParsingData *  data = 0,
TiXmlEncoding  encoding = TIXML_DEFAULT_ENCODING 
) [virtual]

Parse the given null terminated block of xml data.

Passing in an encoding to this method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml to use that encoding, regardless of what TinyXml might otherwise try to detect.

Implements TiXmlBase.

void TiXmlDocument::Print (  )  const [inline]

Write the document to standard out using formatted printing ("pretty print").

References Print().

Referenced by Print().

const TiXmlElement* TiXmlDocument::RootElement (  )  const [inline]

Get the root element -- the only top level element -- of the document.

In well formed XML, there should only be one. TinyXml is tolerant of multiple elements at the document level.

References TiXmlNode::FirstChildElement().

void TiXmlDocument::SetTabSize ( int  _tabsize  )  [inline]

SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) to report the correct values for row and column.

It does not change the output or input in any way.

By calling this method, with a tab size greater than 0, the row and column of each node and attribute is stored when the file is loaded. Very useful for tracking the DOM back in to the source file.

The tab size is required for calculating the location of nodes. If not set, the default of 4 is used. The tabsize is set per document. Setting the tabsize to 0 disables row/column tracking.

Note that row and column tracking is not supported when using operator>>.

The tab size needs to be enabled before the parse or load. Correct usage:

		TiXmlDocument doc;
		doc.SetTabSize( 8 );
		doc.Load( "myfile.xml" );
		
See also:
Row, Column

The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlDocument.png000664 000765 000024 00000001027 11563634571 021500 0ustar00leethomasonstaff000000 000000 ‰PNG  IHDRcˆÄf„ęPLTE’’’’’ĄŸŸ`ĄĄĄ{Ā’ätRNS’’’’’’’ÕŹT2¦IDATxķŻįƒ pĮ;ß’‘÷T(«i£ŪvnÕŅāįö9åųH™£Ę/$ĮÄL2`'už~-mˆ捜5ælšÜZNŻŁkC’3q{{u²“żdÉčūž1żp=[5j›G®ļJu”ÜķĒŽčŽŖ‰2īöcŠ óZźhm]į’  Ī)ĒGšŽ2Ė7„Ä#„Ä#O³®`Ą€ 0`œGŽ”9:`ü€ALĢ$vr4ø={«Žv mļ'f¢Ļ5ælZéwŁ”Ó9›64!i&kōõ³£ļ‡ŸżįF»Ō{ƒĘ/k¢×Ężž{Ćvąf?Žšń‰u…’+0˜sŹń‘¦£ĢßņF)ńČF)ńČĘ߬+0`Ą€ ēAń‘(¼pßi˜ ī"™ŸO¾­Ć}qł*<‹5ælšÜ§õČ”Ķ¶ĒŠa’Ś:H”ŚŪk†1ĶĮ\©ēż¦±į2¶sŁą¢“: Y׆{ŃóuøįiĆO“G_xWĆfō߇[WnQōUgZ’+0®Œųx‘ń)Æ`ßī#IEND®B`‚tinyxml/docs/classTiXmlElement-members.html000664 000765 000024 00000057357 11563634571 023144 0ustar00leethomasonstaff000000 000000 TinyXml: Member List

TiXmlElement Member List

This is the complete list of members for TiXmlElement, including all inherited members.
Accept(TiXmlVisitor *visitor) const TiXmlElement [virtual]
Attribute(const char *name) const TiXmlElement
Attribute(const char *name, int *i) const TiXmlElement
Attribute(const char *name, double *d) const TiXmlElement
Clear()TiXmlNode
Clone() const TiXmlElement [virtual]
Column() const TiXmlBase [inline]
EncodeString(const TIXML_STRING &str, TIXML_STRING *out)TiXmlBase [static]
FirstAttribute() const TiXmlElement [inline]
FirstChild() const TiXmlNode [inline]
FirstChild(const char *value) const TiXmlNode
FirstChild(const char *_value)TiXmlNode [inline]
FirstChild(const std::string &_value) const TiXmlNode [inline]
FirstChild(const std::string &_value)TiXmlNode [inline]
FirstChildElement() const TiXmlNode
FirstChildElement(const char *_value) const TiXmlNode
FirstChildElement(const std::string &_value) const TiXmlNode [inline]
FirstChildElement(const std::string &_value)TiXmlNode [inline]
GetDocument() const TiXmlNode
GetText() const TiXmlElement
GetUserData()TiXmlBase [inline]
GetUserData() const TiXmlBase [inline]
InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)TiXmlNode
InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)TiXmlNode
InsertEndChild(const TiXmlNode &addThis)TiXmlNode
IsWhiteSpaceCondensed()TiXmlBase [inline, static]
IterateChildren(const TiXmlNode *previous) const TiXmlNode
IterateChildren(const char *value, const TiXmlNode *previous) const TiXmlNode
IterateChildren(const std::string &_value, const TiXmlNode *previous) const TiXmlNode [inline]
IterateChildren(const std::string &_value, const TiXmlNode *previous)TiXmlNode [inline]
LastAttribute() const TiXmlElement [inline]
LastChild()TiXmlNode [inline]
LastChild(const char *_value)TiXmlNode [inline]
LastChild(const std::string &_value) const TiXmlNode [inline]
LastChild(const std::string &_value)TiXmlNode [inline]
LinkEndChild(TiXmlNode *addThis)TiXmlNode
NextSibling(const std::string &_value) const TiXmlNode [inline]
NextSibling(const std::string &_value)TiXmlNode [inline]
NextSibling() const TiXmlNode [inline]
NextSibling(const char *) const TiXmlNode
NextSiblingElement() const TiXmlNode
NextSiblingElement(const char *) const TiXmlNode
NextSiblingElement(const std::string &_value) const TiXmlNode [inline]
NextSiblingElement(const std::string &_value)TiXmlNode [inline]
NoChildren() const TiXmlNode [inline]
NodeType enum nameTiXmlNode
operator<<(std::ostream &out, const TiXmlNode &base)TiXmlNode [friend]
operator<<(std::string &out, const TiXmlNode &base)TiXmlNode [friend]
operator>>(std::istream &in, TiXmlNode &base)TiXmlNode [friend]
Parent()TiXmlNode [inline]
PreviousSibling() const TiXmlNode [inline]
PreviousSibling(const char *) const TiXmlNode
PreviousSibling(const std::string &_value) const TiXmlNode [inline]
PreviousSibling(const std::string &_value)TiXmlNode [inline]
Print(FILE *cfile, int depth) const TiXmlElement [virtual]
QueryBoolAttribute(const char *name, bool *_value) const TiXmlElement
QueryDoubleAttribute(const char *name, double *_value) const TiXmlElement
QueryFloatAttribute(const char *name, float *_value) const TiXmlElement [inline]
QueryIntAttribute(const char *name, int *_value) const TiXmlElement
QueryStringAttribute(const char *name, std::string *_value) const TiXmlElement [inline]
QueryUnsignedAttribute(const char *name, unsigned *_value) const TiXmlElement
QueryValueAttribute(const std::string &name, T *outValue) const TiXmlElement [inline]
RemoveAttribute(const char *name)TiXmlElement
RemoveAttribute(const std::string &name)TiXmlElement [inline]
RemoveChild(TiXmlNode *removeThis)TiXmlNode
ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)TiXmlNode
Row() const TiXmlBase [inline]
SetAttribute(const char *name, const char *_value)TiXmlElement
SetAttribute(const std::string &name, const std::string &_value)TiXmlElement
SetAttribute(const std::string &name, int _value)TiXmlElement
SetAttribute(const char *name, int value)TiXmlElement
SetCondenseWhiteSpace(bool condense)TiXmlBase [inline, static]
SetDoubleAttribute(const char *name, double value)TiXmlElement
SetUserData(void *user)TiXmlBase [inline]
SetValue(const char *_value)TiXmlNode [inline]
SetValue(const std::string &_value)TiXmlNode [inline]
TiXmlElement(const char *in_value)TiXmlElement
TiXmlElement(const std::string &_value)TiXmlElement
ToComment() const TiXmlNode [inline, virtual]
ToComment()TiXmlNode [inline, virtual]
ToDeclaration() const TiXmlNode [inline, virtual]
ToDeclaration()TiXmlNode [inline, virtual]
ToDocument() const TiXmlNode [inline, virtual]
ToDocument()TiXmlNode [inline, virtual]
ToElement() const TiXmlElement [inline, virtual]
ToElement()TiXmlElement [inline, virtual]
ToText() const TiXmlNode [inline, virtual]
ToText()TiXmlNode [inline, virtual]
ToUnknown() const TiXmlNode [inline, virtual]
ToUnknown()TiXmlNode [inline, virtual]
Type() const TiXmlNode [inline]
userDataTiXmlBase [protected]
Value() const TiXmlNode [inline]
ValueStr() const TiXmlNode [inline]

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlElement.html000664 000765 000024 00000101456 11563634571 021502 0ustar00leethomasonstaff000000 000000 TinyXml: TiXmlElement Class Reference

TiXmlElement Class Reference

The element is a container class. More...

#include <tinyxml.h>

Inheritance diagram for TiXmlElement:
TiXmlNode TiXmlBase

List of all members.

Public Member Functions

 TiXmlElement (const char *in_value)
 Construct an element.
 TiXmlElement (const std::string &_value)
 std::string constructor.
const char * Attribute (const char *name) const
 Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists.
const char * Attribute (const char *name, int *i) const
 Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists.
const char * Attribute (const char *name, double *d) const
 Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists.
int QueryIntAttribute (const char *name, int *_value) const
 QueryIntAttribute examines the attribute - it is an alternative to the Attribute() method with richer error checking.
int QueryUnsignedAttribute (const char *name, unsigned *_value) const
 QueryUnsignedAttribute examines the attribute - see QueryIntAttribute().
int QueryBoolAttribute (const char *name, bool *_value) const
 QueryBoolAttribute examines the attribute - see QueryIntAttribute().
int QueryDoubleAttribute (const char *name, double *_value) const
 QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
int QueryFloatAttribute (const char *name, float *_value) const
 QueryFloatAttribute examines the attribute - see QueryIntAttribute().
int QueryStringAttribute (const char *name, std::string *_value) const
 QueryStringAttribute examines the attribute - see QueryIntAttribute().
template<typename T >
int QueryValueAttribute (const std::string &name, T *outValue) const
 Template form of the attribute query which will try to read the attribute into the specified type.
void SetAttribute (const char *name, const char *_value)
 Sets an attribute of name to a given value.
void SetAttribute (const std::string &name, const std::string &_value)
void SetAttribute (const std::string &name, int _value)
 STL std::string form.
void SetAttribute (const char *name, int value)
 Sets an attribute of name to a given value.
void SetDoubleAttribute (const char *name, double value)
 Sets an attribute of name to a given value.
void RemoveAttribute (const char *name)
 Deletes an attribute with the given name.
void RemoveAttribute (const std::string &name)
 STL std::string form.
const TiXmlAttributeFirstAttribute () const
 Access the first attribute in this element.
const TiXmlAttributeLastAttribute () const
 Access the last attribute in this element.
const char * GetText () const
 Convenience function for easy access to the text inside an element.
virtual TiXmlNodeClone () const
 Creates a new Element and returns it - the returned element is a copy.
virtual void Print (FILE *cfile, int depth) const
 All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.
virtual const TiXmlElementToElement () const
 Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlElementToElement ()
 Cast to a more defined type. Will return null not of the requested type.
virtual bool Accept (TiXmlVisitor *visitor) const
 Walk the XML tree visiting this node and all of its children.

Detailed Description

The element is a container class.

It has a value, the element name, and can contain other elements, text, comments, and unknowns. Elements also contain an arbitrary number of attributes.


Member Function Documentation

const char* TiXmlElement::Attribute ( const char *  name,
double *  d 
) const

Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists.

If the attribute exists and can be converted to an double, the double value will be put in the return 'd', if 'd' is non-null.

const char* TiXmlElement::Attribute ( const char *  name,
int *  i 
) const

Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists.

If the attribute exists and can be converted to an integer, the integer value will be put in the return 'i', if 'i' is non-null.

const char* TiXmlElement::GetText (  )  const

Convenience function for easy access to the text inside an element.

Although easy and concise, GetText() is limited compared to getting the TiXmlText child and accessing it directly.

If the first child of 'this' is a TiXmlText, the GetText() returns the character string of the Text node, else null is returned.

This is a convenient method for getting the text of simple contained text:

		<foo>This is text</foo>
		const char* str = fooElement->GetText();
		

'str' will be a pointer to "This is text".

Note that this function can be misleading. If the element foo was created from this XML:

		<foo><b>This is text</b></foo> 
		

then the value of str would be null. The first child node isn't a text node, it is another element. From this XML:

		<foo>This is <b>text</b></foo> 
		

GetText() will return "This is ".

WARNING: GetText() accesses a child node - don't become confused with the similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are safe type casts on the referenced node.

virtual void TiXmlElement::Print ( FILE *  cfile,
int  depth 
) const [virtual]

All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.

) Either or both cfile and str can be null.

This is a formatted print, and will insert tabs and newlines.

(For an unformatted stream, use the << operator.)

Implements TiXmlBase.

int TiXmlElement::QueryBoolAttribute ( const char *  name,
bool *  _value 
) const

QueryBoolAttribute examines the attribute - see QueryIntAttribute().

Note that '1', 'true', or 'yes' are considered true, while '0', 'false' and 'no' are considered false.

int TiXmlElement::QueryIntAttribute ( const char *  name,
int *  _value 
) const

QueryIntAttribute examines the attribute - it is an alternative to the Attribute() method with richer error checking.

If the attribute is an integer, it is stored in 'value' and the call returns TIXML_SUCCESS. If it is not an integer, it returns TIXML_WRONG_TYPE. If the attribute does not exist, then TIXML_NO_ATTRIBUTE is returned.

template<typename T >
int TiXmlElement::QueryValueAttribute ( const std::string &  name,
T *  outValue 
) const [inline]

Template form of the attribute query which will try to read the attribute into the specified type.

Very easy, very powerful, but be careful to make sure to call this with the correct type.

NOTE: This method doesn't work correctly for 'string' types that contain spaces.

Returns:
TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE

References TiXmlAttribute::ValueStr().

void TiXmlElement::SetAttribute ( const char *  name,
int  value 
)

Sets an attribute of name to a given value.

The attribute will be created if it does not exist, or changed if it does.

void TiXmlElement::SetAttribute ( const std::string &  name,
const std::string &  _value 
)

STL std::string form.

void TiXmlElement::SetAttribute ( const char *  name,
const char *  _value 
)

Sets an attribute of name to a given value.

The attribute will be created if it does not exist, or changed if it does.

void TiXmlElement::SetDoubleAttribute ( const char *  name,
double  value 
)

Sets an attribute of name to a given value.

The attribute will be created if it does not exist, or changed if it does.


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlElement.png000664 000765 000024 00000001002 11563634571 021304 0ustar00leethomasonstaff000000 000000 ‰PNG  IHDRWˆ„~‡¤PLTE’’’’’ĄŸŸ`ĄĄĄ{Ā’ätRNS’’’’’’’ÕŹT2‘IDATxķŻŃŽ„ P[ž’“÷”--ˆ»Ąl˜ÜftŠC-Äy=Μ8NĪøĻŗ$ĮÄLŅu|/ßzull¾sĶ”CĮčjŚvī§śĶ™ˆkelЧńĘ“ėg’„ś6k°āZ¾]jVł²ÅŽ©ļÕõkÖ’éīŌwPܚȶÉē÷Žpßä&żĻ/DY¹ųūn)9p’[Jœå¾n?Ą… .\øpįJœ9qœœpuI‚‰™¤#Ž:ūÖm¾õ2źļ!f¢Ļ\3åŠDIĖ”Sh“¦\E˜HļŽ®‘·&]??ׯÅ|/ÜÕ„¾SõżŪŻ[·ÖŻØļ]qw÷Žp_å&żĻ/DY¹ųūn)9p’[Jœå¾n?Ą… .\øpįJPN”ņhpŸqĆ*jGs‘Ž·Ż7`Ÿoó£¹?x»®™r(Ų¹DĶØ·å¹n]ė$:je‚k3…Qm‡ ‡®Ÿżćõõ'čŪ¹–ows\Ā~Ź7C7žjڟ»;u·Żæ¶žU³¶-ŽpßļęÄčź$ÕßV;TIEND®B`‚tinyxml/docs/classTiXmlHandle-members.html000664 000765 000024 00000013077 11563634571 022735 0ustar00leethomasonstaff000000 000000 TinyXml: Member List

TiXmlHandle Member List

This is the complete list of members for TiXmlHandle, including all inherited members.
Child(const char *value, int index) const TiXmlHandle
Child(int index) const TiXmlHandle
ChildElement(const char *value, int index) const TiXmlHandle
ChildElement(int index) const TiXmlHandle
Element() const TiXmlHandle [inline]
FirstChild() const TiXmlHandle
FirstChild(const char *value) const TiXmlHandle
FirstChildElement() const TiXmlHandle
FirstChildElement(const char *value) const TiXmlHandle
Node() const TiXmlHandle [inline]
Text() const TiXmlHandle [inline]
TiXmlHandle(TiXmlNode *_node)TiXmlHandle [inline]
TiXmlHandle(const TiXmlHandle &ref)TiXmlHandle [inline]
ToElement() const TiXmlHandle [inline]
ToNode() const TiXmlHandle [inline]
ToText() const TiXmlHandle [inline]
ToUnknown() const TiXmlHandle [inline]
Unknown() const TiXmlHandle [inline]

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlHandle.html000664 000765 000024 00000061176 11563634571 021310 0ustar00leethomasonstaff000000 000000 TinyXml: TiXmlHandle Class Reference

TiXmlHandle Class Reference

A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thing. More...

#include <tinyxml.h>

List of all members.

Public Member Functions

 TiXmlHandle (TiXmlNode *_node)
 Create a handle from any node (at any depth of the tree.) This can be a null pointer.
 TiXmlHandle (const TiXmlHandle &ref)
 Copy constructor.
TiXmlHandle FirstChild () const
 Return a handle to the first child node.
TiXmlHandle FirstChild (const char *value) const
 Return a handle to the first child node with the given name.
TiXmlHandle FirstChildElement () const
 Return a handle to the first child element.
TiXmlHandle FirstChildElement (const char *value) const
 Return a handle to the first child element with the given name.
TiXmlHandle Child (const char *value, int index) const
 Return a handle to the "index" child with the given name.
TiXmlHandle Child (int index) const
 Return a handle to the "index" child.
TiXmlHandle ChildElement (const char *value, int index) const
 Return a handle to the "index" child element with the given name.
TiXmlHandle ChildElement (int index) const
 Return a handle to the "index" child element.
TiXmlNodeToNode () const
 Return the handle as a TiXmlNode.
TiXmlElementToElement () const
 Return the handle as a TiXmlElement.
TiXmlTextToText () const
 Return the handle as a TiXmlText.
TiXmlUnknownToUnknown () const
 Return the handle as a TiXmlUnknown.
TiXmlNodeNode () const
TiXmlElementElement () const
TiXmlTextText () const
TiXmlUnknownUnknown () const

Detailed Description

A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thing.

Note that TiXmlHandle is not part of the TinyXml DOM structure. It is a separate utility class.

Take an example:

	<Document>
		<Element attributeA = "valueA">
			<Child attributeB = "value1" />
			<Child attributeB = "value2" />
		</Element>
	<Document>
	

Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very easy to write a *lot* of code that looks like:

	TiXmlElement* root = document.FirstChildElement( "Document" );
	if ( root )
	{
		TiXmlElement* element = root->FirstChildElement( "Element" );
		if ( element )
		{
			TiXmlElement* child = element->FirstChildElement( "Child" );
			if ( child )
			{
				TiXmlElement* child2 = child->NextSiblingElement( "Child" );
				if ( child2 )
				{
					// Finally do something useful.
	

And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity of such code. A TiXmlHandle checks for null pointers so it is perfectly safe and correct to use:

	TiXmlHandle docHandle( &document );
	TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement();
	if ( child2 )
	{
		// do something useful
	

Which is MUCH more concise and useful.

It is also safe to copy handles - internally they are nothing more than node pointers.

	TiXmlHandle handleCopy = handle;
	

What they should not be used for is iteration:

	int i=0; 
	while ( true )
	{
		TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement();
		if ( !child )
			break;
		// do something
		++i;
	}
	

It seems reasonable, but it is in fact two embedded while loops. The Child method is a linear walk to find the element, so this code would iterate much more than it needs to. Instead, prefer:

	TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement();

	for( child; child; child=child->NextSiblingElement() )
	{
		// do something
	}
	

Member Function Documentation

TiXmlHandle TiXmlHandle::Child ( int  index  )  const

Return a handle to the "index" child.

The first child is 0, the second 1, etc.

TiXmlHandle TiXmlHandle::Child ( const char *  value,
int  index 
) const

Return a handle to the "index" child with the given name.

The first child is 0, the second 1, etc.

TiXmlHandle TiXmlHandle::ChildElement ( int  index  )  const

Return a handle to the "index" child element.

The first child element is 0, the second 1, etc. Note that only TiXmlElements are indexed: other types are not counted.

TiXmlHandle TiXmlHandle::ChildElement ( const char *  value,
int  index 
) const

Return a handle to the "index" child element with the given name.

The first child element is 0, the second 1, etc. Note that only TiXmlElements are indexed: other types are not counted.

TiXmlElement* TiXmlHandle::Element (  )  const [inline]
Deprecated:
use ToElement. Return the handle as a TiXmlElement. This may return null.

References ToElement().

TiXmlNode* TiXmlHandle::Node (  )  const [inline]
Deprecated:
use ToNode. Return the handle as a TiXmlNode. This may return null.

References ToNode().

TiXmlText* TiXmlHandle::Text (  )  const [inline]
Deprecated:
use ToText() Return the handle as a TiXmlText. This may return null.

References ToText().

TiXmlElement* TiXmlHandle::ToElement (  )  const [inline]

Return the handle as a TiXmlElement.

This may return null.

Referenced by Element().

TiXmlNode* TiXmlHandle::ToNode (  )  const [inline]

Return the handle as a TiXmlNode.

This may return null.

Referenced by Node().

TiXmlText* TiXmlHandle::ToText (  )  const [inline]

Return the handle as a TiXmlText.

This may return null.

Referenced by Text().

TiXmlUnknown* TiXmlHandle::ToUnknown (  )  const [inline]

Return the handle as a TiXmlUnknown.

This may return null.

Referenced by Unknown().

TiXmlUnknown* TiXmlHandle::Unknown (  )  const [inline]
Deprecated:
use ToUnknown() Return the handle as a TiXmlUnknown. This may return null.

References ToUnknown().


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlNode-members.html000664 000765 000024 00000044523 11563634571 022427 0ustar00leethomasonstaff000000 000000 TinyXml: Member List

TiXmlNode Member List

This is the complete list of members for TiXmlNode, including all inherited members.
Accept(TiXmlVisitor *visitor) const =0TiXmlNode [pure virtual]
Clear()TiXmlNode
Clone() const =0TiXmlNode [pure virtual]
Column() const TiXmlBase [inline]
EncodeString(const TIXML_STRING &str, TIXML_STRING *out)TiXmlBase [static]
FirstChild() const TiXmlNode [inline]
FirstChild(const char *value) const TiXmlNode
FirstChild(const char *_value)TiXmlNode [inline]
FirstChild(const std::string &_value) const TiXmlNode [inline]
FirstChild(const std::string &_value)TiXmlNode [inline]
FirstChildElement() const TiXmlNode
FirstChildElement(const char *_value) const TiXmlNode
FirstChildElement(const std::string &_value) const TiXmlNode [inline]
FirstChildElement(const std::string &_value)TiXmlNode [inline]
GetDocument() const TiXmlNode
GetUserData()TiXmlBase [inline]
GetUserData() const TiXmlBase [inline]
InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)TiXmlNode
InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)TiXmlNode
InsertEndChild(const TiXmlNode &addThis)TiXmlNode
IsWhiteSpaceCondensed()TiXmlBase [inline, static]
IterateChildren(const TiXmlNode *previous) const TiXmlNode
IterateChildren(const char *value, const TiXmlNode *previous) const TiXmlNode
IterateChildren(const std::string &_value, const TiXmlNode *previous) const TiXmlNode [inline]
IterateChildren(const std::string &_value, const TiXmlNode *previous)TiXmlNode [inline]
LastChild()TiXmlNode [inline]
LastChild(const char *_value)TiXmlNode [inline]
LastChild(const std::string &_value) const TiXmlNode [inline]
LastChild(const std::string &_value)TiXmlNode [inline]
LinkEndChild(TiXmlNode *addThis)TiXmlNode
NextSibling(const std::string &_value) const TiXmlNode [inline]
NextSibling(const std::string &_value)TiXmlNode [inline]
NextSibling() const TiXmlNode [inline]
NextSibling(const char *) const TiXmlNode
NextSiblingElement() const TiXmlNode
NextSiblingElement(const char *) const TiXmlNode
NextSiblingElement(const std::string &_value) const TiXmlNode [inline]
NextSiblingElement(const std::string &_value)TiXmlNode [inline]
NoChildren() const TiXmlNode [inline]
NodeType enum nameTiXmlNode
operator<<(std::ostream &out, const TiXmlNode &base)TiXmlNode [friend]
operator<<(std::string &out, const TiXmlNode &base)TiXmlNode [friend]
operator>>(std::istream &in, TiXmlNode &base)TiXmlNode [friend]
Parent()TiXmlNode [inline]
PreviousSibling() const TiXmlNode [inline]
PreviousSibling(const char *) const TiXmlNode
PreviousSibling(const std::string &_value) const TiXmlNode [inline]
PreviousSibling(const std::string &_value)TiXmlNode [inline]
Print(FILE *cfile, int depth) const =0TiXmlBase [pure virtual]
RemoveChild(TiXmlNode *removeThis)TiXmlNode
ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)TiXmlNode
Row() const TiXmlBase [inline]
SetCondenseWhiteSpace(bool condense)TiXmlBase [inline, static]
SetUserData(void *user)TiXmlBase [inline]
SetValue(const char *_value)TiXmlNode [inline]
SetValue(const std::string &_value)TiXmlNode [inline]
ToComment() const TiXmlNode [inline, virtual]
ToComment()TiXmlNode [inline, virtual]
ToDeclaration() const TiXmlNode [inline, virtual]
ToDeclaration()TiXmlNode [inline, virtual]
ToDocument() const TiXmlNode [inline, virtual]
ToDocument()TiXmlNode [inline, virtual]
ToElement() const TiXmlNode [inline, virtual]
ToElement()TiXmlNode [inline, virtual]
ToText() const TiXmlNode [inline, virtual]
ToText()TiXmlNode [inline, virtual]
ToUnknown() const TiXmlNode [inline, virtual]
ToUnknown()TiXmlNode [inline, virtual]
Type() const TiXmlNode [inline]
userDataTiXmlBase [protected]
Value() const TiXmlNode [inline]
ValueStr() const TiXmlNode [inline]

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlNode.html000664 000765 000024 00000166525 11563634571 021006 0ustar00leethomasonstaff000000 000000 TinyXml: TiXmlNode Class Reference

TiXmlNode Class Reference

The parent class for everything in the Document Object Model. More...

#include <tinyxml.h>

Inheritance diagram for TiXmlNode:
TiXmlBase TiXmlComment TiXmlDeclaration TiXmlDocument TiXmlElement TiXmlText TiXmlUnknown

List of all members.

Public Types

enum  NodeType
 

The types of XML nodes supported by TinyXml.

More...

Public Member Functions

const char * Value () const
 The meaning of 'value' changes for the specific type of TiXmlNode.
const std::string & ValueStr () const
 Return Value() as a std::string.
void SetValue (const char *_value)
 Changes the value of the node.
void SetValue (const std::string &_value)
 STL std::string form.
void Clear ()
 Delete all the children of this node. Does not affect 'this'.
TiXmlNodeParent ()
 One step up the DOM.
const TiXmlNodeFirstChild () const
 The first child of this node. Will be null if there are no children.
const TiXmlNodeFirstChild (const char *value) const
 The first child of this node with the matching 'value'.
TiXmlNodeFirstChild (const char *_value)
 The first child of this node with the matching 'value'. Will be null if none found.
TiXmlNodeLastChild ()
 The last child of this node. Will be null if there are no children.
TiXmlNodeLastChild (const char *_value)
 The last child of this node matching 'value'. Will be null if there are no children.
const TiXmlNodeFirstChild (const std::string &_value) const
 STL std::string form.
TiXmlNodeFirstChild (const std::string &_value)
 STL std::string form.
const TiXmlNodeLastChild (const std::string &_value) const
 STL std::string form.
TiXmlNodeLastChild (const std::string &_value)
 STL std::string form.
const TiXmlNodeIterateChildren (const TiXmlNode *previous) const
 An alternate way to walk the children of a node.
const TiXmlNodeIterateChildren (const char *value, const TiXmlNode *previous) const
 This flavor of IterateChildren searches for children with a particular 'value'.
const TiXmlNodeIterateChildren (const std::string &_value, const TiXmlNode *previous) const
 STL std::string form.
TiXmlNodeIterateChildren (const std::string &_value, const TiXmlNode *previous)
 STL std::string form.
TiXmlNodeInsertEndChild (const TiXmlNode &addThis)
 Add a new node related to this.
TiXmlNodeLinkEndChild (TiXmlNode *addThis)
 Add a new node related to this.
TiXmlNodeInsertBeforeChild (TiXmlNode *beforeThis, const TiXmlNode &addThis)
 Add a new node related to this.
TiXmlNodeInsertAfterChild (TiXmlNode *afterThis, const TiXmlNode &addThis)
 Add a new node related to this.
TiXmlNodeReplaceChild (TiXmlNode *replaceThis, const TiXmlNode &withThis)
 Replace a child of this node.
bool RemoveChild (TiXmlNode *removeThis)
 Delete a child of this node.
const TiXmlNodePreviousSibling () const
 Navigate to a sibling node.
const TiXmlNodePreviousSibling (const char *) const
 Navigate to a sibling node.
const TiXmlNodePreviousSibling (const std::string &_value) const
 STL std::string form.
TiXmlNodePreviousSibling (const std::string &_value)
 STL std::string form.
const TiXmlNodeNextSibling (const std::string &_value) const
 STL std::string form.
TiXmlNodeNextSibling (const std::string &_value)
 STL std::string form.
const TiXmlNodeNextSibling () const
 Navigate to a sibling node.
const TiXmlNodeNextSibling (const char *) const
 Navigate to a sibling node with the given 'value'.
const TiXmlElementNextSiblingElement () const
 Convenience function to get through elements.
const TiXmlElementNextSiblingElement (const char *) const
 Convenience function to get through elements.
const TiXmlElementNextSiblingElement (const std::string &_value) const
 STL std::string form.
TiXmlElementNextSiblingElement (const std::string &_value)
 STL std::string form.
const TiXmlElementFirstChildElement () const
 Convenience function to get through elements.
const TiXmlElementFirstChildElement (const char *_value) const
 Convenience function to get through elements.
const TiXmlElementFirstChildElement (const std::string &_value) const
 STL std::string form.
TiXmlElementFirstChildElement (const std::string &_value)
 STL std::string form.
int Type () const
 Query the type (as an enumerated value, above) of this node.
const TiXmlDocumentGetDocument () const
 Return a pointer to the Document this node lives in.
bool NoChildren () const
 Returns true if this node has no children.
virtual const TiXmlDocumentToDocument () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlElementToElement () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlCommentToComment () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlUnknownToUnknown () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlTextToText () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlDeclarationToDeclaration () const
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlDocumentToDocument ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlElementToElement ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlCommentToComment ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlUnknownToUnknown ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlTextToText ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlDeclarationToDeclaration ()
 Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlNodeClone () const =0
 Create an exact duplicate of this node and return it.
virtual bool Accept (TiXmlVisitor *visitor) const =0
 Accept a hierchical visit the nodes in the TinyXML DOM.

Friends

class TiXmlDocument
class TiXmlElement
std::istream & operator>> (std::istream &in, TiXmlNode &base)
 An input stream operator, for every class.
std::ostream & operator<< (std::ostream &out, const TiXmlNode &base)
 An output stream operator, for every class.
std::string & operator<< (std::string &out, const TiXmlNode &base)
 Appends the XML node or attribute to a std::string.

Detailed Description

The parent class for everything in the Document Object Model.

(Except for attributes). Nodes have siblings, a parent, and children. A node can be in a document, or stand on its own. The type of a TiXmlNode can be queried, and it can be cast to its more defined type.


Member Enumeration Documentation

The types of XML nodes supported by TinyXml.

(All the unsupported types are picked up by UNKNOWN.)


Member Function Documentation

virtual bool TiXmlNode::Accept ( TiXmlVisitor visitor  )  const [pure virtual]

Accept a hierchical visit the nodes in the TinyXML DOM.

Every node in the XML tree will be conditionally visited and the host will be called back via the TiXmlVisitor interface.

This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse the XML for the callbacks, so the performance of TinyXML is unchanged by using this interface versus any other.)

The interface has been based on ideas from:

Which are both good references for "visiting".

An example of using Accept():

		TiXmlPrinter printer;
		tinyxmlDoc.Accept( &printer );
		const char* xmlcstr = printer.CStr();
		

Implemented in TiXmlElement, TiXmlComment, TiXmlText, TiXmlDeclaration, TiXmlUnknown, and TiXmlDocument.

virtual TiXmlNode* TiXmlNode::Clone (  )  const [pure virtual]

Create an exact duplicate of this node and return it.

The memory must be deleted by the caller.

Implemented in TiXmlElement, TiXmlComment, TiXmlText, TiXmlDeclaration, TiXmlUnknown, and TiXmlDocument.

const TiXmlNode* TiXmlNode::FirstChild ( const char *  value  )  const

The first child of this node with the matching 'value'.

Will be null if none found.

const TiXmlDocument* TiXmlNode::GetDocument (  )  const

Return a pointer to the Document this node lives in.

Returns null if not in a document.

TiXmlNode* TiXmlNode::InsertAfterChild ( TiXmlNode afterThis,
const TiXmlNode addThis 
)

Add a new node related to this.

Adds a child after the specified child. Returns a pointer to the new object or NULL if an error occured.

TiXmlNode* TiXmlNode::InsertBeforeChild ( TiXmlNode beforeThis,
const TiXmlNode addThis 
)

Add a new node related to this.

Adds a child before the specified child. Returns a pointer to the new object or NULL if an error occured.

TiXmlNode* TiXmlNode::InsertEndChild ( const TiXmlNode addThis  ) 

Add a new node related to this.

Adds a child past the LastChild. Returns a pointer to the new object or NULL if an error occured.

const TiXmlNode* TiXmlNode::IterateChildren ( const TiXmlNode previous  )  const

An alternate way to walk the children of a node.

One way to iterate over nodes is:

			for( child = parent->FirstChild(); child; child = child->NextSibling() )
		

IterateChildren does the same thing with the syntax:

			child = 0;
			while( child = parent->IterateChildren( child ) )
		

IterateChildren takes the previous child as input and finds the next one. If the previous child is null, it returns the first. IterateChildren will return null when done.

TiXmlNode* TiXmlNode::LinkEndChild ( TiXmlNode addThis  ) 

Add a new node related to this.

Adds a child past the LastChild.

NOTE: the node to be added is passed by pointer, and will be henceforth owned (and deleted) by tinyXml. This method is efficient and avoids an extra copy, but should be used with care as it uses a different memory model than the other insert functions.

See also:
InsertEndChild
const TiXmlElement* TiXmlNode::NextSiblingElement ( const char *   )  const

Convenience function to get through elements.

Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element.

const TiXmlElement* TiXmlNode::NextSiblingElement (  )  const

Convenience function to get through elements.

Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element.

TiXmlNode* TiXmlNode::ReplaceChild ( TiXmlNode replaceThis,
const TiXmlNode withThis 
)

Replace a child of this node.

Returns a pointer to the new object or NULL if an error occured.

void TiXmlNode::SetValue ( const char *  _value  )  [inline]

Changes the value of the node.

Defined as:

		Document:	filename of the xml file
		Element:	name of the element
		Comment:	the comment text
		Unknown:	the tag contents
		Text:		the text string
		

Referenced by TiXmlComment::TiXmlComment(), and TiXmlText::TiXmlText().

int TiXmlNode::Type (  )  const [inline]

Query the type (as an enumerated value, above) of this node.

The possible types are: TINYXML_DOCUMENT, TINYXML_ELEMENT, TINYXML_COMMENT, TINYXML_UNKNOWN, TINYXML_TEXT, and TINYXML_DECLARATION.

const char* TiXmlNode::Value (  )  const [inline]

The meaning of 'value' changes for the specific type of TiXmlNode.

		Document:	filename of the xml file
		Element:	name of the element
		Comment:	the comment text
		Unknown:	the tag contents
		Text:		the text string
		

The subclasses will wrap this function.

const std::string& TiXmlNode::ValueStr (  )  const [inline]

Return Value() as a std::string.

If you only use STL, this is more efficient than calling Value(). Only available in STL mode.


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const TiXmlNode base 
) [friend]

An output stream operator, for every class.

Note that this outputs without any newlines or formatting, as opposed to Print(), which includes tabs and new lines.

The operator<< and operator>> are not completely symmetric. Writing a node to a stream is very well defined. You'll get a nice stream of output, without any extra whitespace or newlines.

But reading is not as well defined. (As it always is.) If you create a TiXmlElement (for example) and read that from an input stream, the text needs to define an element or junk will result. This is true of all input streams, but it's worth keeping in mind.

A TiXmlDocument will read nodes until it reads a root element, and all the children of that root element.

std::istream& operator>> ( std::istream &  in,
TiXmlNode base 
) [friend]

An input stream operator, for every class.

Tolerant of newlines and formatting, but doesn't expect them.


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlNode.png000664 000765 000024 00000002427 11563634571 020614 0ustar00leethomasonstaff000000 000000 ‰PNG  IHDRŗˆ?ø¤PLTE’’’’’ĄŸŸ`ĄĄĄ{Ā’ätRNS’’’’’’’ÕŹT2¦IDATxķŻŪr£0Q‹Tł’?y„.€ a’Õe#5‡×ŗųŗÕʕź·A]P .ØK]P8Ænˆ aBØŽĒ©‹GvŻlf˜™›}>ę.uq§ŗIŪøĪÖźŽĶ7}oŲL]Ü­ntvBBŅ7,&—źā)ź–ļņ „Ć&“©‹§vŻYƒŖF…ĒÆā3uńóźVŪBŻŅhsļ„.ž#uĖ ®‹ĒØ[7Õņ !ÄBˆūi‡ŗųiuƆŗ .@]P—ŗ .@]P—ŗ .p…ŗ7¢ŚųqŽJź7šūę.Ø Üi.wA]ąNy•ŌØ PŌØ PŌØ P .Ø P .Ø P .@]P .@]P .@]€ŗ .šįFTWŖū+£@]ꂺŌuźā·©"ÆĪØĻkī«I]ÜÓ ó‘0?-¼^!PV7i·±Ż†ńwÜF‹Ē‘øG]–Õ±|+é@ģ]źnĒ…|Õ|ń20¶©ųUÄü}uĻ$wͶCݽ"Of³_Żćź®Ż@ž~īżŪļ =u7'ĖYFŅŹåšō_ó;ŲP7¦ CCnśó‡Ø«N÷—ošMu×ć¦s-GāŅĪF§ł]źKīœm§ŗ[E>”wVŻÖ L[Ė:¦īźDėéT+š5Oæ6­‡MÖoEŻÖ§Ł„÷Õ][\®ś3]ęE~ŸŗĒ’ūfŪ«n+;Ä&×x*·Ŗ{RŻĘ Ģ›åāeFݵ"OČv—š.聮{LŻ\ö³]·)P¹jy“–×[µŅgŌŻLŽVwu¶G»n£Č“ėļW÷Ć®ŪP7Õųu×&śźVŪĮ®;½Nu×ćZķvöuŻŻäķ®Ūžm§ŗ[Ež\æŗēŌm°n–ó•?©īźDėOOJcįu—i-uOuŻ­¹5ÅļW·Ü7ŪėŌķ­ī·Ø›{å-ź6p¾õØ[÷:)¾D†ü¾^T6æ_ņ; GŻf\ze„«Öłaǁi~ŗG’ĒŽŁö©»ž=æž~uO©»¶ŹeźIŻ w;ŌmēŒEžŲZ/šAuæ‘īĀJ•Ś‘Ŗ°R©«°R©+U*u„RWa„RWŖTźJż»źŽH5E©R?äų5£¬,nIEND®B`‚tinyxml/docs/classTiXmlPrinter-members.html000664 000765 000024 00000012613 11563634571 023160 0ustar00leethomasonstaff000000 000000 TinyXml: Member List

TiXmlPrinter Member List

This is the complete list of members for TiXmlPrinter, including all inherited members.
CStr()TiXmlPrinter [inline]
Indent()TiXmlPrinter [inline]
LineBreak()TiXmlPrinter [inline]
SetIndent(const char *_indent)TiXmlPrinter [inline]
SetLineBreak(const char *_lineBreak)TiXmlPrinter [inline]
SetStreamPrinting()TiXmlPrinter [inline]
Size()TiXmlPrinter [inline]
Str()TiXmlPrinter [inline]
Visit(const TiXmlDeclaration &declaration)TiXmlPrinter [virtual]
Visit(const TiXmlText &text)TiXmlPrinter [virtual]
Visit(const TiXmlComment &comment)TiXmlPrinter [virtual]
Visit(const TiXmlUnknown &unknown)TiXmlPrinter [virtual]
VisitEnter(const TiXmlDocument &doc)TiXmlPrinter [virtual]
VisitEnter(const TiXmlElement &element, const TiXmlAttribute *firstAttribute)TiXmlPrinter [virtual]
VisitExit(const TiXmlDocument &doc)TiXmlPrinter [virtual]
VisitExit(const TiXmlElement &element)TiXmlPrinter [virtual]

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlPrinter.html000664 000765 000024 00000034535 11563634571 021537 0ustar00leethomasonstaff000000 000000 TinyXml: TiXmlPrinter Class Reference

TiXmlPrinter Class Reference

Print to memory functionality. More...

#include <tinyxml.h>

Inheritance diagram for TiXmlPrinter:
TiXmlVisitor

List of all members.

Public Member Functions

virtual bool VisitEnter (const TiXmlDocument &doc)
 Visit a document.
virtual bool VisitExit (const TiXmlDocument &doc)
 Visit a document.
virtual bool VisitEnter (const TiXmlElement &element, const TiXmlAttribute *firstAttribute)
 Visit an element.
virtual bool VisitExit (const TiXmlElement &element)
 Visit an element.
virtual bool Visit (const TiXmlDeclaration &declaration)
 Visit a declaration.
virtual bool Visit (const TiXmlText &text)
 Visit a text node.
virtual bool Visit (const TiXmlComment &comment)
 Visit a comment node.
virtual bool Visit (const TiXmlUnknown &unknown)
 Visit an unknown node.
void SetIndent (const char *_indent)
 Set the indent characters for printing.
const char * Indent ()
 Query the indention string.
void SetLineBreak (const char *_lineBreak)
 Set the line breaking string.
const char * LineBreak ()
 Query the current line breaking string.
void SetStreamPrinting ()
 Switch over to "stream printing" which is the most dense formatting without linebreaks.
const char * CStr ()
 Return the result.
size_t Size ()
 Return the length of the result string.
const std::string & Str ()
 Return the result.

Detailed Description

Print to memory functionality.

The TiXmlPrinter is useful when you need to:

  1. Print to memory (especially in non-STL mode)
  2. Control formatting (line endings, etc.)

When constructed, the TiXmlPrinter is in its default "pretty printing" mode. Before calling Accept() you can call methods to control the printing of the XML document. After TiXmlNode::Accept() is called, the printed document can be accessed via the CStr(), Str(), and Size() methods.

TiXmlPrinter uses the Visitor API.

	TiXmlPrinter printer;
	printer.SetIndent( "\t" );

	doc.Accept( &printer );
	fprintf( stdout, "%s", printer.CStr() );
	

Member Function Documentation

void TiXmlPrinter::SetIndent ( const char *  _indent  )  [inline]

Set the indent characters for printing.

By default 4 spaces but tab () is also useful, or null/empty string for no indentation.

void TiXmlPrinter::SetLineBreak ( const char *  _lineBreak  )  [inline]

Set the line breaking string.

By default set to newline (
). Some operating systems prefer other characters, or can be set to the null/empty string for no indenation.

void TiXmlPrinter::SetStreamPrinting (  )  [inline]

Switch over to "stream printing" which is the most dense formatting without linebreaks.

Common when the XML is needed for network transmission.


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlPrinter.png000664 000765 000024 00000000574 11563634571 021353 0ustar00leethomasonstaff000000 000000 ‰PNG  IHDRQPV i”PLTE’’’’’ĄŸŸ`ĄĄĄ{Ā’ätRNS’’’’’’’ÕŹT2 IDATxķŻ !…³Ž’‘÷B­cŁl ĀĢ‚RQfŸ s[®h)W•$‰„R­Ä °Be×ć~#ŚZc×Ķzō‰Jć)ØeŹ-QåEl·D½&Ŗ£0§1œģ‰¦j.om•īcÄg Ō¬Ļ‰^‚†ø ’W¢Ć:%ŗ/M‰{ÖŲėü®“ųNbųßõTڱåcÄÖ¢‘įÄÖ¢‘ńÄæču“˜Ä$&1‰I|HŃR(8—$Ę”O¢0F|ēeēÅh6ĘTݬļˆJć)($’Ŗ‰#—²uˆŖ$*½ƒ(ē®īžäĒ:†Öbžˆ7Y÷ķ0E¢ųŗ#Ā TinyXml: Member List

TiXmlText Member List

This is the complete list of members for TiXmlText, including all inherited members.
Accept(TiXmlVisitor *content) const TiXmlText [virtual]
CDATA() const TiXmlText [inline]
Clear()TiXmlNode
Clone() const TiXmlText [protected, virtual]
Column() const TiXmlBase [inline]
EncodeString(const TIXML_STRING &str, TIXML_STRING *out)TiXmlBase [static]
FirstChild() const TiXmlNode [inline]
FirstChild(const char *value) const TiXmlNode
FirstChild(const char *_value)TiXmlNode [inline]
FirstChild(const std::string &_value) const TiXmlNode [inline]
FirstChild(const std::string &_value)TiXmlNode [inline]
FirstChildElement() const TiXmlNode
FirstChildElement(const char *_value) const TiXmlNode
FirstChildElement(const std::string &_value) const TiXmlNode [inline]
FirstChildElement(const std::string &_value)TiXmlNode [inline]
GetDocument() const TiXmlNode
GetUserData()TiXmlBase [inline]
GetUserData() const TiXmlBase [inline]
InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)TiXmlNode
InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)TiXmlNode
InsertEndChild(const TiXmlNode &addThis)TiXmlNode
IsWhiteSpaceCondensed()TiXmlBase [inline, static]
IterateChildren(const TiXmlNode *previous) const TiXmlNode
IterateChildren(const char *value, const TiXmlNode *previous) const TiXmlNode
IterateChildren(const std::string &_value, const TiXmlNode *previous) const TiXmlNode [inline]
IterateChildren(const std::string &_value, const TiXmlNode *previous)TiXmlNode [inline]
LastChild()TiXmlNode [inline]
LastChild(const char *_value)TiXmlNode [inline]
LastChild(const std::string &_value) const TiXmlNode [inline]
LastChild(const std::string &_value)TiXmlNode [inline]
LinkEndChild(TiXmlNode *addThis)TiXmlNode
NextSibling(const std::string &_value) const TiXmlNode [inline]
NextSibling(const std::string &_value)TiXmlNode [inline]
NextSibling() const TiXmlNode [inline]
NextSibling(const char *) const TiXmlNode
NextSiblingElement() const TiXmlNode
NextSiblingElement(const char *) const TiXmlNode
NextSiblingElement(const std::string &_value) const TiXmlNode [inline]
NextSiblingElement(const std::string &_value)TiXmlNode [inline]
NoChildren() const TiXmlNode [inline]
NodeType enum nameTiXmlNode
operator<<(std::ostream &out, const TiXmlNode &base)TiXmlNode [friend]
operator<<(std::string &out, const TiXmlNode &base)TiXmlNode [friend]
operator>>(std::istream &in, TiXmlNode &base)TiXmlNode [friend]
Parent()TiXmlNode [inline]
PreviousSibling() const TiXmlNode [inline]
PreviousSibling(const char *) const TiXmlNode
PreviousSibling(const std::string &_value) const TiXmlNode [inline]
PreviousSibling(const std::string &_value)TiXmlNode [inline]
Print(FILE *cfile, int depth) const TiXmlText [virtual]
RemoveChild(TiXmlNode *removeThis)TiXmlNode
ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)TiXmlNode
Row() const TiXmlBase [inline]
SetCDATA(bool _cdata)TiXmlText [inline]
SetCondenseWhiteSpace(bool condense)TiXmlBase [inline, static]
SetUserData(void *user)TiXmlBase [inline]
SetValue(const char *_value)TiXmlNode [inline]
SetValue(const std::string &_value)TiXmlNode [inline]
TiXmlText(const char *initValue)TiXmlText [inline]
TiXmlText(const std::string &initValue)TiXmlText [inline]
ToComment() const TiXmlNode [inline, virtual]
ToComment()TiXmlNode [inline, virtual]
ToDeclaration() const TiXmlNode [inline, virtual]
ToDeclaration()TiXmlNode [inline, virtual]
ToDocument() const TiXmlNode [inline, virtual]
ToDocument()TiXmlNode [inline, virtual]
ToElement() const TiXmlNode [inline, virtual]
ToElement()TiXmlNode [inline, virtual]
ToText() const TiXmlText [inline, virtual]
ToText()TiXmlText [inline, virtual]
ToUnknown() const TiXmlNode [inline, virtual]
ToUnknown()TiXmlNode [inline, virtual]
Type() const TiXmlNode [inline]
userDataTiXmlBase [protected]
Value() const TiXmlNode [inline]
ValueStr() const TiXmlNode [inline]

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlText.html000664 000765 000024 00000024506 11563634571 021035 0ustar00leethomasonstaff000000 000000 TinyXml: TiXmlText Class Reference

TiXmlText Class Reference

XML text. More...

#include <tinyxml.h>

Inheritance diagram for TiXmlText:
TiXmlNode TiXmlBase

List of all members.

Public Member Functions

 TiXmlText (const char *initValue)
 Constructor for text element.
 TiXmlText (const std::string &initValue)
 Constructor.
virtual void Print (FILE *cfile, int depth) const
 All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.
bool CDATA () const
 Queries whether this represents text using a CDATA section.
void SetCDATA (bool _cdata)
 Turns on or off a CDATA representation of text.
virtual const TiXmlTextToText () const
 Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlTextToText ()
 Cast to a more defined type. Will return null not of the requested type.
virtual bool Accept (TiXmlVisitor *content) const
 Walk the XML tree visiting this node and all of its children.

Protected Member Functions

virtual TiXmlNodeClone () const
 [internal use] Creates a new Element and returns it.

Friends

class TiXmlElement

Detailed Description

XML text.

A text node can have 2 ways to output the next. "normal" output and CDATA. It will default to the mode it was parsed from the XML file and you generally want to leave it alone, but you can change the output mode with SetCDATA() and query it with CDATA().


Constructor & Destructor Documentation

TiXmlText::TiXmlText ( const char *  initValue  )  [inline]

Constructor for text element.

By default, it is treated as normal, encoded text. If you want it be output as a CDATA text element, set the parameter _cdata to 'true'

References TiXmlNode::SetValue().


Member Function Documentation

virtual void TiXmlText::Print ( FILE *  cfile,
int  depth 
) const [virtual]

All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.

) Either or both cfile and str can be null.

This is a formatted print, and will insert tabs and newlines.

(For an unformatted stream, use the << operator.)

Implements TiXmlBase.


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlText.png000664 000765 000024 00000000745 11563634571 020654 0ustar00leethomasonstaff000000 000000 ‰PNG  IHDRIˆœ6’PLTE’’’’’ĄŸŸ`ĄĄĄ{Ā’ätRNS’’’’’’’ÕŹT2tIDATxķŻŻ®„ `§&¼’#Ÿ‹؀€Łīɚ ]~ü,e·ĒUŽSb „‡“D nl|7¦2 TųÕIYŃj„—,“|.ųPRB²Ž3[yŗKŅžŽń ¦!…}„^ś5O)Š “RŠ¢ā¤ŸÜ;J”(Q¢Déõ¢Ź ø)=–ÜhŸŹpsūMLUm mōįĻ„¬hµäØ/1ŽH¹8ÜzżƒŹ±’źŁŻr ¹ÉĄ*¦dkŚ”\ÅäG>“JÄK©OŅxļt‰|ƒ)}EŠ*¾¹$ūIEND®B`‚tinyxml/docs/classTiXmlUnknown-members.html000664 000765 000024 00000044564 11563634571 023206 0ustar00leethomasonstaff000000 000000 TinyXml: Member List

TiXmlUnknown Member List

This is the complete list of members for TiXmlUnknown, including all inherited members.
Accept(TiXmlVisitor *content) const TiXmlUnknown [virtual]
Clear()TiXmlNode
Clone() const TiXmlUnknown [virtual]
Column() const TiXmlBase [inline]
EncodeString(const TIXML_STRING &str, TIXML_STRING *out)TiXmlBase [static]
FirstChild() const TiXmlNode [inline]
FirstChild(const char *value) const TiXmlNode
FirstChild(const char *_value)TiXmlNode [inline]
FirstChild(const std::string &_value) const TiXmlNode [inline]
FirstChild(const std::string &_value)TiXmlNode [inline]
FirstChildElement() const TiXmlNode
FirstChildElement(const char *_value) const TiXmlNode
FirstChildElement(const std::string &_value) const TiXmlNode [inline]
FirstChildElement(const std::string &_value)TiXmlNode [inline]
GetDocument() const TiXmlNode
GetUserData()TiXmlBase [inline]
GetUserData() const TiXmlBase [inline]
InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)TiXmlNode
InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)TiXmlNode
InsertEndChild(const TiXmlNode &addThis)TiXmlNode
IsWhiteSpaceCondensed()TiXmlBase [inline, static]
IterateChildren(const TiXmlNode *previous) const TiXmlNode
IterateChildren(const char *value, const TiXmlNode *previous) const TiXmlNode
IterateChildren(const std::string &_value, const TiXmlNode *previous) const TiXmlNode [inline]
IterateChildren(const std::string &_value, const TiXmlNode *previous)TiXmlNode [inline]
LastChild()TiXmlNode [inline]
LastChild(const char *_value)TiXmlNode [inline]
LastChild(const std::string &_value) const TiXmlNode [inline]
LastChild(const std::string &_value)TiXmlNode [inline]
LinkEndChild(TiXmlNode *addThis)TiXmlNode
NextSibling(const std::string &_value) const TiXmlNode [inline]
NextSibling(const std::string &_value)TiXmlNode [inline]
NextSibling() const TiXmlNode [inline]
NextSibling(const char *) const TiXmlNode
NextSiblingElement() const TiXmlNode
NextSiblingElement(const char *) const TiXmlNode
NextSiblingElement(const std::string &_value) const TiXmlNode [inline]
NextSiblingElement(const std::string &_value)TiXmlNode [inline]
NoChildren() const TiXmlNode [inline]
NodeType enum nameTiXmlNode
operator<<(std::ostream &out, const TiXmlNode &base)TiXmlNode [friend]
operator<<(std::string &out, const TiXmlNode &base)TiXmlNode [friend]
operator>>(std::istream &in, TiXmlNode &base)TiXmlNode [friend]
Parent()TiXmlNode [inline]
PreviousSibling() const TiXmlNode [inline]
PreviousSibling(const char *) const TiXmlNode
PreviousSibling(const std::string &_value) const TiXmlNode [inline]
PreviousSibling(const std::string &_value)TiXmlNode [inline]
Print(FILE *cfile, int depth) const TiXmlUnknown [virtual]
RemoveChild(TiXmlNode *removeThis)TiXmlNode
ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)TiXmlNode
Row() const TiXmlBase [inline]
SetCondenseWhiteSpace(bool condense)TiXmlBase [inline, static]
SetUserData(void *user)TiXmlBase [inline]
SetValue(const char *_value)TiXmlNode [inline]
SetValue(const std::string &_value)TiXmlNode [inline]
ToComment() const TiXmlNode [inline, virtual]
ToComment()TiXmlNode [inline, virtual]
ToDeclaration() const TiXmlNode [inline, virtual]
ToDeclaration()TiXmlNode [inline, virtual]
ToDocument() const TiXmlNode [inline, virtual]
ToDocument()TiXmlNode [inline, virtual]
ToElement() const TiXmlNode [inline, virtual]
ToElement()TiXmlNode [inline, virtual]
ToText() const TiXmlNode [inline, virtual]
ToText()TiXmlNode [inline, virtual]
ToUnknown() const TiXmlUnknown [inline, virtual]
ToUnknown()TiXmlUnknown [inline, virtual]
Type() const TiXmlNode [inline]
userDataTiXmlBase [protected]
Value() const TiXmlNode [inline]
ValueStr() const TiXmlNode [inline]

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlUnknown.html000664 000765 000024 00000015545 11563634571 021553 0ustar00leethomasonstaff000000 000000 TinyXml: TiXmlUnknown Class Reference

TiXmlUnknown Class Reference

Any tag that tinyXml doesn't recognize is saved as an unknown. More...

#include <tinyxml.h>

Inheritance diagram for TiXmlUnknown:
TiXmlNode TiXmlBase

List of all members.

Public Member Functions

virtual TiXmlNodeClone () const
 Creates a copy of this Unknown and returns it.
virtual void Print (FILE *cfile, int depth) const
 All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.
virtual const TiXmlUnknownToUnknown () const
 Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlUnknownToUnknown ()
 Cast to a more defined type. Will return null not of the requested type.
virtual bool Accept (TiXmlVisitor *content) const
 Walk the XML tree visiting this node and all of its children.

Detailed Description

Any tag that tinyXml doesn't recognize is saved as an unknown.

It is a tag of text, but should not be modified. It will be written back to the XML, unchanged, when the file is saved.

DTD tags get thrown into TiXmlUnknowns.


Member Function Documentation

virtual void TiXmlUnknown::Print ( FILE *  cfile,
int  depth 
) const [virtual]

All TinyXml classes can print themselves to a filestream or the string class (TiXmlString in non-STL mode, std::string in STL mode.

) Either or both cfile and str can be null.

This is a formatted print, and will insert tabs and newlines.

(For an unformatted stream, use the << operator.)

Implements TiXmlBase.


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlUnknown.png000664 000765 000024 00000001011 11563634571 021352 0ustar00leethomasonstaff000000 000000 ‰PNG  IHDR^ˆYk¬nPLTE’’’’’ĄŸŸ`ĄĄĄ{Ā’ätRNS’’’’’’’ÕŹT2˜IDATxķŻŃ®ƒ `žššž|.JiAœ2ÖŻŚ ˆŸ]a^§Ķ5ŅFŽü­xpˆĄöb¹¾”}½^ŸyŃĮ Ķ­ø–/?BŽ£'žšģTĖ%õiŚ™åõØSūf}Žą%ū.Q)Ÿd?,Ō~ĻkĀõ78š µŽŌAžÓ;'Ž9Į=ļi2ņģ wāsvõ}łœ]}gžį;'ųąƒ>ųąƒž9üęi#ĒžN<8Dą{q4Ų÷Ī²Æ³Ńß "ą#¼ŠÜJŚ(ß¹•'•īĶšÅ"  –ד7ĒėqųٟŽĖ~§īyŒŖsµöēüŅҶ¼­öūµ?*üāΉwNšßĻ»FšŒ<{Ɲųœ]}_>gWߙųĪ >ųąƒ>ųąƒ×Hšü­Į’?oŗ 4“ø«cWs2Ł7_šū?Ē Ķ­ø†G‚Ž”NtbB>ąeHµ\•Æ0OŠ _+<ęõh?†’¬Ū1;÷/Łūš¦ņŻ$³ĖµÄwĖ>jc~\x@¶Ģ`5›ZšńĪ ž—x×ų1%'Ÿ¹~ IEND®B`‚tinyxml/docs/classTiXmlVisitor-members.html000664 000765 000024 00000007073 11563634571 023200 0ustar00leethomasonstaff000000 000000 TinyXml: Member List

TiXmlVisitor Member List

This is the complete list of members for TiXmlVisitor, including all inherited members.
Visit(const TiXmlDeclaration &)TiXmlVisitor [inline, virtual]
Visit(const TiXmlText &)TiXmlVisitor [inline, virtual]
Visit(const TiXmlComment &)TiXmlVisitor [inline, virtual]
Visit(const TiXmlUnknown &)TiXmlVisitor [inline, virtual]
VisitEnter(const TiXmlDocument &)TiXmlVisitor [inline, virtual]
VisitEnter(const TiXmlElement &, const TiXmlAttribute *)TiXmlVisitor [inline, virtual]
VisitExit(const TiXmlDocument &)TiXmlVisitor [inline, virtual]
VisitExit(const TiXmlElement &)TiXmlVisitor [inline, virtual]

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlVisitor.html000664 000765 000024 00000020515 11563634571 021544 0ustar00leethomasonstaff000000 000000 TinyXml: TiXmlVisitor Class Reference

TiXmlVisitor Class Reference

Implements the interface to the "Visitor pattern" (see the Accept() method. More...

#include <tinyxml.h>

Inheritance diagram for TiXmlVisitor:
TiXmlPrinter

List of all members.

Public Member Functions

virtual bool VisitEnter (const TiXmlDocument &)
 Visit a document.
virtual bool VisitExit (const TiXmlDocument &)
 Visit a document.
virtual bool VisitEnter (const TiXmlElement &, const TiXmlAttribute *)
 Visit an element.
virtual bool VisitExit (const TiXmlElement &)
 Visit an element.
virtual bool Visit (const TiXmlDeclaration &)
 Visit a declaration.
virtual bool Visit (const TiXmlText &)
 Visit a text node.
virtual bool Visit (const TiXmlComment &)
 Visit a comment node.
virtual bool Visit (const TiXmlUnknown &)
 Visit an unknown node.

Detailed Description

Implements the interface to the "Visitor pattern" (see the Accept() method.

) If you call the Accept() method, it requires being passed a TiXmlVisitor class to handle callbacks. For nodes that contain other nodes (Document, Element) you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves are simply called with Visit().

If you return 'true' from a Visit method, recursive parsing will continue. If you return false, no children of this node or its sibilings will be Visited.

All flavors of Visit methods have a default implementation that returns 'true' (continue visiting). You need to only override methods that are interesting to you.

Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting.

You should never change the document from a callback.

See also:
TiXmlNode::Accept()

The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2
tinyxml/docs/classTiXmlVisitor.png000664 000765 000024 00000000602 11563634571 021357 0ustar00leethomasonstaff000000 000000 ‰PNG  IHDRQPV i”PLTE’’’’’ĄŸŸ`ĄĄĄ{Ā’ätRNS’’’’’’’ÕŹT2IDATxķŻŖÄ „ ¾’#Ÿ ŌŲu!Ėć—?¤·ŃRPb%‰ĮDjT×°'V=obd[kģŗY·>Qi} j™r ”¾p²Qµ@™u yÓɞhŖęłŌVé9F¾FJĶśœč%hˆ›šß%:¬S¢{ӔxdͽĪwÄß$†’]O„ēņbkŃČpbkŃČxāæču“˜Ä$&1‰Iü"ń:”vjX®+IŒ%¢KE­č 2‚œÓ~łņb4Œ©ŗYļ•Ö§ ˜U£G.‹XoˆzŌQ‡I”żP’ÆKœėZGŠłF|ČzÄh‡)2Åבę ńÖ¤ā‹"ī‰Üė|×IüIb“üż•ĶF™ˆIEND®B`‚tinyxml/docs/deprecated.html000664 000765 000024 00000005076 11563634571 020206 0ustar00leethomasonstaff000000 000000 TinyXml: Deprecated List

Deprecated List

Member TiXmlHandle::Element () const
use ToElement. Return the handle as a TiXmlElement. This may return null.

Member TiXmlHandle::Node () const
use ToNode. Return the handle as a TiXmlNode. This may return null.

Member TiXmlHandle::Text () const
use ToText() Return the handle as a TiXmlText. This may return null.

Member TiXmlHandle::Unknown () const
use ToUnknown() Return the handle as a TiXmlUnknown. This may return null.

Generated by  doxygen 1.6.2
tinyxml/docs/doxygen.css000664 000765 000024 00000015733 11563634571 017410 0ustar00leethomasonstaff000000 000000 /* The standard CSS for doxygen */ body, table, div, p, dl { font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; font-size: 12px; } /* @group Heading Levels */ h1 { text-align: center; font-size: 150%; } h2 { font-size: 120%; } h3 { font-size: 100%; } dt { font-weight: bold; } div.multicol { -moz-column-gap: 1em; -webkit-column-gap: 1em; -moz-column-count: 3; -webkit-column-count: 3; } p.startli, p.startdd, p.starttd { margin-top: 2px; } p.endli { margin-bottom: 0px; } p.enddd { margin-bottom: 4px; } p.endtd { margin-bottom: 2px; } /* @end */ caption { font-weight: bold; } span.legend { font-size: 70%; text-align: center; } h3.version { font-size: 90%; text-align: center; } div.qindex, div.navtab{ background-color: #e8eef2; border: 1px solid #84b0c7; text-align: center; margin: 2px; padding: 2px; } div.qindex, div.navpath { width: 100%; line-height: 140%; } div.navtab { margin-right: 15px; } /* @group Link Styling */ a { color: #153788; font-weight: normal; text-decoration: none; } .contents a:visited { color: #1b77c5; } a:hover { text-decoration: underline; } a.qindex { font-weight: bold; } a.qindexHL { font-weight: bold; background-color: #6666cc; color: #ffffff; border: 1px double #9295C2; } .contents a.qindexHL:visited { color: #ffffff; } a.el { font-weight: bold; } a.elRef { } a.code { color: #3030f0; } a.codeRef { color: #3030f0; } /* @end */ dl.el { margin-left: -1cm; } .fragment { font-family: monospace, fixed; font-size: 105%; } pre.fragment { border: 1px solid #CCCCCC; background-color: #f5f5f5; padding: 4px 6px; margin: 4px 8px 4px 2px; overflow: auto; word-wrap: break-word; font-size: 9pt; line-height: 125%; } div.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px } div.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold; } div.groupText { margin-left: 16px; font-style: italic; } body { background: white; color: black; margin-right: 20px; margin-left: 20px; } td.indexkey { background-color: #e8eef2; font-weight: bold; border: 1px solid #CCCCCC; margin: 2px 0px 2px 0; padding: 2px 10px; } td.indexvalue { background-color: #e8eef2; border: 1px solid #CCCCCC; padding: 2px 10px; margin: 2px 0px; } tr.memlist { background-color: #f0f0f0; } p.formulaDsp { text-align: center; } img.formulaDsp { } img.formulaInl { vertical-align: middle; } div.center { text-align: center; margin-top: 0px; margin-bottom: 0px; padding: 0px; } div.center img { border: 0px; } img.footer { border: 0px; vertical-align: middle; } /* @group Code Colorization */ span.keyword { color: #008000 } span.keywordtype { color: #604020 } span.keywordflow { color: #e08000 } span.comment { color: #800000 } span.preprocessor { color: #806020 } span.stringliteral { color: #002080 } span.charliteral { color: #008080 } span.vhdldigit { color: #ff00ff } span.vhdlchar { color: #000000 } span.vhdlkeyword { color: #700070 } span.vhdllogic { color: #ff0000 } /* @end */ .search { color: #003399; font-weight: bold; } form.search { margin-bottom: 0px; margin-top: 0px; } input.search { font-size: 75%; color: #000080; font-weight: normal; background-color: #e8eef2; } td.tiny { font-size: 75%; } .dirtab { padding: 4px; border-collapse: collapse; border: 1px solid #84b0c7; } th.dirtab { background: #e8eef2; font-weight: bold; } hr { height: 0; border: none; border-top: 1px solid #666; } /* @group Member Descriptions */ .mdescLeft, .mdescRight, .memItemLeft, .memItemRight, .memTemplItemLeft, .memTemplItemRight, .memTemplParams { background-color: #FAFAFA; border: none; margin: 4px; padding: 1px 0 0 8px; } .mdescLeft, .mdescRight { padding: 0px 8px 4px 8px; color: #555; } .memItemLeft, .memItemRight, .memTemplParams { border-top: 1px solid #ccc; } .memItemLeft, .memTemplItemLeft { white-space: nowrap; } .memTemplParams { color: #606060; white-space: nowrap; } /* @end */ /* @group Member Details */ /* Styles for detailed member documentation */ .memtemplate { font-size: 80%; color: #606060; font-weight: normal; margin-left: 3px; } .memnav { background-color: #e8eef2; border: 1px solid #84b0c7; text-align: center; margin: 2px; margin-right: 15px; padding: 2px; } .memitem { padding: 0; margin-bottom: 10px; } .memname { white-space: nowrap; font-weight: bold; } .memproto, .memdoc { border: 1px solid #84b0c7; } .memproto { padding: 0; background-color: #d5e1e8; font-weight: bold; -webkit-border-top-left-radius: 8px; -webkit-border-top-right-radius: 8px; -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); -moz-border-radius-topleft: 8px; -moz-border-radius-topright: 8px; -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; } .memdoc { padding: 2px 5px; background-color: #eef3f5; border-top-width: 0; -webkit-border-bottom-left-radius: 8px; -webkit-border-bottom-right-radius: 8px; -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); -moz-border-radius-bottomleft: 8px; -moz-border-radius-bottomright: 8px; -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; } .paramkey { text-align: right; } .paramtype { white-space: nowrap; } .paramname { color: #602020; white-space: nowrap; } .paramname em { font-style: normal; } /* @end */ /* @group Directory (tree) */ /* for the tree view */ .ftvtree { font-family: sans-serif; margin: 0.5em; } /* these are for tree view when used as main index */ .directory { font-size: 9pt; font-weight: bold; } .directory h3 { margin: 0px; margin-top: 1em; font-size: 11pt; } /* The following two styles can be used to replace the root node title with an image of your choice. Simply uncomment the next two styles, specify the name of your image and be sure to set 'height' to the proper pixel height of your image. */ /* .directory h3.swap { height: 61px; background-repeat: no-repeat; background-image: url("yourimage.gif"); } .directory h3.swap span { display: none; } */ .directory > h3 { margin-top: 0; } .directory p { margin: 0px; white-space: nowrap; } .directory div { display: none; margin: 0px; } .directory img { vertical-align: -30%; } /* these are for tree view when not used as main index */ .directory-alt { font-size: 100%; font-weight: bold; } .directory-alt h3 { margin: 0px; margin-top: 1em; font-size: 11pt; } .directory-alt > h3 { margin-top: 0; } .directory-alt p { margin: 0px; white-space: nowrap; } .directory-alt div { display: none; margin: 0px; } .directory-alt img { vertical-align: -30%; } /* @end */ address { font-style: normal; color: #333; } table.doxtable { border-collapse:collapse; } table.doxtable td, table.doxtable th { border: 1px solid #153788; padding: 3px 7px 2px; } table.doxtable th { background-color: #254798; color: #FFFFFF; font-size: 110%; padding-bottom: 4px; padding-top: 5px; text-align:left; } tinyxml/docs/doxygen.png000664 000765 000024 00000002401 11563634571 017370 0ustar00leethomasonstaff000000 000000 ‰PNG  IHDRd-ok>ĀgAMAÖŲŌOX2tEXtSoftwareAdobe ImageReadyqÉe<]PLTEǾĻ"&©ČĪļ¶»ÖÓŚś“¢Ž ¬ą¶Āõ‡§ÕŁźÉŹĪįāę{ŽŌ”ėˆ™× ²ų§¬¹ĄĄ±ŻŻĪłłéõõēėėåED9×ÖĖhg]_X<@:#mhU’’’ŻĄ1tRNS’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’Ķv’IDATxŚbC£: d#„„………h` @”X",***LKˆ.–], ŗX@t± €čb @ŃÅ€BµD„6–š%""“° € ˜% ˆ™B:H¢ˆ²Įf@• ˆRPy"K`\PbC(!II!h©…ėƒ(ń„Ä!źˆ¬C„ąąl!0[X\J\$TMˆ(’>a$S„ Ł@ ŠØ@R.$‚¬LJBR¢‰AĢG1 ¬ Ā(FČƒŌPhhĮTĄ¢„%!`€&q°%uĀ P ¹¢ ¬ € ¹CT$B¢ą|‚ĀŗW„¤Ąl £!B`R$( …Ĉ‘’Āž@AÅ%ĤÄ%@,(—ʂڱ%$ĮāāRPmB U`1IˆYB  99€\1 yCCC’f"[N 'Ü=TGȒųl8˜^Kū5<źSęRɤ”%ī@@ ą›Ź b1 qÅAXHˆø&ŲB’R y n˜P„Ģć–4A €€j¹€€>Ü ˜ t!˜+(.ČÅWQ±A2ÜÜMU܂’’‚‚ā `1 %`19€F< 3cZÄ`óe!\ˆ DČ+. 83‹³Ąäø!lYYA -6‚EJŠ¢V €@©žXXX 4„å Ź@86Š`RdB“€4I "Ż "–@xrʌ‚H€AŹ`—f ÉȰCŒ"XV0ɲ³C b@2…¬H ¬ȓ p)!(ģ‚ 0Ž4ˆ)(%RĮĪ ¶$€TŹ€„Ąžb‡b,säŠ@7Ą üѰ‚Ņī?f„֗\PIx!I“¦"”Čˆ’3Ø QY˜’t^^ŪŲgv- }>WJOAV`$&#”¦8łųų8€\FF ›SFJ$ĀʀŠĘŠŠ”䈁‰ĄĄ 4Ŗ…Čäå -Į§‡ €H²…—ŸŸŸf ?šā5„ €k1Ād‰,ŒĆ ³ƒ“€.€"­F™ĖĖ€ąń‚½ĮIČ€"±Ł4ÉH gx|‚f©m)))9“. aMDƒ& ŗX@t± €čb @ŃÅ€¢‹%DKˆ.–], ŗX@t± €čb @€d`‚ɽSµOIEND®B`‚tinyxml/docs/files.html000664 000765 000024 00000003014 11563634571 017176 0ustar00leethomasonstaff000000 000000 TinyXml: File Index

File List

Here is a list of all documented files with brief descriptions:
tinystr.h [code]
tinyxml.h [code]

Generated by  doxygen 1.6.2
tinyxml/docs/functions.html000664 000765 000024 00000007724 11563634571 020120 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- a -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_0x63.html000664 000765 000024 00000011171 11563634571 020667 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- c -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_0x64.html000664 000765 000024 00000006442 11563634571 020675 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- d -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_0x65.html000664 000765 000024 00000010137 11563634571 020672 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- e -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_0x66.html000664 000765 000024 00000007737 11563634571 020707 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- f -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_0x67.html000664 000765 000024 00000007000 11563634571 020667 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- g -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_0x69.html000664 000765 000024 00000007756 11563634571 020713 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- i -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_0x6c.html000664 000765 000024 00000007364 11563634571 020760 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- l -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_0x6e.html000664 000765 000024 00000007716 11563634571 020763 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- n -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_0x6f.html000664 000765 000024 00000006621 11563634571 020756 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- o -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_0x70.html000664 000765 000024 00000010770 11563634571 020671 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- p -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_0x71.html000664 000765 000024 00000010457 11563634571 020674 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- q -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_0x72.html000664 000765 000024 00000007357 11563634571 020702 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- r -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_0x73.html000664 000765 000024 00000012564 11563634571 020677 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- s -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_0x74.html000664 000765 000024 00000014027 11563634571 020674 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- t -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_0x75.html000664 000765 000024 00000006606 11563634571 020701 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- u -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_0x76.html000664 000765 000024 00000011624 11563634571 020676 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members
Here is a list of all documented class members with links to the class documentation for each member:

- v -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_enum.html000664 000765 000024 00000003614 11563634571 021136 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Enumerations
 

Generated by  doxygen 1.6.2
tinyxml/docs/functions_func.html000664 000765 000024 00000007611 11563634571 021126 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Functions
Generated by  doxygen 1.6.2
tinyxml/docs/functions_func_0x63.html000664 000765 000024 00000011056 11563634571 021704 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Functions
 

- c -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_func_0x64.html000664 000765 000024 00000006327 11563634571 021712 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Functions
 

- d -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_func_0x65.html000664 000765 000024 00000010024 11563634571 021700 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Functions
 

- e -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_func_0x66.html000664 000765 000024 00000007624 11563634571 021715 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Functions
 

- f -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_func_0x67.html000664 000765 000024 00000006665 11563634571 021722 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Functions
 

- g -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_func_0x69.html000664 000765 000024 00000007643 11563634571 021721 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Functions
 

- i -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_func_0x6c.html000664 000765 000024 00000007251 11563634571 021766 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Functions
 

- l -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_func_0x6e.html000664 000765 000024 00000007425 11563634571 021773 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Functions
 

- n -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_func_0x70.html000664 000765 000024 00000010655 11563634571 021706 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Functions
Generated by  doxygen 1.6.2
tinyxml/docs/functions_func_0x71.html000664 000765 000024 00000010344 11563634571 021702 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Functions
 

- q -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_func_0x72.html000664 000765 000024 00000007244 11563634571 021710 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Functions
 

- r -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_func_0x73.html000664 000765 000024 00000012451 11563634571 021705 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Functions
 

- s -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_func_0x74.html000664 000765 000024 00000013714 11563634571 021711 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Functions
 

- t -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_func_0x75.html000664 000765 000024 00000006315 11563634571 021711 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Functions
 

- u -


Generated by  doxygen 1.6.2
tinyxml/docs/functions_func_0x76.html000664 000765 000024 00000011511 11563634571 021704 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Functions
Generated by  doxygen 1.6.2
tinyxml/docs/functions_rela.html000664 000765 000024 00000004017 11563634571 021113 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Related Functions
 

Generated by  doxygen 1.6.2
tinyxml/docs/functions_vars.html000664 000765 000024 00000003611 11563634571 021142 0ustar00leethomasonstaff000000 000000 TinyXml: Class Members - Variables
 

Generated by  doxygen 1.6.2
tinyxml/docs/hierarchy.html000664 000765 000024 00000004447 11563634571 020065 0ustar00leethomasonstaff000000 000000 TinyXml: Hierarchical Index

Class Hierarchy

This inheritance list is sorted roughly, but not completely, alphabetically:

Generated by  doxygen 1.6.2
tinyxml/docs/index.html000664 000765 000024 00000057557 11563634571 017230 0ustar00leethomasonstaff000000 000000 TinyXml: Main Page

TinyXml Documentation

2.6.2

TinyXML

TinyXML is a simple, small, C++ XML parser that can be easily integrated into other programs.

What it does.

In brief, TinyXML parses an XML document, and builds from that a Document Object Model (DOM) that can be read, modified, and saved.

XML stands for "eXtensible Markup Language." It allows you to create your own document markups. Where HTML does a very good job of marking documents for browsers, XML allows you to define any kind of document markup, for example a document that describes a "to do" list for an organizer application. XML is a very structured and convenient format. All those random file formats created to store application data can all be replaced with XML. One parser for everything.

The best place for the complete, correct, and quite frankly hard to read spec is at http://www.w3.org/TR/2004/REC-xml-20040204/. An intro to XML (that I really like) can be found at http://skew.org/xml/tutorial.

There are different ways to access and interact with XML data. TinyXML uses a Document Object Model (DOM), meaning the XML data is parsed into a C++ objects that can be browsed and manipulated, and then written to disk or another output stream. You can also construct an XML document from scratch with C++ objects and write this to disk or another output stream.

TinyXML is designed to be easy and fast to learn. It is two headers and four cpp files. Simply add these to your project and off you go. There is an example file - xmltest.cpp - to get you started.

TinyXML is released under the ZLib license, so you can use it in open source or commercial code. The details of the license are at the top of every source file.

TinyXML attempts to be a flexible parser, but with truly correct and compliant XML output. TinyXML should compile on any reasonably C++ compliant system. It does not rely on exceptions or RTTI. It can be compiled with or without STL support. TinyXML fully supports the UTF-8 encoding, and the first 64k character entities.

What it doesn't do.

TinyXML doesn't parse or use DTDs (Document Type Definitions) or XSLs (eXtensible Stylesheet Language.) There are other parsers out there (check out www.sourceforge.org, search for XML) that are much more fully featured. But they are also much bigger, take longer to set up in your project, have a higher learning curve, and often have a more restrictive license. If you are working with browsers or have more complete XML needs, TinyXML is not the parser for you.

The following DTD syntax will not parse at this time in TinyXML:

	<!DOCTYPE Archiv [
	 <!ELEMENT Comment (#PCDATA)>
	]>

because TinyXML sees this as a !DOCTYPE node with an illegally embedded !ELEMENT node. This may be addressed in the future.

Tutorials.

For the impatient, here is a tutorial to get you going. A great way to get started, but it is worth your time to read this (very short) manual completely.

Code Status.

TinyXML is mature, tested code. It is very stable. If you find bugs, please file a bug report on the sourceforge web site (www.sourceforge.net/projects/tinyxml). We'll get them straightened out as soon as possible.

There are some areas of improvement; please check sourceforge if you are interested in working on TinyXML.

Related Projects

TinyXML projects you may find useful! (Descriptions provided by the projects.)

Features

Using STL

TinyXML can be compiled to use or not use STL. When using STL, TinyXML uses the std::string class, and fully supports std::istream, std::ostream, operator<<, and operator>>. Many API methods have both 'const char*' and 'const std::string&' forms.

When STL support is compiled out, no STL files are included whatsoever. All the string classes are implemented by TinyXML itself. API methods all use the 'const char*' form for input.

Use the compile time define:

TIXML_USE_STL

to compile one version or the other. This can be passed by the compiler, or set as the first line of "tinyxml.h".

Note: If compiling the test code in Linux, setting the environment variable TINYXML_USE_STL=YES/NO will control STL compilation. In the Windows project file, STL and non STL targets are provided. In your project, It's probably easiest to add the line "#define TIXML_USE_STL" as the first line of tinyxml.h.

UTF-8

TinyXML supports UTF-8 allowing to manipulate XML files in any language. TinyXML also supports "legacy mode" - the encoding used before UTF-8 support and probably best described as "extended ascii".

Normally, TinyXML will try to detect the correct encoding and use it. However, by setting the value of TIXML_DEFAULT_ENCODING in the header file, TinyXML can be forced to always use one encoding.

TinyXML will assume Legacy Mode until one of the following occurs:

  1. If the non-standard but common "UTF-8 lead bytes" (0xef 0xbb 0xbf) begin the file or data stream, TinyXML will read it as UTF-8.
  2. If the declaration tag is read, and it has an encoding="UTF-8", then TinyXML will read it as UTF-8.
  3. If the declaration tag is read, and it has no encoding specified, then TinyXML will read it as UTF-8.
  4. If the declaration tag is read, and it has an encoding="something else", then TinyXML will read it as Legacy Mode. In legacy mode, TinyXML will work as it did before. It's not clear what that mode does exactly, but old content should keep working.
  5. Until one of the above criteria is met, TinyXML runs in Legacy Mode.

What happens if the encoding is incorrectly set or detected? TinyXML will try to read and pass through text seen as improperly encoded. You may get some strange results or mangled characters. You may want to force TinyXML to the correct mode.

You may force TinyXML to Legacy Mode by using LoadFile( TIXML_ENCODING_LEGACY ) or LoadFile( filename, TIXML_ENCODING_LEGACY ). You may force it to use legacy mode all the time by setting TIXML_DEFAULT_ENCODING = TIXML_ENCODING_LEGACY. Likewise, you may force it to TIXML_ENCODING_UTF8 with the same technique.

For English users, using English XML, UTF-8 is the same as low-ASCII. You don't need to be aware of UTF-8 or change your code in any way. You can think of UTF-8 as a "superset" of ASCII.

UTF-8 is not a double byte format - but it is a standard encoding of Unicode! TinyXML does not use or directly support wchar, TCHAR, or Microsoft's _UNICODE at this time. It is common to see the term "Unicode" improperly refer to UTF-16, a wide byte encoding of unicode. This is a source of confusion.

For "high-ascii" languages - everything not English, pretty much - TinyXML can handle all languages, at the same time, as long as the XML is encoded in UTF-8. That can be a little tricky, older programs and operating systems tend to use the "default" or "traditional" code page. Many apps (and almost all modern ones) can output UTF-8, but older or stubborn (or just broken) ones still output text in the default code page.

For example, Japanese systems traditionally use SHIFT-JIS encoding. Text encoded as SHIFT-JIS can not be read by TinyXML. A good text editor can import SHIFT-JIS and then save as UTF-8.

The Skew.org link does a great job covering the encoding issue.

The test file "utf8test.xml" is an XML containing English, Spanish, Russian, and Simplified Chinese. (Hopefully they are translated correctly). The file "utf8test.gif" is a screen capture of the XML file, rendered in IE. Note that if you don't have the correct fonts (Simplified Chinese or Russian) on your system, you won't see output that matches the GIF file even if you can parse it correctly. Also note that (at least on my Windows machine) console output is in a Western code page, so that Print() or printf() cannot correctly display the file. This is not a bug in TinyXML - just an OS issue. No data is lost or destroyed by TinyXML. The console just doesn't render UTF-8.

Entities

TinyXML recognizes the pre-defined "character entities", meaning special characters. Namely:

	&amp;	&
	&lt;	<
	&gt;	>
	&quot;	"
	&apos;	'

These are recognized when the XML document is read, and translated to there UTF-8 equivalents. For instance, text with the XML of:

	Far &amp; Away

will have the Value() of "Far & Away" when queried from the TiXmlText object, and will be written back to the XML stream/file as an ampersand. Older versions of TinyXML "preserved" character entities, but the newer versions will translate them into characters.

Additionally, any character can be specified by its Unicode code point: The syntax "&#xA0;" or "&#160;" are both to the non-breaking space characher.

Printing

TinyXML can print output in several different ways that all have strengths and limitations.

  • Print( FILE* ). Output to a std-C stream, which includes all C files as well as stdout.
    • "Pretty prints", but you don't have control over printing options.
    • The output is streamed directly to the FILE object, so there is no memory overhead in the TinyXML code.
    • used by Print() and SaveFile()
  • operator<<. Output to a c++ stream.
    • Integrates with standart C++ iostreams.
    • Outputs in "network printing" mode without line breaks. Good for network transmission and moving XML between C++ objects, but hard for a human to read.
  • TiXmlPrinter. Output to a std::string or memory buffer.
    • API is less concise
    • Future printing options will be put here.
    • Printing may change slightly in future versions as it is refined and expanded.

Streams

With TIXML_USE_STL on TinyXML supports C++ streams (operator <<,>>) streams as well as C (FILE*) streams. There are some differences that you may need to be aware of.

C style output:

  • based on FILE*
  • the Print() and SaveFile() methods

Generates formatted output, with plenty of white space, intended to be as human-readable as possible. They are very fast, and tolerant of ill formed XML documents. For example, an XML document that contains 2 root elements and 2 declarations, will still print.

C style input:

  • based on FILE*
  • the Parse() and LoadFile() methods

A fast, tolerant read. Use whenever you don't need the C++ streams.

C++ style output:

  • based on std::ostream
  • operator<<

Generates condensed output, intended for network transmission rather than readability. Depending on your system's implementation of the ostream class, these may be somewhat slower. (Or may not.) Not tolerant of ill formed XML: a document should contain the correct one root element. Additional root level elements will not be streamed out.

C++ style input:

  • based on std::istream
  • operator>>

Reads XML from a stream, making it useful for network transmission. The tricky part is knowing when the XML document is complete, since there will almost certainly be other data in the stream. TinyXML will assume the XML data is complete after it reads the root element. Put another way, documents that are ill-constructed with more than one root element will not read correctly. Also note that operator>> is somewhat slower than Parse, due to both implementation of the STL and limitations of TinyXML.

White space

The world simply does not agree on whether white space should be kept, or condensed. For example, pretend the '_' is a space, and look at "Hello____world". HTML, and at least some XML parsers, will interpret this as "Hello_world". They condense white space. Some XML parsers do not, and will leave it as "Hello____world". (Remember to keep pretending the _ is a space.) Others suggest that __Hello___world__ should become Hello___world.

It's an issue that hasn't been resolved to my satisfaction. TinyXML supports the first 2 approaches. Call TiXmlBase::SetCondenseWhiteSpace( bool ) to set the desired behavior. The default is to condense white space.

If you change the default, you should call TiXmlBase::SetCondenseWhiteSpace( bool ) before making any calls to Parse XML data, and I don't recommend changing it after it has been set.

Handles

Where browsing an XML document in a robust way, it is important to check for null returns from method calls. An error safe implementation can generate a lot of code like:

TiXmlElement* root = document.FirstChildElement( "Document" );
if ( root )
{
	TiXmlElement* element = root->FirstChildElement( "Element" );
	if ( element )
	{
		TiXmlElement* child = element->FirstChildElement( "Child" );
		if ( child )
		{
			TiXmlElement* child2 = child->NextSiblingElement( "Child" );
			if ( child2 )
			{
				// Finally do something useful.

Handles have been introduced to clean this up. Using the TiXmlHandle class, the previous code reduces to:

TiXmlHandle docHandle( &document );
TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement();
if ( child2 )
{
	// do something useful

Which is much easier to deal with. See TiXmlHandle for more information.

Row and Column tracking

Being able to track nodes and attributes back to their origin location in source files can be very important for some applications. Additionally, knowing where parsing errors occured in the original source can be very time saving.

TinyXML can tracks the row and column origin of all nodes and attributes in a text file. The TiXmlBase::Row() and TiXmlBase::Column() methods return the origin of the node in the source text. The correct tabs can be configured in TiXmlDocument::SetTabSize().

Using and Installing

To Compile and Run xmltest:

A Linux Makefile and a Windows Visual C++ .dsw file is provided. Simply compile and run. It will write the file demotest.xml to your disk and generate output on the screen. It also tests walking the DOM by printing out the number of nodes found using different techniques.

The Linux makefile is very generic and runs on many systems - it is currently tested on mingw and MacOSX. You do not need to run 'make depend'. The dependecies have been hard coded.

Windows project file for VC6

  • tinyxml: tinyxml library, non-STL
  • tinyxmlSTL: tinyxml library, STL
  • tinyXmlTest: test app, non-STL
  • tinyXmlTestSTL: test app, STL

Makefile

At the top of the makefile you can set:

PROFILE, DEBUG, and TINYXML_USE_STL. Details (such that they are) are in the makefile.

In the tinyxml directory, type "make clean" then "make". The executable file 'xmltest' will be created.

To Use in an Application:

Add tinyxml.cpp, tinyxml.h, tinyxmlerror.cpp, tinyxmlparser.cpp, tinystr.cpp, and tinystr.h to your project or make file. That's it! It should compile on any reasonably compliant C++ system. You do not need to enable exceptions or RTTI for TinyXML.

How TinyXML works.

An example is probably the best way to go. Take:

	<?xml version="1.0" standalone=no>
	<!-- Our to do list data -->
	<ToDo>
		<Item priority="1"> Go to the <bold>Toy store!</bold></Item>
		<Item priority="2"> Do bills</Item>
	</ToDo>

Its not much of a To Do list, but it will do. To read this file (say "demo.xml") you would create a document, and parse it in:

	TiXmlDocument doc( "demo.xml" );
	doc.LoadFile();

And its ready to go. Now lets look at some lines and how they relate to the DOM.

<?xml version="1.0" standalone=no>

The first line is a declaration, and gets turned into the TiXmlDeclaration class. It will be the first child of the document node.

This is the only directive/special tag parsed by TinyXML. Generally directive tags are stored in TiXmlUnknown so the commands wont be lost when it is saved back to disk.

<!-- Our to do list data -->

A comment. Will become a TiXmlComment object.

<ToDo>

The "ToDo" tag defines a TiXmlElement object. This one does not have any attributes, but does contain 2 other elements.

<Item priority="1"> 

Creates another TiXmlElement which is a child of the "ToDo" element. This element has 1 attribute, with the name "priority" and the value "1".

Go to the

A TiXmlText. This is a leaf node and cannot contain other nodes. It is a child of the "Item" TiXmlElement.

<bold>

Another TiXmlElement, this one a child of the "Item" element.

Etc.

Looking at the entire object tree, you end up with:

TiXmlDocument					"demo.xml"
	TiXmlDeclaration			"version='1.0'" "standalone=no"
	TiXmlComment				" Our to do list data"
	TiXmlElement				"ToDo"
		TiXmlElement			"Item" Attribtutes: priority = 1
			TiXmlText			"Go to the "
			TiXmlElement		"bold"
				TiXmlText		"Toy store!"
		TiXmlElement			"Item" Attributes: priority=2
			TiXmlText			"Do bills"

Documentation

The documentation is build with Doxygen, using the 'dox' configuration file.

License

TinyXML is released under the zlib license:

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.

References

The World Wide Web Consortium is the definitive standard body for XML, and their web pages contain huge amounts of information.

The definitive spec: http://www.w3.org/TR/2004/REC-xml-20040204/

I also recommend "XML Pocket Reference" by Robert Eckstein and published by OReilly...the book that got the whole thing started.

Contributors, Contacts, and a Brief History

Thanks very much to everyone who sends suggestions, bugs, ideas, and encouragement. It all helps, and makes this project fun. A special thanks to the contributors on the web pages that keep it lively.

So many people have sent in bugs and ideas, that rather than list here we try to give credit due in the "changes.txt" file.

TinyXML was originally written by Lee Thomason. (Often the "I" still in the documentation.) Lee reviews changes and releases new versions, with the help of Yves Berquin, Andrew Ellerton, and the tinyXml community.

We appreciate your suggestions, and would love to know if you use TinyXML. Hopefully you will enjoy it and find it useful. Please post questions, comments, file bugs, or contact us at:

www.sourceforge.net/projects/tinyxml

Lee Thomason, Yves Berquin, Andrew Ellerton


Generated by  doxygen 1.6.2
tinyxml/docs/pages.html000664 000765 000024 00000002277 11563634571 017205 0ustar00leethomasonstaff000000 000000 TinyXml: Page Index

Related Pages

Here is a list of all related documentation pages:

Generated by  doxygen 1.6.2
tinyxml/docs/tab_b.gif000664 000765 000024 00000000043 11563634571 016743 0ustar00leethomasonstaff000000 000000 GIF89a€„°Ē,D;tinyxml/docs/tab_l.gif000664 000765 000024 00000001302 11563634571 016754 0ustar00leethomasonstaff000000 000000 GIF89a ,Õö÷łńō÷öųśüżžśūüłśūųłśźļóļóöĘÕßŅŽęŲāéŽēķŻęģåģńčīņō÷łóöų³ČÕĮŅŻĖŁāĻÜäÖįč–“Å¹ÉÆĀĶ»ĪŁĆŌŽĀÓŻČ×ąĢŚāÕįčŁäź×āčåģšėšó„°ĒŃŽåÜęėćėļėńōīóõ÷śūūüü’’’žžž, ,’@–P±É`H$!%CqVe2X­ŠĢJ(“Ä +€˜3 2$ĄĘ ¼kvŠä-Ėēõu*…"}ć|}|~q(" $f„ 'Žl(Œ&&$r‘™ › & ! )¢¤›{Ø£„r­Ŗ°©Æ„±Æ¬“¦·»ŗ³®«§¾¶ĆĀĄæ²¹ĒÄĖƲĢÉεҽͼ„ŌČÓ׊øŁŻÕĻŁŹāÜßćēęź¾äŪÅėĒķįīÖģéļųń÷õüŃšåłü¤Pß?‚ƒœĒŪBm åAœĪįĄ†%V܈ī!Ēk÷Ų/įĐ;^¤Ø²$ʖ#Mf)f͇(WĪL‰“ęKēŅ„° ’I)L:eD ”Cµ“x*4 UØh  %A«£^ĮNKb¬Łe§X±‚“k»x!ĮÖķ—2tŻÖ !ƚ5tŪęé—Ą]$¬“%ƒXķā.i[¬]Y­•ŹfžEėõkg`µ††:zėēŅž;£}ŗµj×aa‹–Mš¶é×øcēž½»vļŪŗƒóī›8šįȋ'?®¼9óē©G_>Żyuč¬_ߞ]zwźß­‡Ē¾ŗ¼mīęµG~½ūōŽįƒ—/ž>łöö٫ϒæ’ż’Åą|ÖWą}v;tinyxml/docs/tab_r.gif000664 000765 000024 00000005031 11563634571 016765 0ustar00leethomasonstaff000000 000000 GIF89a,Õö÷łńō÷öųśüżžśūüłśūųłśźļóļóöĘÕßŅŽęŲāéŽēķŻęģåģńčīņō÷łóöų³ČÕĮŅŻĖŁāĻÜäÖįč–“Å¹ÉÆĀĶ»ĪŁĆŌŽĀÓŻČ×ąĢŚāÕįčŁäź×āčåģšėšó„°ĒŃŽåÜęėćėļėńōīóõ÷śūūüü’’’žžž,,’@’pH,Č¤rÉl:ŸŠØtJ­ZÆŲ¬v •h<¬pkL.›Ļč“zĶn»ßšø|NÆŪļų¼~ĻwVa+‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ “*)^,*Ŗ«¬­®Æ°±²³“µ¶·ø¹ŗ»¼½¾æĄĮĀƶ)'ĘĪĻŠŃŅÓŌÕÖ×ŲŁŚŪÜŻŽßąįāćäåꌄ(" šńņóōõö÷ųłśūüżž’ H° ĮƒņK"ƒRHœH±¢Å‹3jÜȱ£Ē CŠI²¤É“(SŖ\éŁu&@€ Į²¦Ķ›8sźÜɳ§O’–(±€DŠ£H“*]Ź“©Ó§P£JJµŖÕ«X³jŻŹµ«×ÆS84± ‰hÓŖ]˶­Ū·p欝K·®Ż»xóźŻĖ·Æßæ€Ó} āDĢf(^Ģø±ćǐ#KžL¹²å˘3kŽĢ¹³ēĻ C‹m¹šCÄHœXĶŗµė×°cĖžM»¶ķŪøsėŽĶ»·ļߥƒ N÷ĆJ” Į®¹óēŠ£KŸN½ŗõėŲ³kßν»÷ļąĆ‹O¾śń€ dĒ@€‚‚L¤"ÉČF:ņ‘Œ¤$9† (8…&ÉÉNzņ“  „(G©FB^²!ĖØ)WÉŹVŗņ•°l¤)1™ wÄņ–øĢ„.wŹYŗäƒą„0‡IĢbó¾|ÉHpĢf:ó™Šģe pJ±ˆ€}Ȧ6·ÉĶnzó›ą §8ū0Ā%"øę8×ÉĪvŗóšŒ§<ÉPĪQ`ņ%×$€>÷ÉĻ~śóŸ Ø@JŠ‚ō MØBŹŠ†:ō”ØD'ZPKF Ö¼&16ŹŃŽzō£ ©HGJRb ÷Lē5ĻĮŅ–ŗō„’0©LgJӚš#(e>ƉӞśō§@ ŖP‡JŌ¢õØHMŖR—ŹŌ¦:õ©PŖT§JÕŖ&5;%U·ŹÕ®zõ«` «XĒJV«ĀC§‹ŃjY׏ֶŗõ­p«\ŠU“Ą¦xĶ«^÷Ź×¾śõÆŠĄi)$‚”ō°ˆM¬bĖŲĘ:vˆ, ಘͬf7ĖŁĪzö³  ­hGKŚŅšö“ØM­jWĖŚÖŗöµ°­*$ŪSPō¶øĶ­nwĖŪŽśö·ĄÅm +„āøČM®r—ĖÜę:÷¹ŠE®?±9ĻźZ÷ŗŲĶ®væ9€ī"‚ŗŪ ÆxĒKŽņb—™ŃL’Æz×Ė^A¢·½šÆ|ē†÷Ņ÷¾ųĶÆ0ķ«ßžś÷æ”ä/€Lą»×ĄN°‚ļ(ą;ųĮ n0„'LażJøĀĪ0{/¬į{ؘž°ˆG|Ė“ųÄ(„‰SĢāCrÅ.ޱŒ ćŪųĘv¬1ŽwĢc6źøĒ@ŽńƒLd¹ČHNń‘“Ģd/¹ÉPĪš“£LeO¹ŹXŽp–·|ā+słĖżõ2˜ĒL_1“łĢķ53š×M5³łĶĒt3œē¼_:ŪŁĀwĪs™õĢgųʹπp żĢ?śŠ/F“¢ė¼čFćŅŠŽŽt!-éJć‘Ņ–Īō1­éN»‘Óžu’A-źP“ŗŌ>5Ŗ3­źUWŗÕ®Ž4¬cŻčYÓZѶ¾õ”s­ėAóŗ×€ž5°ł,ģaē¹Ųʶ3²“=ēe3ūĶĪ~öš£-ķ3S»Śc¾6¶æ¬ķmo¹ŪŽĘ2øĆMåq“Źę>7“Ó­n$³»ŻD~7¼,ļyóøŽöĘ1¾ómć}óŪČ’vµæŽā\É/µĮNā…3ÜÉ÷“Ć#Žį‰S\ŹguĘ-mńOøć0ČC¾ą‘“\Ė'_“ÉS^ą•³|Ą.łc.ó0לŠ4æ9~s®ó=÷¼Ļ<’y|ƒ.ō4]ĻD?ŗz“®ō67]ŁO§3Ó£ŽĢ©SÄW‡vÖŁl>õ­3Śėdī:Ųu)ö±?ŚģŁF;˜Ė®öW²½ķ­|;ÜW)÷¹²īvtŽĖ½w¾÷Ż|ą×=xĀŽŻA;tinyxml/docs/tabs.css000664 000765 000024 00000003464 11563634571 016662 0ustar00leethomasonstaff000000 000000 /* tabs styles, based on http://www.alistapart.com/articles/slidingdoors */ DIV.tabs { float : left; width : 100%; background : url("tab_b.gif") repeat-x bottom; margin-bottom : 4px; } DIV.tabs UL { margin : 0px; padding-left : 10px; list-style : none; } DIV.tabs LI, DIV.tabs FORM { display : inline; margin : 0px; padding : 0px; } DIV.tabs FORM { float : right; } DIV.tabs A { float : left; background : url("tab_r.gif") no-repeat right top; border-bottom : 1px solid #84B0C7; font-size : 80%; font-weight : bold; text-decoration : none; } DIV.tabs A:hover { background-position: 100% -150px; } DIV.tabs A:link, DIV.tabs A:visited, DIV.tabs A:active, DIV.tabs A:hover { color: #1A419D; } DIV.tabs SPAN { float : left; display : block; background : url("tab_l.gif") no-repeat left top; padding : 5px 9px; white-space : nowrap; } DIV.tabs #MSearchBox { float : right; display : inline; font-size : 1em; } DIV.tabs TD { font-size : 80%; font-weight : bold; text-decoration : none; } /* Commented Backslash Hack hides rule from IE5-Mac \*/ DIV.tabs SPAN {float : none;} /* End IE5-Mac hack */ DIV.tabs A:hover SPAN { background-position: 0% -150px; } DIV.tabs LI.current A { background-position: 100% -150px; border-width : 0px; } DIV.tabs LI.current SPAN { background-position: 0% -150px; padding-bottom : 6px; } DIV.navpath { background : none; border : none; border-bottom : 1px solid #84B0C7; text-align : center; margin : 2px; padding : 2px; } tinyxml/docs/tinystr_8h_source.html000664 000765 000024 00000065612 11563634571 021603 0ustar00leethomasonstaff000000 000000 TinyXml: tinystr.h Source File
Generated by  doxygen 1.6.2
tinyxml/docs/tinyxml_8h_source.html000664 000765 000024 00000617724 11563634571 021602 0ustar00leethomasonstaff000000 000000 TinyXml: tinyxml.h Source File
Generated by  doxygen 1.6.2
tinyxml/docs/tutorial0.html000664 000765 000024 00000055272 11563634571 020034 0ustar00leethomasonstaff000000 000000 TinyXml: TinyXML Tutorial

TinyXML Tutorial

What is this?

This tutorial has a few tips and suggestions on how to use TinyXML effectively.

I've also tried to include some C++ tips like how to convert strings to integers and vice versa. This isn't anything to do with TinyXML itself, but it may helpful for your project so I've put it in anyway.

If you don't know basic C++ concepts this tutorial won't be useful. Likewise if you don't know what a DOM is, look elsewhere first.

Before we start

Some example XML datasets/files will be used.

example1.xml:

<?xml version="1.0" ?>
<Hello>World</Hello>

example2.xml:

<?xml version="1.0" ?>
<poetry>
	<verse>
		Alas
		  Great World
			Alas (again)
	</verse>
</poetry>

example3.xml:

<?xml version="1.0" ?>
<shapes>
	<circle name="int-based" x="20" y="30" r="50" />
	<point name="float-based" x="3.5" y="52.1" />
</shapes>

example4.xml

<?xml version="1.0" ?>
<MyApp>
    <!-- Settings for MyApp -->
    <Messages>
        <Welcome>Welcome to MyApp</Welcome>
        <Farewell>Thank you for using MyApp</Farewell>
    </Messages>
    <Windows>
        <Window name="MainFrame" x="5" y="15" w="400" h="250" />
    </Windows>
    <Connection ip="192.168.0.1" timeout="123.456000" />
</MyApp>

Getting Started

Load XML from a file

The simplest way to load a file into a TinyXML DOM is:

TiXmlDocument doc( "demo.xml" );
doc.LoadFile();

A more real-world usage is shown below. This will load the file and display the contents to STDOUT:

// load the named file and dump its structure to STDOUT
void dump_to_stdout(const char* pFilename)
{
	TiXmlDocument doc(pFilename);
	bool loadOkay = doc.LoadFile();
	if (loadOkay)
	{
		printf("\n%s:\n", pFilename);
		dump_to_stdout( &doc ); // defined later in the tutorial
	}
	else
	{
		printf("Failed to load file \"%s\"\n", pFilename);
	}
}

A simple demonstration of this function is to use a main like this:

int main(void)
{
	dump_to_stdout("example1.xml");
	return 0;
}

Recall that Example 1 XML is:

<?xml version="1.0" ?>
<Hello>World</Hello>

Running the program with this XML will display this in the console/DOS window:

DOCUMENT
+ DECLARATION
+ ELEMENT Hello
  + TEXT[World]

The ``dump_to_stdout`` function is defined later in this tutorial and is useful if you want to understand recursive traversal of a DOM.

Building Documents Programatically

This is how to build Example 1 pragmatically:

void build_simple_doc( )
{
	// Make xml: <?xml ..><Hello>World</Hello>
	TiXmlDocument doc;
	TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "", "" );
	TiXmlElement * element = new TiXmlElement( "Hello" );
	TiXmlText * text = new TiXmlText( "World" );
	element->LinkEndChild( text );
	doc.LinkEndChild( decl );
	doc.LinkEndChild( element );
	doc.SaveFile( "madeByHand.xml" );
}

This can be loaded and displayed on the console with:

dump_to_stdout("madeByHand.xml"); // this func defined later in the tutorial

and you'll see it is identical to Example 1:

madeByHand.xml:
Document
+ Declaration
+ Element [Hello]
  + Text: [World]

This code produces exactly the same XML DOM but it shows a different ordering to node creation and linking:

void write_simple_doc2( )
{
	// same as write_simple_doc1 but add each node
	// as early as possible into the tree.

	TiXmlDocument doc;
	TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "", "" );
	doc.LinkEndChild( decl );
	
	TiXmlElement * element = new TiXmlElement( "Hello" );
	doc.LinkEndChild( element );
	
	TiXmlText * text = new TiXmlText( "World" );
	element->LinkEndChild( text );
	
	doc.SaveFile( "madeByHand2.xml" );
}

Both of these produce the same XML, namely:

<?xml version="1.0" ?>
<Hello>World</Hello>

Or in structure form:

DOCUMENT
+ DECLARATION
+ ELEMENT Hello
  + TEXT[World]

Attributes

Given an existing node, settings attributes is easy:

window = new TiXmlElement( "Demo" );  
window->SetAttribute("name", "Circle");
window->SetAttribute("x", 5);
window->SetAttribute("y", 15);
window->SetDoubleAttribute("radius", 3.14159);

You can it also work with the TiXmlAttribute objects if you want.

The following code shows one way (not the only way) to get all attributes of an element, print the name and string value, and if the value can be converted to an integer or double, print that value too:

// print all attributes of pElement.
// returns the number of attributes printed
int dump_attribs_to_stdout(TiXmlElement* pElement, unsigned int indent)
{
	if ( !pElement ) return 0;

	TiXmlAttribute* pAttrib=pElement->FirstAttribute();
	int i=0;
	int ival;
	double dval;
	const char* pIndent=getIndent(indent);
	printf("\n");
	while (pAttrib)
	{
		printf( "%s%s: value=[%s]", pIndent, pAttrib->Name(), pAttrib->Value());

		if (pAttrib->QueryIntValue(&ival)==TIXML_SUCCESS)    printf( " int=%d", ival);
		if (pAttrib->QueryDoubleValue(&dval)==TIXML_SUCCESS) printf( " d=%1.1f", dval);
		printf( "\n" );
		i++;
		pAttrib=pAttrib->Next();
	}
	return i;
}

Writing a document to a file

Writing a pre-built DOM to a file is trivial:

doc.SaveFile( saveFilename );  

Recall, for example, example 4:

<?xml version="1.0" ?>
<MyApp>
    <!-- Settings for MyApp -->
    <Messages>
        <Welcome>Welcome to MyApp</Welcome>
        <Farewell>Thank you for using MyApp</Farewell>
    </Messages>
    <Windows>
        <Window name="MainFrame" x="5" y="15" w="400" h="250" />
    </Windows>
    <Connection ip="192.168.0.1" timeout="123.456000" />
</MyApp>

The following function builds this DOM and writes the file "appsettings.xml":

void write_app_settings_doc( )  
{  
	TiXmlDocument doc;  
	TiXmlElement* msg;
 	TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );  
	doc.LinkEndChild( decl );  
 
	TiXmlElement * root = new TiXmlElement( "MyApp" );  
	doc.LinkEndChild( root );  

	TiXmlComment * comment = new TiXmlComment();
	comment->SetValue(" Settings for MyApp " );  
	root->LinkEndChild( comment );  
 
	TiXmlElement * msgs = new TiXmlElement( "Messages" );  
	root->LinkEndChild( msgs );  
 
	msg = new TiXmlElement( "Welcome" );  
	msg->LinkEndChild( new TiXmlText( "Welcome to MyApp" ));  
	msgs->LinkEndChild( msg );  
 
	msg = new TiXmlElement( "Farewell" );  
	msg->LinkEndChild( new TiXmlText( "Thank you for using MyApp" ));  
	msgs->LinkEndChild( msg );  
 
	TiXmlElement * windows = new TiXmlElement( "Windows" );  
	root->LinkEndChild( windows );  

	TiXmlElement * window;
	window = new TiXmlElement( "Window" );  
	windows->LinkEndChild( window );  
	window->SetAttribute("name", "MainFrame");
	window->SetAttribute("x", 5);
	window->SetAttribute("y", 15);
	window->SetAttribute("w", 400);
	window->SetAttribute("h", 250);

	TiXmlElement * cxn = new TiXmlElement( "Connection" );  
	root->LinkEndChild( cxn );  
	cxn->SetAttribute("ip", "192.168.0.1");
	cxn->SetDoubleAttribute("timeout", 123.456); // floating point attrib
	
	dump_to_stdout( &doc );
	doc.SaveFile( "appsettings.xml" );  
} 

The dump_to_stdout function will show this structure:

Document
+ Declaration
+ Element [MyApp]
 (No attributes)
  + Comment: [ Settings for MyApp ]
  + Element [Messages]
 (No attributes)
    + Element [Welcome]
 (No attributes)
      + Text: [Welcome to MyApp]
    + Element [Farewell]
 (No attributes)
      + Text: [Thank you for using MyApp]
  + Element [Windows]
 (No attributes)
    + Element [Window]
      + name: value=[MainFrame]
      + x: value=[5] int=5 d=5.0
      + y: value=[15] int=15 d=15.0
      + w: value=[400] int=400 d=400.0
      + h: value=[250] int=250 d=250.0
      5 attributes
  + Element [Connection]
    + ip: value=[192.168.0.1] int=192 d=192.2
    + timeout: value=[123.456000] int=123 d=123.5
    2 attributes

I was surprised that TinyXml, by default, writes the XML in what other APIs call a "pretty" format - it modifies the whitespace of text of elements that contain other nodes so that writing the tree includes an indication of nesting level.

I haven't looked yet to see if there is a way to turn off indenting when writing a file - its bound to be easy.

[Lee: It's easy in STL mode, just use cout << myDoc. Non-STL mode is always in "pretty" format. Adding a switch would be a nice feature and has been requested.]

XML to/from C++ objects

Intro

This example assumes you're loading and saving your app settings in an XML file, e.g. something like example4.xml.

There are a number of ways to do this. For example, look into the TinyBind project at http://sourceforge.net/projects/tinybind

This section shows a plain-old approach to loading and saving a basic object structure using XML.

Set up your object classes

Start off with some basic classes like these:

#include <string>
#include <map>
using namespace std;

typedef std::map<std::string,std::string> MessageMap;

// a basic window abstraction - demo purposes only
class WindowSettings
{
public:
	int x,y,w,h;
	string name;

	WindowSettings()
		: x(0), y(0), w(100), h(100), name("Untitled")
	{
	}

	WindowSettings(int x, int y, int w, int h, const string& name)
	{
		this->x=x;
		this->y=y;
		this->w=w;
		this->h=h;
		this->name=name;
	}
};

class ConnectionSettings
{
public:
	string ip;
	double timeout;
};

class AppSettings
{
public:
	string m_name;
	MessageMap m_messages;
	list<WindowSettings> m_windows;
	ConnectionSettings m_connection;

	AppSettings() {}

	void save(const char* pFilename);
	void load(const char* pFilename);
	
	// just to show how to do it
	void setDemoValues()
	{
		m_name="MyApp";
		m_messages.clear();
		m_messages["Welcome"]="Welcome to "+m_name;
		m_messages["Farewell"]="Thank you for using "+m_name;
		m_windows.clear();
		m_windows.push_back(WindowSettings(15,15,400,250,"Main"));
		m_connection.ip="Unknown";
		m_connection.timeout=123.456;
	}
};

This is a basic main() that shows how to create a default settings object tree, save it and load it again:

int main(void)
{
	AppSettings settings;
	
	settings.save("appsettings2.xml");
	settings.load("appsettings2.xml");
	return 0;
}

The following main() shows creation, modification, saving and then loading of a settings structure:

int main(void)
{
	// block: customise and save settings
	{
		AppSettings settings;
		settings.m_name="HitchHikerApp";
		settings.m_messages["Welcome"]="Don't Panic";
		settings.m_messages["Farewell"]="Thanks for all the fish";
		settings.m_windows.push_back(WindowSettings(15,25,300,250,"BookFrame"));
		settings.m_connection.ip="192.168.0.77";
		settings.m_connection.timeout=42.0;

		settings.save("appsettings2.xml");
	}
	
	// block: load settings
	{
		AppSettings settings;
		settings.load("appsettings2.xml");
		printf("%s: %s\n", settings.m_name.c_str(), 
			settings.m_messages["Welcome"].c_str());
		WindowSettings & w=settings.m_windows.front();
		printf("%s: Show window '%s' at %d,%d (%d x %d)\n", 
			settings.m_name.c_str(), w.name.c_str(), w.x, w.y, w.w, w.h);
		printf("%s: %s\n", settings.m_name.c_str(), settings.m_messages["Farewell"].c_str());
	}
	return 0;
}

When the save() and load() are completed (see below), running this main() displays on the console:

HitchHikerApp: Don't Panic
HitchHikerApp: Show window 'BookFrame' at 15,25 (300 x 100)
HitchHikerApp: Thanks for all the fish

Encode C++ state as XML

There are lots of different ways to approach saving this to a file. Here's one:

void AppSettings::save(const char* pFilename)
{
	TiXmlDocument doc;  
	TiXmlElement* msg;
	TiXmlComment * comment;
	string s;
 	TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );  
	doc.LinkEndChild( decl ); 
 
	TiXmlElement * root = new TiXmlElement(m_name.c_str());  
	doc.LinkEndChild( root );  

	comment = new TiXmlComment();
	s=" Settings for "+m_name+" ";
	comment->SetValue(s.c_str());  
	root->LinkEndChild( comment );  

	// block: messages
	{
		MessageMap::iterator iter;

		TiXmlElement * msgs = new TiXmlElement( "Messages" );  
		root->LinkEndChild( msgs );  
 
		for (iter=m_messages.begin(); iter != m_messages.end(); iter++)
		{
			const string & key=(*iter).first;
			const string & value=(*iter).second;
			msg = new TiXmlElement(key.c_str());  
			msg->LinkEndChild( new TiXmlText(value.c_str()));  
			msgs->LinkEndChild( msg );  
		}
	}

	// block: windows
	{
		TiXmlElement * windowsNode = new TiXmlElement( "Windows" );  
		root->LinkEndChild( windowsNode );  

		list<WindowSettings>::iterator iter;

		for (iter=m_windows.begin(); iter != m_windows.end(); iter++)
		{
			const WindowSettings& w=*iter;

			TiXmlElement * window;
			window = new TiXmlElement( "Window" );  
			windowsNode->LinkEndChild( window );  
			window->SetAttribute("name", w.name.c_str());
			window->SetAttribute("x", w.x);
			window->SetAttribute("y", w.y);
			window->SetAttribute("w", w.w);
			window->SetAttribute("h", w.h);
		}
	}

	// block: connection
	{
		TiXmlElement * cxn = new TiXmlElement( "Connection" );  
		root->LinkEndChild( cxn );  
		cxn->SetAttribute("ip", m_connection.ip.c_str());
		cxn->SetDoubleAttribute("timeout", m_connection.timeout); 
	}

	doc.SaveFile(pFilename);  
}

Running this with the modified main produces this file:

<?xml version="1.0" ?>
<HitchHikerApp>
    <!-- Settings for HitchHikerApp -->
    <Messages>
        <Farewell>Thanks for all the fish</Farewell>
        <Welcome>Don&apos;t Panic</Welcome>
    </Messages>
    <Windows>
        <Window name="BookFrame" x="15" y="25" w="300" h="250" />
    </Windows>
    <Connection ip="192.168.0.77" timeout="42.000000" />
</HitchHikerApp>

Decoding state from XML

As with encoding objects, there are a number of approaches to decoding XML into your own C++ object structure. The following approach uses TiXmlHandles.

void AppSettings::load(const char* pFilename)
{
	TiXmlDocument doc(pFilename);
	if (!doc.LoadFile()) return;

	TiXmlHandle hDoc(&doc);
	TiXmlElement* pElem;
	TiXmlHandle hRoot(0);

	// block: name
	{
		pElem=hDoc.FirstChildElement().Element();
		// should always have a valid root but handle gracefully if it does
		if (!pElem) return;
		m_name=pElem->Value();

		// save this for later
		hRoot=TiXmlHandle(pElem);
	}

	// block: string table
	{
		m_messages.clear(); // trash existing table

		pElem=hRoot.FirstChild( "Messages" ).FirstChild().Element();
		for( pElem; pElem; pElem=pElem->NextSiblingElement())
		{
			const char *pKey=pElem->Value();
			const char *pText=pElem->GetText();
			if (pKey && pText) 
			{
				m_messages[pKey]=pText;
			}
		}
	}

	// block: windows
	{
		m_windows.clear(); // trash existing list

		TiXmlElement* pWindowNode=hRoot.FirstChild( "Windows" ).FirstChild().Element();
		for( pWindowNode; pWindowNode; pWindowNode=pWindowNode->NextSiblingElement())
		{
			WindowSettings w;
			const char *pName=pWindowNode->Attribute("name");
			if (pName) w.name=pName;
			
			pWindowNode->QueryIntAttribute("x", &w.x); // If this fails, original value is left as-is
			pWindowNode->QueryIntAttribute("y", &w.y);
			pWindowNode->QueryIntAttribute("w", &w.w);
			pWindowNode->QueryIntAttribute("hh", &w.h);

			m_windows.push_back(w);
		}
	}

	// block: connection
	{
		pElem=hRoot.FirstChild("Connection").Element();
		if (pElem)
		{
			m_connection.ip=pElem->Attribute("ip");
			pElem->QueryDoubleAttribute("timeout",&m_connection.timeout);
		}
	}
}

Full listing for dump_to_stdout

Below is a copy-and-paste demo program for loading arbitrary XML files and dumping the structure to STDOUT using the recursive traversal listed above.

// tutorial demo program
#include "stdafx.h"
#include "tinyxml.h"

// ----------------------------------------------------------------------
// STDOUT dump and indenting utility functions
// ----------------------------------------------------------------------
const unsigned int NUM_INDENTS_PER_SPACE=2;

const char * getIndent( unsigned int numIndents )
{
	static const char * pINDENT="                                      + ";
	static const unsigned int LENGTH=strlen( pINDENT );
	unsigned int n=numIndents*NUM_INDENTS_PER_SPACE;
	if ( n > LENGTH ) n = LENGTH;

	return &pINDENT[ LENGTH-n ];
}

// same as getIndent but no "+" at the end
const char * getIndentAlt( unsigned int numIndents )
{
	static const char * pINDENT="                                        ";
	static const unsigned int LENGTH=strlen( pINDENT );
	unsigned int n=numIndents*NUM_INDENTS_PER_SPACE;
	if ( n > LENGTH ) n = LENGTH;

	return &pINDENT[ LENGTH-n ];
}

int dump_attribs_to_stdout(TiXmlElement* pElement, unsigned int indent)
{
	if ( !pElement ) return 0;

	TiXmlAttribute* pAttrib=pElement->FirstAttribute();
	int i=0;
	int ival;
	double dval;
	const char* pIndent=getIndent(indent);
	printf("\n");
	while (pAttrib)
	{
		printf( "%s%s: value=[%s]", pIndent, pAttrib->Name(), pAttrib->Value());

		if (pAttrib->QueryIntValue(&ival)==TIXML_SUCCESS)    printf( " int=%d", ival);
		if (pAttrib->QueryDoubleValue(&dval)==TIXML_SUCCESS) printf( " d=%1.1f", dval);
		printf( "\n" );
		i++;
		pAttrib=pAttrib->Next();
	}
	return i;	
}

void dump_to_stdout( TiXmlNode* pParent, unsigned int indent = 0 )
{
	if ( !pParent ) return;

	TiXmlNode* pChild;
	TiXmlText* pText;
	int t = pParent->Type();
	printf( "%s", getIndent(indent));
	int num;

	switch ( t )
	{
	case TiXmlNode::TINYXML_DOCUMENT:
		printf( "Document" );
		break;

	case TiXmlNode::TINYXML_ELEMENT:
		printf( "Element [%s]", pParent->Value() );
		num=dump_attribs_to_stdout(pParent->ToElement(), indent+1);
		switch(num)
		{
			case 0:  printf( " (No attributes)"); break;
			case 1:  printf( "%s1 attribute", getIndentAlt(indent)); break;
			default: printf( "%s%d attributes", getIndentAlt(indent), num); break;
		}
		break;

	case TiXmlNode::TINYXML_COMMENT:
		printf( "Comment: [%s]", pParent->Value());
		break;

	case TiXmlNode::TINYXML_UNKNOWN:
		printf( "Unknown" );
		break;

	case TiXmlNode::TINYXML_TEXT:
		pText = pParent->ToText();
		printf( "Text: [%s]", pText->Value() );
		break;

	case TiXmlNode::TINYXML_DECLARATION:
		printf( "Declaration" );
		break;
	default:
		break;
	}
	printf( "\n" );
	for ( pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) 
	{
		dump_to_stdout( pChild, indent+1 );
	}
}

// load the named file and dump its structure to STDOUT
void dump_to_stdout(const char* pFilename)
{
	TiXmlDocument doc(pFilename);
	bool loadOkay = doc.LoadFile();
	if (loadOkay)
	{
		printf("\n%s:\n", pFilename);
		dump_to_stdout( &doc ); // defined later in the tutorial
	}
	else
	{
		printf("Failed to load file \"%s\"\n", pFilename);
	}
}

// ----------------------------------------------------------------------
// main() for printing files named on the command line
// ----------------------------------------------------------------------
int main(int argc, char* argv[])
{
	for (int i=1; i<argc; i++)
	{
		dump_to_stdout(argv[i]);
	}
	return 0;
}

Run this from the command line or a DOS window, e.g.:

C:\dev\tinyxml> Debug\tinyxml_1.exe example1.xml

example1.xml:
Document
+ Declaration
+ Element [Hello]
 (No attributes)
  + Text: [World]

Authors and Changes

  • Written by Ellers, April, May, June 2005
  • Minor edits and integration into doc system, Lee Thomason September 2005
  • Updated by Ellers, October 2005


Generated by  doxygen 1.6.2