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

xmltest.d

Go to the documentation of this file.
00001 module xmltest;
00002 
00003  //
00004  // XML storage D classes version 1.2
00005  //
00006  // Copyright (c) 2004, 2005, 2006, 2007 Martin Fuchs <martin-fuchs@gmx.net>
00007  //
00008 
00009  /// \file xmltest.d
00010  /// XMLStorage example file
00011 
00012 
00013 /*
00014 
00015  All rights reserved.
00016 
00017  Redistribution and use in source and binary forms, with or without
00018  modification, are permitted provided that the following conditions are met:
00019 
00020  * Redistributions of source code must retain the above copyright
00021     notice, this list of conditions and the following disclaimer.
00022  * Redistributions in binary form must reproduce the above copyright
00023     notice, this list of conditions and the following disclaimer in
00024     the documentation and/or other materials provided with the
00025     distribution.
00026 
00027  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00028  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00029  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00030  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00031  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00032  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00033  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00034  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00035  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00036  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00037  POSSIBILITY OF SUCH DAMAGE.
00038 
00039 */
00040 
00041 import xmlstorage;
00042 import std.stdio;
00043 
00044 
00045 bool xml_test()
00046 {
00047     auto doc = new XMLDoc;
00048     bool ret;
00049 
00050     //ret = doc.read_file("poem.xml");
00051     //ret = doc.read_file("machines.xml");
00052     ret = doc.read_file("packets.xml");
00053 
00054     if (!ret) {
00055         fwritef(stderr, doc._errors.str());
00056         return false;
00057     }
00058 
00059     doc.write_file("out.xml");
00060 
00061     auto pos = new XMLPos(doc);
00062 
00063 //  if (pos.go("get_packets/packet"))
00064 //  if (pos.go("/get_packets/packet"))
00065 //  if (pos.go("/get_packets/packet[5]"))
00066     if (pos.go("/get_packets/packet[@db_id=\"7628\"]"))
00067 //  if (pos.go("get_machines/machine[@wsid=\"client2\"]"))
00068     {
00069         writefln("db_id = " ~ pos.get("db_id"));
00070         writefln("name = " ~ pos.get("name"));
00071         writefln("short_name = ", pos.get("short_name"));
00072 /*@@
00073         writefln("db_id = %d", XMLInt(pos, "db_id"));
00074         writefln("name = %s", XMLString(pos, "name").c_str());
00075         writefln("short_name = %s", XMLString(pos, "short_name").c_str());
00076 */
00077         pos.back();
00078     }
00079 
00080     return true;
00081 }
00082 
00083 
00084 void print_gc_stats()
00085 {
00086     std.gc.GCStats stats;
00087     std.gc.getStats(stats);
00088 
00089     printf("poolsize = x%x, usedsize = x%x, freelistsize = x%x, freeblocks = %d, pageblocks = %d\n",
00090             stats.poolsize, stats.usedsize, stats.freelistsize, stats.freeblocks, stats.pageblocks);
00091 }
00092 
00093 int main(char[][] args)
00094 {
00095     writefln(); // insert an empty line after unit test output
00096 
00097     print_gc_stats();
00098     writefln();
00099 
00100     int ret = xml_test()? 0: 1;
00101 
00102     writefln();
00103     print_gc_stats();
00104 
00105     writefln();
00106 
00107     std.gc.minimize();
00108     print_gc_stats();
00109 
00110     std.gc.genCollect();
00111     print_gc_stats();
00112 
00113     std.gc.fullCollect();
00114     print_gc_stats();
00115 
00116     return ret;
00117 }

Generated on Thu Nov 11 2010 22:11:39 for XMLStorage/D by  doxygen 1.7.2