Revision: 84
http://xmlstorage.svn.sourceforge.net/xmlstorage/?rev=84&view=rev
Author: martinfuchs
Date: 2008-02-04 01:35:15 -0800 (Mon, 04 Feb 2008)
Log Message:
-----------
add xmltest for D
Added Paths:
-----------
trunk/d/xmltest.d
Added: trunk/d/xmltest.d
===================================================================
--- trunk/d/xmltest.d (rev 0)
+++ trunk/d/xmltest.d 2008-02-04 09:35:15 UTC (rev 84)
@@ -0,0 +1,117 @@
+module xmltest;
+
+ //
+ // XML storage D classes version 1.2
+ //
+ // Copyright (c) 2004, 2005, 2006, 2007 Martin Fuchs <mar...@gm...>
+ //
+
+ /// \file xmltest.d
+ /// XMLStorage example file
+
+
+/*
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+import xmlstorage;
+import std.stdio;
+
+
+bool xml_test()
+{
+ auto doc = new XMLDoc;
+ bool ret;
+
+ //ret = doc.read_file("poem.xml");
+ //ret = doc.read_file("machines.xml");
+ ret = doc.read_file("packets.xml");
+
+ if (!ret) {
+ fwritef(stderr, doc._errors.str());
+ return false;
+ }
+
+ doc.write_file("out.xml");
+
+ auto pos = new XMLPos(doc);
+
+// if (pos.go("get_packets/packet"))
+// if (pos.go("/get_packets/packet"))
+// if (pos.go("/get_packets/packet[5]"))
+ if (pos.go("/get_packets/packet[@db_id=\"7628\"]"))
+// if (pos.go("get_machines/machine[@wsid=\"client2\"]"))
+ {
+ writefln("db_id = " ~ pos.get("db_id"));
+ writefln("name = " ~ pos.get("name"));
+ writefln("short_name = ", pos.get("short_name"));
+/*@@
+ writefln("db_id = %d", XMLInt(pos, "db_id"));
+ writefln("name = %s", XMLString(pos, "name").c_str());
+ writefln("short_name = %s", XMLString(pos, "short_name").c_str());
+*/
+ pos.back();
+ }
+
+ return true;
+}
+
+
+void print_gc_stats()
+{
+ std.gc.GCStats stats;
+ std.gc.getStats(stats);
+
+ printf("poolsize = x%x, usedsize = x%x, freelistsize = x%x, freeblocks = %d, pageblocks = %d\n",
+ stats.poolsize, stats.usedsize, stats.freelistsize, stats.freeblocks, stats.pageblocks);
+}
+
+int main(char[][] args)
+{
+ writefln(); // insert an empty line after unit test output
+
+ print_gc_stats();
+ writefln();
+
+ int ret = xml_test()? 0: 1;
+
+ writefln();
+ print_gc_stats();
+
+ writefln();
+
+ std.gc.minimize();
+ print_gc_stats();
+
+ std.gc.genCollect();
+ print_gc_stats();
+
+ std.gc.fullCollect();
+ print_gc_stats();
+
+ return ret;
+}
Property changes on: trunk/d/xmltest.d
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|