David's final changes: more profiler features, fixes.
[ipdf/code.git] / src / tests / xml.cpp
1 #include "main.h"
2 #include "../../contrib/pugixml-1.4/src/pugixml.hpp"
3 #include "../../contrib/pugixml-1.4/src/pugixml.cpp"
4
5 using namespace std;
6
7 /**
8  * This tester reads XML and uses it to produce rectangles in our viewer
9  * We use pugixml because I really didn't feel like implementing an XML parser
10  */
11 int main(int argc, char ** argv)
12 {
13         pugi::xml_document doc_xml;
14         Document doc;
15         pugi::xml_parse_result result = doc_xml.load(cin); // load from stdin
16         
17         if (!result)
18         {
19                 Fatal("XML from stdin has errors: %s", result.description());
20         }
21
22         Debug("pugixml load result was: %s", result.description());
23         int count = 0;
24         for (pugi::xml_node rect : doc_xml.children("rect"))
25         {
26                         
27                 Real coords[4];
28                 const char * attrib_names[] = {"x", "y", "w", "h"};
29                 for (size_t i = 0; i < sizeof(attrib_names)/sizeof(char*); ++i)
30                 {
31                         coords[i] = rect.attribute(attrib_names[i]).as_float();
32                 }
33
34                 bool outline = false;
35                 outline = rect.attribute("outline").as_bool();
36
37                 Debug("rect node %d is {%lf, %lf, %lf, %lf} (%s)", count++, coords[0], coords[1], coords[2], coords[3], (outline) ? "outline" : "filled");
38                 doc.Add(outline?RECT_OUTLINE:RECT_FILLED, Rect(coords[0], coords[1], coords[2], coords[3]));
39         }
40
41
42         MainLoop(doc);
43
44         
45
46         return 0;
47 }

UCC git Repository :: git.ucc.asn.au