2 #include "../../contrib/pugixml-1.4/src/pugixml.hpp"
3 #include "../../contrib/pugixml-1.4/src/pugixml.cpp"
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
11 int main(int argc, char ** argv)
13 pugi::xml_document doc_xml;
15 pugi::xml_parse_result result = doc_xml.load(cin); // load from stdin
19 Fatal("XML from stdin has errors: %s", result.description());
22 Debug("pugixml load result was: %s", result.description());
24 for (pugi::xml_node rect : doc_xml.children("rect"))
28 const char * attrib_names[] = {"x", "y", "w", "h"};
29 for (size_t i = 0; i < sizeof(attrib_names)/sizeof(char*); ++i)
31 coords[i] = rect.attribute(attrib_names[i]).as_float();
35 outline = rect.attribute("outline").as_bool();
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]));