• Main Page
  • Namespaces
  • Classes
  • Files
  • Directories
  • File List
  • File Members

writertest.cpp

Go to the documentation of this file.
00001 
00002  //
00003  // XML storage classes
00004  //
00005  // writertest.cpp
00006  //
00007  // Copyright (c) 2005 Martin Fuchs <martin-fuchs@gmx.net>
00008  //
00009 
00010 
00011 /*
00012 
00013   All rights reserved.
00014 
00015   Redistribution and use in source and binary forms, with or without
00016   modification, are permitted provided that the following conditions are met:
00017 
00018   * Redistributions of source code must retain the above copyright
00019     notice, this list of conditions and the following disclaimer.
00020   * Redistributions in binary form must reproduce the above copyright
00021     notice, this list of conditions and the following disclaimer in
00022     the documentation and/or other materials provided with the
00023     distribution.
00024 
00025   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00026   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00028   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00029   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00030   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00031   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00032   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00033   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00034   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00035   POSSIBILITY OF SUCH DAMAGE.
00036 
00037 */
00038 
00039 //#define XS_USE_EXPAT
00040 
00041 //#define XML_STATIC
00042 #include <xmlstorage.h>
00043 using namespace XMLStorage;
00044 
00045 #include <iostream>
00046 using namespace std;
00047 
00048 
00049 void test_writer()
00050 {
00051     XMLWriter wr("writertest.xml");
00052 
00053     wr.create("root");
00054 
00055       wr.create("example1");
00056         wr.create("PARAMS");
00057           wr.create("TEXT");
00058             wr.set_content("Testgruppe");
00059           wr.back(); // </TEXT>
00060 
00061           wr.create("COLOR");
00062             wr.create("RED");
00063             wr.set_content("234");
00064             wr.back(); // </RED>
00065 
00066             wr.create("GREEN");
00067             wr.set_content("22");
00068             wr.back(); // </GREEN>
00069 
00070             wr.create("BLUE");
00071             wr.set_content("33");
00072             wr.back(); // </BLUE>
00073           wr.back(); // </COLOR>
00074 
00075           wr.create("FONT");
00076             wr.create("FONT_FILENAME");
00077             wr.set_content("Arial.ttf");
00078             wr.back(); // </FONT_FILENAME>
00079 
00080             wr.create("SIZE");
00081             wr.set_content("12");
00082             wr.back(); // </SIZE>
00083           wr.back(); // </FONT>
00084         wr.back(); // </PARAMS>
00085       wr.back(); // </example1>
00086 
00087       wr.create("example2");
00088         wr.create("PARAMS");
00089           wr["text"] = "Testgruppe";
00090 
00091           wr.create("COLOR");
00092             wr["red"] = XMLInt(234);
00093             wr["green"] = XMLInt(22);
00094             wr["blue"] = XMLInt(33);
00095           wr.back(); // </COLOR>
00096 
00097           wr.create("FONT");
00098             wr["font_filename"] = "Arial.ttf";
00099             wr["size"] = XMLInt(12);
00100           wr.back(); // </FONT>
00101         wr.back(); // </PARAMS>
00102       wr.back(); // </example2>
00103 
00104       wr.create("example3");
00105         wr.create("Y_ACHSE");
00106           wr["Stopbits"] = XMLInt(1);
00107           wr["Parity"] = "N";
00108         wr.back();
00109       wr.back(); // </example3>
00110 
00111     wr.back(); // </root>
00112 }
00113 
00114 
00115 int main()
00116 {
00117     test_writer();
00118 
00119     return 0;
00120 }

Generated on Fri Nov 14 2014 00:05:04 for XMLStorage/C++ by  doxygen 1.7.2