[Xmlstorage-commits] SF.net SVN: xmlstorage: [77] trunk/c++
Brought to you by:
martinfuchs
|
From: <mar...@us...> - 2008-01-30 23:09:22
|
Revision: 77
http://xmlstorage.svn.sourceforge.net/xmlstorage/?rev=77&view=rev
Author: martinfuchs
Date: 2008-01-30 15:09:16 -0800 (Wed, 30 Jan 2008)
Log Message:
-----------
added XMLPos::delete_this() and XMLNode::Children::remove() to allow removing of XML nodes
Modified Paths:
--------------
trunk/c++/xmlstorage.dsw
trunk/c++/xmlstorage.h
Added Paths:
-----------
trunk/c++/example5.cpp
trunk/c++/example5.dsp
Added: trunk/c++/example5.cpp
===================================================================
--- trunk/c++/example5.cpp (rev 0)
+++ trunk/c++/example5.cpp 2008-01-30 23:09:16 UTC (rev 77)
@@ -0,0 +1,99 @@
+
+ //
+ // XML storage classes
+ //
+ // example5.cpp
+ //
+ // Copyright (c) 2008 Martin Fuchs <mar...@gm...>
+ //
+
+
+/*
+
+ 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.
+
+*/
+
+#include <xmlstorage.h>
+using namespace XMLStorage;
+
+#include <iostream>
+using namespace std;
+
+
+void test_write()
+{
+ XMLDoc doc;
+ XMLPos pos(&doc);
+
+ // Zusammenstellen der XML-Struktur im Dokument 'doc'
+ pos.create("PERSON");
+
+ pos.create("NAME");
+ pos->set_content("Mustername");
+ pos.back(); // </NAME>
+
+ pos.create("VORNAME");
+ pos->set_content("Mustervorname");
+ pos.back(); // </VORNAME>
+
+ pos.create("ADRESSE");
+ pos->set_content("Musteradresse");
+ pos.back(); // </ADRESSE>
+
+ pos.back(); // </PERSON>
+
+ // Schreiben der XML-Datei
+ doc.write_file("example5.xml");
+}
+
+
+void test_delete()
+{
+ XMLDoc doc;
+
+ // Einlesen des XML-Files
+ doc.read_file("example5.xml");
+
+ XMLPos pos(&doc);
+
+
+ pos.go_down("PERSON");
+ pos.go_down("VORNAME");
+ pos.delete_this();
+ pos.back(); // </PERSON>
+
+ // Schreiben der XML-Datei
+ doc.write_file("example5.xml");
+}
+
+
+int main()
+{
+ test_write();
+ test_delete();
+
+ return 0;
+}
Property changes on: trunk/c++/example5.cpp
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/c++/example5.dsp
===================================================================
--- trunk/c++/example5.dsp (rev 0)
+++ trunk/c++/example5.dsp 2008-01-30 23:09:16 UTC (rev 77)
@@ -0,0 +1,97 @@
+# Microsoft Developer Studio Project File - Name="example5" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=example5 - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "example5.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "example5.mak" CFG="example5 - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "example5 - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "example5 - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "example5 - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "."
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x407 /d "NDEBUG"
+# ADD RSC /l 0x407 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 /nologo /subsystem:console /machine:I386
+# SUBTRACT LINK32 /verbose
+
+!ELSEIF "$(CFG)" == "example5 - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /FR /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x407 /d "_DEBUG"
+# ADD RSC /l 0x407 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "example5 - Win32 Release"
+# Name "example5 - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\example5.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\example5.xml
+# End Source File
+# End Target
+# End Project
Property changes on: trunk/c++/example5.dsp
___________________________________________________________________
Name: svn:eol-style
+ CRLF
Modified: trunk/c++/xmlstorage.dsw
===================================================================
--- trunk/c++/xmlstorage.dsw 2008-01-30 23:07:48 UTC (rev 76)
+++ trunk/c++/xmlstorage.dsw 2008-01-30 23:09:16 UTC (rev 77)
@@ -48,6 +48,30 @@
###############################################################################
+Project: "example4"=.\example4.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "example5"=.\example5.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
Project: "writertest"=.\writertest.dsp - Package Owner=<4>
Package=<5>
Modified: trunk/c++/xmlstorage.h
===================================================================
--- trunk/c++/xmlstorage.h 2008-01-30 23:07:48 UTC (rev 76)
+++ trunk/c++/xmlstorage.h 2008-01-30 23:09:16 UTC (rev 77)
@@ -2,7 +2,7 @@
//
// XML storage C++ classes version 1.2
//
- // Copyright (c) 2004, 2005, 2006, 2007 Martin Fuchs <mar...@gm...>
+ // Copyright (c) 2004, 2005, 2006, 2007, 2008 Martin Fuchs <mar...@gm...>
//
/// \file xmlstorage.h
@@ -265,10 +265,7 @@
#endif
-int inline isxmlsym(unsigned char c)
-{
- return isalnum(c) || c=='_' || c=='-';
-}
+extern const char* get_xmlsym_end_utf8(const char* p);
#if defined(_STRING_DEFINED) && !defined(XS_STRING_UTF8)
@@ -860,6 +857,17 @@
delete node;
}
}
+
+ bool remove(XMLNode* node)
+ {
+ for(iterator it=begin(); it!=end(); ++it)
+ if (*it == node) {
+ erase(it);
+ return true;
+ }
+
+ return false;
+ }
};
// access to protected class members for XMLPos and XMLReader
@@ -1452,6 +1460,21 @@
return false;
}
+ /// delete current node and go back to previous position
+ bool delete_this()
+ {
+ if (!_stack.empty()) {
+ XMLNode* pLast = _stack.top();
+
+ if (pLast->_children.remove(_cur)) {
+ _cur = _stack.top();
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/// go down to first child
bool go_down()
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|