diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-07-03 00:28:59 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-07-03 00:28:59 +0000 |
commit | ac517a2b7625e0aa0862679e961c6349f859ea3b (patch) | |
tree | e3e27a6b9bd5e2be6150088495c91fc91786ad9d /src/old | |
parent | f8d4301e9fa4f3709258505941e37fab2eadadc6 (diff) | |
parent | bd865cee5f89116c1f054cd0e5c275e97c2d0a9b (diff) | |
download | libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.gz libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.bz2 libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.tar.xz libbu++-ac517a2b7625e0aa0862679e961c6349f859ea3b.zip |
The reorg is being put in trunk, I think it's ready. Now we just get to find
out how many applications won't work anymore :)
Diffstat (limited to '')
-rw-r--r-- | src/old/cgi.cpp (renamed from src/cgi.cpp) | 0 | ||||
-rw-r--r-- | src/old/cgi.h (renamed from src/cgi.h) | 0 | ||||
-rw-r--r-- | src/old/configmanagerbase.cpp (renamed from src/configmanagerbase.cpp) | 0 | ||||
-rw-r--r-- | src/old/configmanagerbase.h (renamed from src/configmanagerbase.h) | 0 | ||||
-rw-r--r-- | src/old/confpair.cpp (renamed from src/confpair.cpp) | 0 | ||||
-rw-r--r-- | src/old/confpair.h (renamed from src/confpair.h) | 0 | ||||
-rw-r--r-- | src/old/confpairbase.cpp (renamed from src/confpairbase.cpp) | 0 | ||||
-rw-r--r-- | src/old/confpairbase.h (renamed from src/confpairbase.h) | 0 | ||||
-rw-r--r-- | src/old/conftree.cpp (renamed from src/conftree.cpp) | 0 | ||||
-rw-r--r-- | src/old/conftree.h (renamed from src/conftree.h) | 0 | ||||
-rw-r--r-- | src/old/connection.cpp (renamed from src/connection.cpp) | 0 | ||||
-rw-r--r-- | src/old/connection.h (renamed from src/connection.h) | 0 | ||||
-rw-r--r-- | src/old/connectionmanager.cpp (renamed from src/connectionmanager.cpp) | 0 | ||||
-rw-r--r-- | src/old/connectionmanager.h (renamed from src/connectionmanager.h) | 0 | ||||
-rw-r--r-- | src/old/connectionmonitor.cpp (renamed from src/connectionmonitor.cpp) | 0 | ||||
-rw-r--r-- | src/old/connectionmonitor.h (renamed from src/connectionmonitor.h) | 0 | ||||
-rw-r--r-- | src/old/flexbuf.cpp (renamed from src/flexbuf.cpp) | 0 | ||||
-rw-r--r-- | src/old/flexbuf.h (renamed from src/flexbuf.h) | 0 | ||||
-rw-r--r-- | src/old/formula.cpp (renamed from src/formula.cpp) | 0 | ||||
-rw-r--r-- | src/old/formula.h (renamed from src/formula.h) | 0 | ||||
-rw-r--r-- | src/old/http.cpp (renamed from src/http.cpp) | 0 | ||||
-rw-r--r-- | src/old/http.h (renamed from src/http.h) | 0 | ||||
-rw-r--r-- | src/old/httpget.cpp (renamed from src/httpget.cpp) | 0 | ||||
-rw-r--r-- | src/old/httpget.h (renamed from src/httpget.h) | 0 | ||||
-rw-r--r-- | src/old/linkedlist.cpp (renamed from src/linkedlist.cpp) | 0 | ||||
-rw-r--r-- | src/old/linkedlist.h (renamed from src/linkedlist.h) | 0 | ||||
-rw-r--r-- | src/old/linkmessenger.cpp (renamed from src/linkmessenger.cpp) | 0 | ||||
-rw-r--r-- | src/old/linkmessenger.h (renamed from src/linkmessenger.h) | 0 | ||||
-rw-r--r-- | src/old/list.cpp | 10 | ||||
-rw-r--r-- | src/old/list.h | 101 | ||||
-rw-r--r-- | src/old/md5.cpp (renamed from src/md5.cpp) | 0 | ||||
-rw-r--r-- | src/old/md5.h (renamed from src/md5.h) | 0 | ||||
-rw-r--r-- | src/old/multilog.cpp (renamed from src/multilog.cpp) | 0 | ||||
-rw-r--r-- | src/old/multilog.h (renamed from src/multilog.h) | 0 | ||||
-rw-r--r-- | src/old/multilogchannel.cpp (renamed from src/multilogchannel.cpp) | 0 | ||||
-rw-r--r-- | src/old/multilogchannel.h (renamed from src/multilogchannel.h) | 0 | ||||
-rw-r--r-- | src/old/multilogtext.cpp (renamed from src/multilogtext.cpp) | 0 | ||||
-rw-r--r-- | src/old/multilogtext.h (renamed from src/multilogtext.h) | 0 | ||||
-rw-r--r-- | src/old/ordhash.cpp (renamed from src/ordhash.cpp) | 0 | ||||
-rw-r--r-- | src/old/ordhash.h (renamed from src/ordhash.h) | 0 | ||||
-rw-r--r-- | src/old/pqueue.cpp (renamed from src/pqueue.cpp) | 0 | ||||
-rw-r--r-- | src/old/pqueue.h (renamed from src/pqueue.h) | 0 | ||||
-rw-r--r-- | src/old/protocol.cpp | 20 | ||||
-rw-r--r-- | src/old/protocol.h | 62 | ||||
-rw-r--r-- | src/old/protocoltelnet.cpp (renamed from src/protocoltelnet.cpp) | 0 | ||||
-rw-r--r-- | src/old/protocoltelnet.h (renamed from src/protocoltelnet.h) | 0 | ||||
-rw-r--r-- | src/old/queue.cpp (renamed from src/queue.cpp) | 0 | ||||
-rw-r--r-- | src/old/queue.h (renamed from src/queue.h) | 0 | ||||
-rw-r--r-- | src/old/ringlist.cpp (renamed from src/ringlist.cpp) | 0 | ||||
-rw-r--r-- | src/old/ringlist.h (renamed from src/ringlist.h) | 0 | ||||
-rw-r--r-- | src/old/sbuffer.cpp (renamed from src/sbuffer.cpp) | 0 | ||||
-rw-r--r-- | src/old/sbuffer.h (renamed from src/sbuffer.h) | 0 | ||||
-rw-r--r-- | src/old/serializerbinary.cpp (renamed from src/serializerbinary.cpp) | 0 | ||||
-rw-r--r-- | src/old/serializerbinary.h (renamed from src/serializerbinary.h) | 0 | ||||
-rw-r--r-- | src/old/serializerbzip2.cpp (renamed from src/serializerbzip2.cpp) | 0 | ||||
-rw-r--r-- | src/old/serializerbzip2.h (renamed from src/serializerbzip2.h) | 0 | ||||
-rw-r--r-- | src/old/serializerconnection.cpp (renamed from src/serializerconnection.cpp) | 0 | ||||
-rw-r--r-- | src/old/serializerconnection.h (renamed from src/serializerconnection.h) | 0 | ||||
-rw-r--r-- | src/old/serializertext.cpp (renamed from src/serializertext.cpp) | 0 | ||||
-rw-r--r-- | src/old/serializertext.h (renamed from src/serializertext.h) | 0 | ||||
-rw-r--r-- | src/old/sha1.cpp (renamed from src/sha1.cpp) | 0 | ||||
-rw-r--r-- | src/old/sha1.h (renamed from src/sha1.h) | 0 | ||||
-rw-r--r-- | src/old/stack.cpp (renamed from src/stack.cpp) | 0 | ||||
-rw-r--r-- | src/old/stack.h (renamed from src/stack.h) | 0 | ||||
-rw-r--r-- | src/old/staticstring.cpp (renamed from src/staticstring.cpp) | 0 | ||||
-rw-r--r-- | src/old/staticstring.h (renamed from src/staticstring.h) | 0 | ||||
-rw-r--r-- | src/old/stringrep.cpp (renamed from src/stringrep.cpp) | 0 | ||||
-rw-r--r-- | src/old/stringrep.h (renamed from src/stringrep.h) | 0 | ||||
-rw-r--r-- | src/old/tests/clistress.cpp (renamed from src/tests/clistress.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/confpair.cpp (renamed from src/tests/confpair.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/connect.cpp (renamed from src/tests/connect.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/exception.cpp (renamed from src/tests/exception.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/formula.cpp (renamed from src/tests/formula.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/hash.cpp | 116 | ||||
-rw-r--r-- | src/old/tests/hashtest.cpp (renamed from src/tests/hashtest.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/hashtest2.cpp (renamed from src/tests/hashtest2.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/httpsrv/httpconnectionmonitor.cpp (renamed from src/tests/httpsrv/httpconnectionmonitor.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/httpsrv/httpconnectionmonitor.h (renamed from src/tests/httpsrv/httpconnectionmonitor.h) | 0 | ||||
-rw-r--r-- | src/old/tests/httpsrv/main.cpp (renamed from src/tests/httpsrv/main.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/log.cpp (renamed from src/tests/log.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/md5test.cpp (renamed from src/tests/md5test.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/ordhash.cpp (renamed from src/tests/ordhash.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/param.cpp (renamed from src/tests/param.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/param.h (renamed from src/tests/param.h) | 0 | ||||
-rw-r--r-- | src/old/tests/plugin/main.cpp (renamed from src/tests/plugin/main.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/plugin/plugin.cpp (renamed from src/tests/plugin/plugin.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/plugin/plugin.h (renamed from src/tests/plugin/plugin.h) | 0 | ||||
-rw-r--r-- | src/old/tests/qsort.cpp (renamed from src/tests/qsort.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/sbuffer.cpp (renamed from src/tests/sbuffer.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/serialize.cpp (renamed from src/tests/serialize.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/serializetext.cpp (renamed from src/tests/serializetext.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/sha1.cpp (renamed from src/tests/sha1.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/sptr.cpp (renamed from src/tests/sptr.cpp) | 30 | ||||
-rw-r--r-- | src/old/tests/srvstress.cpp (renamed from src/tests/srvstress.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/strhash.cpp (renamed from src/tests/strhash.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/teltest/main.cpp (renamed from src/tests/teltest/main.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/teltest/telnetmonitor.cpp (renamed from src/tests/teltest/telnetmonitor.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/teltest/telnetmonitor.h (renamed from src/tests/teltest/telnetmonitor.h) | 0 | ||||
-rw-r--r-- | src/old/tests/xmlreadtest.cpp (renamed from src/tests/xmlreadtest.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/xmlrepltest.cpp (renamed from src/tests/xmlrepltest.cpp) | 0 | ||||
-rw-r--r-- | src/old/tests/xmlwritetest.cpp (renamed from src/tests/xmlwritetest.cpp) | 0 | ||||
-rw-r--r-- | src/old/tokenstring.cpp (renamed from src/tokenstring.cpp) | 0 | ||||
-rw-r--r-- | src/old/tokenstring.h (renamed from src/tokenstring.h) | 0 | ||||
-rw-r--r-- | src/old/tqsort.h (renamed from src/tqsort.h) | 0 | ||||
-rw-r--r-- | src/old/unit/hashtable/hashtable.cpp (renamed from src/unit/hashtable/hashtable.cpp) | 0 | ||||
-rw-r--r-- | src/old/unit/xml/xml.cpp (renamed from src/unit/xml/xml.cpp) | 0 | ||||
-rw-r--r-- | src/old/xmldocument.cpp (renamed from src/xmldocument.cpp) | 20 | ||||
-rw-r--r-- | src/old/xmldocument.h (renamed from src/xmldocument.h) | 8 | ||||
-rw-r--r-- | src/old/xmlfilereader.cpp (renamed from src/xmlfilereader.cpp) | 0 | ||||
-rw-r--r-- | src/old/xmlfilereader.h (renamed from src/xmlfilereader.h) | 0 | ||||
-rw-r--r-- | src/old/xmlfilewriter.cpp (renamed from src/xmlfilewriter.cpp) | 0 | ||||
-rw-r--r-- | src/old/xmlfilewriter.h (renamed from src/xmlfilewriter.h) | 0 | ||||
-rw-r--r-- | src/old/xmlnode.cpp (renamed from src/xmlnode.cpp) | 106 | ||||
-rw-r--r-- | src/old/xmlnode.h (renamed from src/xmlnode.h) | 101 | ||||
-rw-r--r-- | src/old/xmlreader.cpp (renamed from src/xmlreader.cpp) | 170 | ||||
-rw-r--r-- | src/old/xmlreader.h (renamed from src/xmlreader.h) | 31 | ||||
-rw-r--r-- | src/old/xmlstringreader.cpp (renamed from src/xmlstringreader.cpp) | 0 | ||||
-rw-r--r-- | src/old/xmlstringreader.h (renamed from src/xmlstringreader.h) | 0 | ||||
-rw-r--r-- | src/old/xmlstringwriter.cpp (renamed from src/xmlstringwriter.cpp) | 0 | ||||
-rw-r--r-- | src/old/xmlstringwriter.h (renamed from src/xmlstringwriter.h) | 0 | ||||
-rw-r--r-- | src/old/xmlwriter.cpp (renamed from src/xmlwriter.cpp) | 62 | ||||
-rw-r--r-- | src/old/xmlwriter.h (renamed from src/xmlwriter.h) | 16 |
122 files changed, 528 insertions, 325 deletions
diff --git a/src/cgi.cpp b/src/old/cgi.cpp index 1fecbbe..1fecbbe 100644 --- a/src/cgi.cpp +++ b/src/old/cgi.cpp | |||
diff --git a/src/cgi.h b/src/old/cgi.h index 01142b5..01142b5 100644 --- a/src/cgi.h +++ b/src/old/cgi.h | |||
diff --git a/src/configmanagerbase.cpp b/src/old/configmanagerbase.cpp index ac55fe0..ac55fe0 100644 --- a/src/configmanagerbase.cpp +++ b/src/old/configmanagerbase.cpp | |||
diff --git a/src/configmanagerbase.h b/src/old/configmanagerbase.h index 381cc1f..381cc1f 100644 --- a/src/configmanagerbase.h +++ b/src/old/configmanagerbase.h | |||
diff --git a/src/confpair.cpp b/src/old/confpair.cpp index 4741401..4741401 100644 --- a/src/confpair.cpp +++ b/src/old/confpair.cpp | |||
diff --git a/src/confpair.h b/src/old/confpair.h index 56eb06e..56eb06e 100644 --- a/src/confpair.h +++ b/src/old/confpair.h | |||
diff --git a/src/confpairbase.cpp b/src/old/confpairbase.cpp index 1203dc0..1203dc0 100644 --- a/src/confpairbase.cpp +++ b/src/old/confpairbase.cpp | |||
diff --git a/src/confpairbase.h b/src/old/confpairbase.h index 2530756..2530756 100644 --- a/src/confpairbase.h +++ b/src/old/confpairbase.h | |||
diff --git a/src/conftree.cpp b/src/old/conftree.cpp index d9a3a3f..d9a3a3f 100644 --- a/src/conftree.cpp +++ b/src/old/conftree.cpp | |||
diff --git a/src/conftree.h b/src/old/conftree.h index 197b1ef..197b1ef 100644 --- a/src/conftree.h +++ b/src/old/conftree.h | |||
diff --git a/src/connection.cpp b/src/old/connection.cpp index efef144..efef144 100644 --- a/src/connection.cpp +++ b/src/old/connection.cpp | |||
diff --git a/src/connection.h b/src/old/connection.h index 0e991c7..0e991c7 100644 --- a/src/connection.h +++ b/src/old/connection.h | |||
diff --git a/src/connectionmanager.cpp b/src/old/connectionmanager.cpp index ea60b2b..ea60b2b 100644 --- a/src/connectionmanager.cpp +++ b/src/old/connectionmanager.cpp | |||
diff --git a/src/connectionmanager.h b/src/old/connectionmanager.h index cff036b..cff036b 100644 --- a/src/connectionmanager.h +++ b/src/old/connectionmanager.h | |||
diff --git a/src/connectionmonitor.cpp b/src/old/connectionmonitor.cpp index 4f90ee6..4f90ee6 100644 --- a/src/connectionmonitor.cpp +++ b/src/old/connectionmonitor.cpp | |||
diff --git a/src/connectionmonitor.h b/src/old/connectionmonitor.h index 9910556..9910556 100644 --- a/src/connectionmonitor.h +++ b/src/old/connectionmonitor.h | |||
diff --git a/src/flexbuf.cpp b/src/old/flexbuf.cpp index 6d55294..6d55294 100644 --- a/src/flexbuf.cpp +++ b/src/old/flexbuf.cpp | |||
diff --git a/src/flexbuf.h b/src/old/flexbuf.h index 7d7f11a..7d7f11a 100644 --- a/src/flexbuf.h +++ b/src/old/flexbuf.h | |||
diff --git a/src/formula.cpp b/src/old/formula.cpp index cf63cf3..cf63cf3 100644 --- a/src/formula.cpp +++ b/src/old/formula.cpp | |||
diff --git a/src/formula.h b/src/old/formula.h index 939eb09..939eb09 100644 --- a/src/formula.h +++ b/src/old/formula.h | |||
diff --git a/src/http.cpp b/src/old/http.cpp index df7dafe..df7dafe 100644 --- a/src/http.cpp +++ b/src/old/http.cpp | |||
diff --git a/src/http.h b/src/old/http.h index 7e9f9a0..7e9f9a0 100644 --- a/src/http.h +++ b/src/old/http.h | |||
diff --git a/src/httpget.cpp b/src/old/httpget.cpp index ee1f29c..ee1f29c 100644 --- a/src/httpget.cpp +++ b/src/old/httpget.cpp | |||
diff --git a/src/httpget.h b/src/old/httpget.h index 8272641..8272641 100644 --- a/src/httpget.h +++ b/src/old/httpget.h | |||
diff --git a/src/linkedlist.cpp b/src/old/linkedlist.cpp index a9902bc..a9902bc 100644 --- a/src/linkedlist.cpp +++ b/src/old/linkedlist.cpp | |||
diff --git a/src/linkedlist.h b/src/old/linkedlist.h index e430108..e430108 100644 --- a/src/linkedlist.h +++ b/src/old/linkedlist.h | |||
diff --git a/src/linkmessenger.cpp b/src/old/linkmessenger.cpp index 3bd401a..3bd401a 100644 --- a/src/linkmessenger.cpp +++ b/src/old/linkmessenger.cpp | |||
diff --git a/src/linkmessenger.h b/src/old/linkmessenger.h index ed52639..ed52639 100644 --- a/src/linkmessenger.h +++ b/src/old/linkmessenger.h | |||
diff --git a/src/old/list.cpp b/src/old/list.cpp new file mode 100644 index 0000000..18f1a66 --- /dev/null +++ b/src/old/list.cpp | |||
@@ -0,0 +1,10 @@ | |||
1 | #include "list.h" | ||
2 | |||
3 | List::List( ) | ||
4 | { | ||
5 | } | ||
6 | |||
7 | List::~List( ) | ||
8 | { | ||
9 | } | ||
10 | |||
diff --git a/src/old/list.h b/src/old/list.h new file mode 100644 index 0000000..c71b328 --- /dev/null +++ b/src/old/list.h | |||
@@ -0,0 +1,101 @@ | |||
1 | #ifndef LIST_H | ||
2 | #define LIST_H | ||
3 | |||
4 | |||
5 | /** The basic List class ADT. This, on it's own, does absolutely nothing, but | ||
6 | * does define all standard interface functions to access a list. | ||
7 | *@author Mike Buland | ||
8 | */ | ||
9 | class List | ||
10 | { | ||
11 | public: | ||
12 | /** | ||
13 | * Construct a list. | ||
14 | */ | ||
15 | List(); | ||
16 | |||
17 | /** | ||
18 | * Desconstruct a list. | ||
19 | */ | ||
20 | virtual ~List(); | ||
21 | |||
22 | /** Gets the value at a specified index. | ||
23 | *@param nIndex The index of the item to return. | ||
24 | *@returns The specified item, or NULL if the index was beyond the range | ||
25 | * of the list. | ||
26 | *@author Mike Buland | ||
27 | */ | ||
28 | virtual void *getAt( int nIndex ) = 0; | ||
29 | |||
30 | /** Append the given data to the end of the list. This increases the | ||
31 | * size of the list by one. | ||
32 | *@param pData The data to append to the list. | ||
33 | *@author Mike Buland | ||
34 | */ | ||
35 | virtual void append( void *pData ) = 0; | ||
36 | |||
37 | /** Inserts an item at the specified position in the list. The | ||
38 | * new item takes the index that you specify, and all other items | ||
39 | * are moved up one position. The size of the list is increased by | ||
40 | * one. | ||
41 | *@param pData The value to insert into the list. | ||
42 | *@param nPos Where to insert the data into the list. | ||
43 | *@author Mike Buland | ||
44 | */ | ||
45 | virtual void insertBefore( void *pData, int nPos = 0 ) = 0; | ||
46 | |||
47 | /** Determines the size of the list, in elements. | ||
48 | *@returns The size of the list. | ||
49 | *@author Mike Buland | ||
50 | */ | ||
51 | virtual int getSize( ) = 0; | ||
52 | |||
53 | /** Determines if the list is empty or not. | ||
54 | *@returns True if the list is empty, or false if the list has | ||
55 | * data in it (if the size is greater than zero). | ||
56 | *@author Mike Buland | ||
57 | */ | ||
58 | virtual bool isEmpty( ) = 0; | ||
59 | |||
60 | /** Deletes an item at the specified index and moves all other | ||
61 | * values down one index. The size of the list is decreased by one. | ||
62 | *@param nIndex The index of the item to delete. | ||
63 | *@author Mike Buland | ||
64 | */ | ||
65 | virtual void deleteAt( int nIndex ) = 0; | ||
66 | |||
67 | /** Completely empties the list, and sets the effective size to | ||
68 | * zero. | ||
69 | *@author Mike Buland | ||
70 | */ | ||
71 | virtual void empty() = 0; | ||
72 | |||
73 | /** Sets the size of the list. This can be larger or smaller | ||
74 | * than what it was previously. If larger, new blank items will | ||
75 | * be added to the end of the list. If smaller than the old list | ||
76 | * items will be deleted from the end. | ||
77 | *@param nNewSize The new size of the list. | ||
78 | *@author Mike Buland | ||
79 | */ | ||
80 | virtual void setSize( int nNewSize ) = 0; | ||
81 | |||
82 | /** Sets a member at a specified location to a new value. | ||
83 | * If the member being set is outside of the range of the | ||
84 | * current list it should be expanded. | ||
85 | *@param nIndex The zero-based index of the item to change. | ||
86 | *@param pData The new value for that index. | ||
87 | *@author Mike Buland | ||
88 | */ | ||
89 | virtual void setAt( int nIndex, void *pData ) = 0; | ||
90 | |||
91 | /** Makes the List work like an array. Just say listObj[2] to get | ||
92 | * the third element. | ||
93 | *@param nIndex The index to access in the list. | ||
94 | *@returns A pointer to the data at element index. | ||
95 | *@author Mike Buland | ||
96 | */ | ||
97 | void *operator[]( int nIndex ) { return getAt( nIndex ); }; | ||
98 | }; | ||
99 | |||
100 | #endif | ||
101 | |||
diff --git a/src/md5.cpp b/src/old/md5.cpp index c0cacdd..c0cacdd 100644 --- a/src/md5.cpp +++ b/src/old/md5.cpp | |||
diff --git a/src/md5.h b/src/old/md5.h index 7f77d83..7f77d83 100644 --- a/src/md5.h +++ b/src/old/md5.h | |||
diff --git a/src/multilog.cpp b/src/old/multilog.cpp index 143ee89..143ee89 100644 --- a/src/multilog.cpp +++ b/src/old/multilog.cpp | |||
diff --git a/src/multilog.h b/src/old/multilog.h index 692095a..692095a 100644 --- a/src/multilog.h +++ b/src/old/multilog.h | |||
diff --git a/src/multilogchannel.cpp b/src/old/multilogchannel.cpp index ee4c9bf..ee4c9bf 100644 --- a/src/multilogchannel.cpp +++ b/src/old/multilogchannel.cpp | |||
diff --git a/src/multilogchannel.h b/src/old/multilogchannel.h index d891a65..d891a65 100644 --- a/src/multilogchannel.h +++ b/src/old/multilogchannel.h | |||
diff --git a/src/multilogtext.cpp b/src/old/multilogtext.cpp index 4337cc9..4337cc9 100644 --- a/src/multilogtext.cpp +++ b/src/old/multilogtext.cpp | |||
diff --git a/src/multilogtext.h b/src/old/multilogtext.h index 197aef1..197aef1 100644 --- a/src/multilogtext.h +++ b/src/old/multilogtext.h | |||
diff --git a/src/ordhash.cpp b/src/old/ordhash.cpp index 77cbd61..77cbd61 100644 --- a/src/ordhash.cpp +++ b/src/old/ordhash.cpp | |||
diff --git a/src/ordhash.h b/src/old/ordhash.h index e946f95..e946f95 100644 --- a/src/ordhash.h +++ b/src/old/ordhash.h | |||
diff --git a/src/pqueue.cpp b/src/old/pqueue.cpp index 1f0b8b5..1f0b8b5 100644 --- a/src/pqueue.cpp +++ b/src/old/pqueue.cpp | |||
diff --git a/src/pqueue.h b/src/old/pqueue.h index 8307d56..8307d56 100644 --- a/src/pqueue.h +++ b/src/old/pqueue.h | |||
diff --git a/src/old/protocol.cpp b/src/old/protocol.cpp new file mode 100644 index 0000000..78b3ee2 --- /dev/null +++ b/src/old/protocol.cpp | |||
@@ -0,0 +1,20 @@ | |||
1 | #include "protocol.h" | ||
2 | |||
3 | Protocol::Protocol() | ||
4 | { | ||
5 | pConnection = NULL; | ||
6 | } | ||
7 | |||
8 | Protocol::~Protocol() | ||
9 | { | ||
10 | } | ||
11 | |||
12 | void Protocol::setConnection( Connection *pNewConnection ) | ||
13 | { | ||
14 | pConnection = pNewConnection; | ||
15 | } | ||
16 | |||
17 | Connection *Protocol::getConnection() | ||
18 | { | ||
19 | return pConnection; | ||
20 | } | ||
diff --git a/src/old/protocol.h b/src/old/protocol.h new file mode 100644 index 0000000..09e1c98 --- /dev/null +++ b/src/old/protocol.h | |||
@@ -0,0 +1,62 @@ | |||
1 | #ifndef PROTOCOL_H | ||
2 | #define PROTOCOL_H | ||
3 | |||
4 | #include "connection.h" | ||
5 | |||
6 | /** This is the template for a class that handles specialized input and output | ||
7 | * to connections of different types with different protocols. | ||
8 | *@author Mike Buland | ||
9 | */ | ||
10 | class Protocol | ||
11 | { | ||
12 | public: | ||
13 | /** Constructor */ | ||
14 | Protocol(); | ||
15 | /** Deconstructor */ | ||
16 | virtual ~Protocol(); | ||
17 | |||
18 | /** | ||
19 | * Function is called every time there is new data on the line. This is | ||
20 | * called directly from the Connection class to process data. This is not | ||
21 | * called whever there is pending data on the input, but every time new data | ||
22 | * is added to the input buffer. | ||
23 | *@returns True if processing went alright, false if something went wrong, | ||
24 | * I suppose. In truth this value is thrown away right now. | ||
25 | *@todo Either make a return value of false mean something, or make these | ||
26 | * void. | ||
27 | */ | ||
28 | virtual bool onNewData()=0; | ||
29 | |||
30 | /** | ||
31 | * Function is called when there is a new connection. This should only | ||
32 | * happen once per Protocol object, but gives each protocol object a | ||
33 | * chance to perform connection handshaking and initialization at a point | ||
34 | * where they know that they have a handle to an active Connection. | ||
35 | *@returns See onNewData | ||
36 | */ | ||
37 | virtual bool onNewConnection()=0; | ||
38 | |||
39 | virtual void onNewClientConnection(){}; | ||
40 | |||
41 | virtual void poll(){}; | ||
42 | |||
43 | /** | ||
44 | * Sets the Protocol's Connection object. This is rather important, and | ||
45 | * handled usually by the ConnectionManager. | ||
46 | *@param pNewConnection The Connection object that this protocol will use to | ||
47 | * deal with the outside world. | ||
48 | */ | ||
49 | void setConnection( class Connection *pNewConnection ); | ||
50 | |||
51 | /** | ||
52 | * Get a pointer to this object's Connection object, or NULL if one was | ||
53 | * never set. If used with the ConnectionManager that should never happen. | ||
54 | *@returns A pointer to the active Connection. | ||
55 | */ | ||
56 | Connection *getConnection(); | ||
57 | |||
58 | private: | ||
59 | class Connection *pConnection; /**< The pointer to the Connection. */ | ||
60 | }; | ||
61 | |||
62 | #endif | ||
diff --git a/src/protocoltelnet.cpp b/src/old/protocoltelnet.cpp index b169a51..b169a51 100644 --- a/src/protocoltelnet.cpp +++ b/src/old/protocoltelnet.cpp | |||
diff --git a/src/protocoltelnet.h b/src/old/protocoltelnet.h index a6d2e49..a6d2e49 100644 --- a/src/protocoltelnet.h +++ b/src/old/protocoltelnet.h | |||
diff --git a/src/queue.cpp b/src/old/queue.cpp index 42999fe..42999fe 100644 --- a/src/queue.cpp +++ b/src/old/queue.cpp | |||
diff --git a/src/queue.h b/src/old/queue.h index 692f5d8..692f5d8 100644 --- a/src/queue.h +++ b/src/old/queue.h | |||
diff --git a/src/ringlist.cpp b/src/old/ringlist.cpp index 9efbbc4..9efbbc4 100644 --- a/src/ringlist.cpp +++ b/src/old/ringlist.cpp | |||
diff --git a/src/ringlist.h b/src/old/ringlist.h index bc069f3..bc069f3 100644 --- a/src/ringlist.h +++ b/src/old/ringlist.h | |||
diff --git a/src/sbuffer.cpp b/src/old/sbuffer.cpp index f84f8a3..f84f8a3 100644 --- a/src/sbuffer.cpp +++ b/src/old/sbuffer.cpp | |||
diff --git a/src/sbuffer.h b/src/old/sbuffer.h index 65feb71..65feb71 100644 --- a/src/sbuffer.h +++ b/src/old/sbuffer.h | |||
diff --git a/src/serializerbinary.cpp b/src/old/serializerbinary.cpp index ea7ed93..ea7ed93 100644 --- a/src/serializerbinary.cpp +++ b/src/old/serializerbinary.cpp | |||
diff --git a/src/serializerbinary.h b/src/old/serializerbinary.h index 8510fcd..8510fcd 100644 --- a/src/serializerbinary.h +++ b/src/old/serializerbinary.h | |||
diff --git a/src/serializerbzip2.cpp b/src/old/serializerbzip2.cpp index bafabc8..bafabc8 100644 --- a/src/serializerbzip2.cpp +++ b/src/old/serializerbzip2.cpp | |||
diff --git a/src/serializerbzip2.h b/src/old/serializerbzip2.h index 4aeb22e..4aeb22e 100644 --- a/src/serializerbzip2.h +++ b/src/old/serializerbzip2.h | |||
diff --git a/src/serializerconnection.cpp b/src/old/serializerconnection.cpp index 2934c8b..2934c8b 100644 --- a/src/serializerconnection.cpp +++ b/src/old/serializerconnection.cpp | |||
diff --git a/src/serializerconnection.h b/src/old/serializerconnection.h index e8d85c6..e8d85c6 100644 --- a/src/serializerconnection.h +++ b/src/old/serializerconnection.h | |||
diff --git a/src/serializertext.cpp b/src/old/serializertext.cpp index 9cf4394..9cf4394 100644 --- a/src/serializertext.cpp +++ b/src/old/serializertext.cpp | |||
diff --git a/src/serializertext.h b/src/old/serializertext.h index 01b7f7b..01b7f7b 100644 --- a/src/serializertext.h +++ b/src/old/serializertext.h | |||
diff --git a/src/sha1.cpp b/src/old/sha1.cpp index 8270c3b..8270c3b 100644 --- a/src/sha1.cpp +++ b/src/old/sha1.cpp | |||
diff --git a/src/sha1.h b/src/old/sha1.h index ab6081d..ab6081d 100644 --- a/src/sha1.h +++ b/src/old/sha1.h | |||
diff --git a/src/stack.cpp b/src/old/stack.cpp index 8d9565c..8d9565c 100644 --- a/src/stack.cpp +++ b/src/old/stack.cpp | |||
diff --git a/src/stack.h b/src/old/stack.h index 30e2a19..30e2a19 100644 --- a/src/stack.h +++ b/src/old/stack.h | |||
diff --git a/src/staticstring.cpp b/src/old/staticstring.cpp index 60f130f..60f130f 100644 --- a/src/staticstring.cpp +++ b/src/old/staticstring.cpp | |||
diff --git a/src/staticstring.h b/src/old/staticstring.h index 4c3f7b8..4c3f7b8 100644 --- a/src/staticstring.h +++ b/src/old/staticstring.h | |||
diff --git a/src/stringrep.cpp b/src/old/stringrep.cpp index a505f8a..a505f8a 100644 --- a/src/stringrep.cpp +++ b/src/old/stringrep.cpp | |||
diff --git a/src/stringrep.h b/src/old/stringrep.h index eaa4a12..eaa4a12 100644 --- a/src/stringrep.h +++ b/src/old/stringrep.h | |||
diff --git a/src/tests/clistress.cpp b/src/old/tests/clistress.cpp index 6b0ac66..6b0ac66 100644 --- a/src/tests/clistress.cpp +++ b/src/old/tests/clistress.cpp | |||
diff --git a/src/tests/confpair.cpp b/src/old/tests/confpair.cpp index fb1b0d3..fb1b0d3 100644 --- a/src/tests/confpair.cpp +++ b/src/old/tests/confpair.cpp | |||
diff --git a/src/tests/connect.cpp b/src/old/tests/connect.cpp index a9fca64..a9fca64 100644 --- a/src/tests/connect.cpp +++ b/src/old/tests/connect.cpp | |||
diff --git a/src/tests/exception.cpp b/src/old/tests/exception.cpp index 6417692..6417692 100644 --- a/src/tests/exception.cpp +++ b/src/old/tests/exception.cpp | |||
diff --git a/src/tests/formula.cpp b/src/old/tests/formula.cpp index 976b039..976b039 100644 --- a/src/tests/formula.cpp +++ b/src/old/tests/formula.cpp | |||
diff --git a/src/old/tests/hash.cpp b/src/old/tests/hash.cpp new file mode 100644 index 0000000..2fc6968 --- /dev/null +++ b/src/old/tests/hash.cpp | |||
@@ -0,0 +1,116 @@ | |||
1 | #include "hash.h" | ||
2 | #include "staticstring.h" | ||
3 | |||
4 | int main() | ||
5 | { | ||
6 | const char *names[]={ | ||
7 | "Homer the Great", | ||
8 | "And Maggie Makes Three", | ||
9 | "Bart's Comet", | ||
10 | "Homie The Clown", | ||
11 | "Bart Vs Australia", | ||
12 | "Homer vs Patty and Selma", | ||
13 | "A star is burns", | ||
14 | "Lisa's Wedding", | ||
15 | "Two Dozen and One Greyhounds", | ||
16 | "The PTA Disbands", | ||
17 | "Round Springfield", | ||
18 | "The Springfield connection", | ||
19 | "Lemon of Troy", | ||
20 | "Who Shot Mr. Burns (Pt. 1)", | ||
21 | "Who Shot Mr. Burns (pt. 2)", | ||
22 | "Radioactive Man", | ||
23 | "Home Sweet Homediddly-dum-doodly", | ||
24 | "Bart Sells His Soul", | ||
25 | "Lisa the Vegetarian", | ||
26 | "Treehouse of horror VI", | ||
27 | "King Size Homer", | ||
28 | "Mother Simpson", | ||
29 | "Sideshow Bob's Last Gleaming", | ||
30 | "The Simpson's 138th Show Spectacular", | ||
31 | "Marge Be Not Proud", | ||
32 | "Team Homer", | ||
33 | "Two Bad Neighbors", | ||
34 | "Scenes From the Class Struggle in Springfield", | ||
35 | "Bart the Fink", | ||
36 | "Lisa the Iconoclast", | ||
37 | "Homer the Smithers", | ||
38 | "The Day the Violence Died", | ||
39 | "A Fish Called Selma", | ||
40 | "Bart on the road", | ||
41 | "22 Short Films about Springfield", | ||
42 | "The Curse of the Flying Hellfish", | ||
43 | "Much Apu about Nothing", | ||
44 | "Homerpalooza", | ||
45 | "The Summer of 4 Ft 2", | ||
46 | "Treehouse of Horror VII", | ||
47 | "You Only Move Twice", | ||
48 | "The Homer They Fall", | ||
49 | "Burns Baby Burns", | ||
50 | "Bart After Dark", | ||
51 | "A Millhouse Divided", | ||
52 | "Lisas Date With Destiny", | ||
53 | "Hurricane Neddy", | ||
54 | "The Mysterious Voyage of Our Homer", | ||
55 | "The Springfield Files", | ||
56 | "The Twisted World of Marge Simpson", | ||
57 | "Mountain of Madness", | ||
58 | NULL | ||
59 | }; | ||
60 | |||
61 | Hash<const char *, int> sTest; | ||
62 | |||
63 | printf("Inserting\n-------------------\n\n"); | ||
64 | for( int j = 0; j < 33; j++ ) | ||
65 | { | ||
66 | sTest[names[j]] = j; | ||
67 | } | ||
68 | |||
69 | printf("Test1: %d, Test2: %d\n", sTest.has("Lemon of Troy"), sTest.has(std::string("Lemon of Troy").c_str() ) ); | ||
70 | |||
71 | sTest.has(std::string("Lemon of Troy").c_str() ); | ||
72 | |||
73 | printf("Getting\n-------------------\n\n"); | ||
74 | |||
75 | sTest.erase("Homer the Great"); | ||
76 | sTest["Bart's Comet"].erase(); | ||
77 | |||
78 | for( Hash<const char *, int>::iterator i = sTest.begin(); | ||
79 | i != sTest.end(); i++ ) | ||
80 | { | ||
81 | Hash<const char *, int>::iterator j = i; | ||
82 | printf("%d: %s\n", (*j).second, (*j).first ); | ||
83 | } | ||
84 | |||
85 | printf("Testing\n-------------------\n\n"); | ||
86 | for( int j = 0; j < 33; j++ ) | ||
87 | { | ||
88 | if( sTest.has(names[j]) ) | ||
89 | { | ||
90 | if( sTest[names[j]] != j ) | ||
91 | { | ||
92 | printf("'%s' should be %d, is %d\n", | ||
93 | names[j], j, | ||
94 | sTest[names[j]].value() | ||
95 | ); | ||
96 | } | ||
97 | } | ||
98 | else | ||
99 | { | ||
100 | printf("Missing element %d, '%s'\n", j, names[j] ); | ||
101 | } | ||
102 | } | ||
103 | |||
104 | printf("Clearing\n-------------------\n\n"); | ||
105 | |||
106 | sTest.clear(); | ||
107 | |||
108 | for( Hash<const char *, int>::iterator i = sTest.begin(); | ||
109 | i != sTest.end(); i++ ) | ||
110 | { | ||
111 | Hash<const char *, int>::iterator j = i; | ||
112 | printf("%d: %s\n", (*j).second, (*j).first ); | ||
113 | } | ||
114 | |||
115 | } | ||
116 | |||
diff --git a/src/tests/hashtest.cpp b/src/old/tests/hashtest.cpp index eaa84a0..eaa84a0 100644 --- a/src/tests/hashtest.cpp +++ b/src/old/tests/hashtest.cpp | |||
diff --git a/src/tests/hashtest2.cpp b/src/old/tests/hashtest2.cpp index 74700fd..74700fd 100644 --- a/src/tests/hashtest2.cpp +++ b/src/old/tests/hashtest2.cpp | |||
diff --git a/src/tests/httpsrv/httpconnectionmonitor.cpp b/src/old/tests/httpsrv/httpconnectionmonitor.cpp index 51d82f3..51d82f3 100644 --- a/src/tests/httpsrv/httpconnectionmonitor.cpp +++ b/src/old/tests/httpsrv/httpconnectionmonitor.cpp | |||
diff --git a/src/tests/httpsrv/httpconnectionmonitor.h b/src/old/tests/httpsrv/httpconnectionmonitor.h index 30c0afd..30c0afd 100644 --- a/src/tests/httpsrv/httpconnectionmonitor.h +++ b/src/old/tests/httpsrv/httpconnectionmonitor.h | |||
diff --git a/src/tests/httpsrv/main.cpp b/src/old/tests/httpsrv/main.cpp index 2f1563c..2f1563c 100644 --- a/src/tests/httpsrv/main.cpp +++ b/src/old/tests/httpsrv/main.cpp | |||
diff --git a/src/tests/log.cpp b/src/old/tests/log.cpp index d7cfa0b..d7cfa0b 100644 --- a/src/tests/log.cpp +++ b/src/old/tests/log.cpp | |||
diff --git a/src/tests/md5test.cpp b/src/old/tests/md5test.cpp index 6f832df..6f832df 100644 --- a/src/tests/md5test.cpp +++ b/src/old/tests/md5test.cpp | |||
diff --git a/src/tests/ordhash.cpp b/src/old/tests/ordhash.cpp index f1d96ec..f1d96ec 100644 --- a/src/tests/ordhash.cpp +++ b/src/old/tests/ordhash.cpp | |||
diff --git a/src/tests/param.cpp b/src/old/tests/param.cpp index a4d2824..a4d2824 100644 --- a/src/tests/param.cpp +++ b/src/old/tests/param.cpp | |||
diff --git a/src/tests/param.h b/src/old/tests/param.h index 2756b69..2756b69 100644 --- a/src/tests/param.h +++ b/src/old/tests/param.h | |||
diff --git a/src/tests/plugin/main.cpp b/src/old/tests/plugin/main.cpp index 51c8390..51c8390 100644 --- a/src/tests/plugin/main.cpp +++ b/src/old/tests/plugin/main.cpp | |||
diff --git a/src/tests/plugin/plugin.cpp b/src/old/tests/plugin/plugin.cpp index ea558fd..ea558fd 100644 --- a/src/tests/plugin/plugin.cpp +++ b/src/old/tests/plugin/plugin.cpp | |||
diff --git a/src/tests/plugin/plugin.h b/src/old/tests/plugin/plugin.h index f726867..f726867 100644 --- a/src/tests/plugin/plugin.h +++ b/src/old/tests/plugin/plugin.h | |||
diff --git a/src/tests/qsort.cpp b/src/old/tests/qsort.cpp index 28c6f03..28c6f03 100644 --- a/src/tests/qsort.cpp +++ b/src/old/tests/qsort.cpp | |||
diff --git a/src/tests/sbuffer.cpp b/src/old/tests/sbuffer.cpp index 02798cb..02798cb 100644 --- a/src/tests/sbuffer.cpp +++ b/src/old/tests/sbuffer.cpp | |||
diff --git a/src/tests/serialize.cpp b/src/old/tests/serialize.cpp index e233704..e233704 100644 --- a/src/tests/serialize.cpp +++ b/src/old/tests/serialize.cpp | |||
diff --git a/src/tests/serializetext.cpp b/src/old/tests/serializetext.cpp index f6be7d3..f6be7d3 100644 --- a/src/tests/serializetext.cpp +++ b/src/old/tests/serializetext.cpp | |||
diff --git a/src/tests/sha1.cpp b/src/old/tests/sha1.cpp index df3113c..df3113c 100644 --- a/src/tests/sha1.cpp +++ b/src/old/tests/sha1.cpp | |||
diff --git a/src/tests/sptr.cpp b/src/old/tests/sptr.cpp index 252463b..38d3675 100644 --- a/src/tests/sptr.cpp +++ b/src/old/tests/sptr.cpp | |||
@@ -9,12 +9,12 @@ public: | |||
9 | printf("Created.\n"); | 9 | printf("Created.\n"); |
10 | } | 10 | } |
11 | 11 | ||
12 | virtual ~Annoy() | 12 | ~Annoy() |
13 | { | 13 | { |
14 | printf("Destroyed.\n"); | 14 | printf("Destroyed.\n"); |
15 | } | 15 | } |
16 | 16 | ||
17 | virtual void go() | 17 | void go() |
18 | { | 18 | { |
19 | printf("%d: I'm annoying.\n", ++nCnt); | 19 | printf("%d: I'm annoying.\n", ++nCnt); |
20 | } | 20 | } |
@@ -22,22 +22,6 @@ public: | |||
22 | int nCnt; | 22 | int nCnt; |
23 | }; | 23 | }; |
24 | 24 | ||
25 | class Annoy2: public Annoy | ||
26 | { | ||
27 | public: | ||
28 | Annoy2(){}; | ||
29 | virtual ~Annoy2(){}; | ||
30 | virtual void go() | ||
31 | { | ||
32 | printf("{{I'm Annoy2!!}} "); | ||
33 | Annoy::go(); | ||
34 | } | ||
35 | virtual void go2() | ||
36 | { | ||
37 | printf("This is me, on my own...\n"); | ||
38 | } | ||
39 | }; | ||
40 | |||
41 | void beAnnoying( SPtr<Annoy> bob ) | 25 | void beAnnoying( SPtr<Annoy> bob ) |
42 | { | 26 | { |
43 | printf("bob-Count: %d\n", bob.count() ); | 27 | printf("bob-Count: %d\n", bob.count() ); |
@@ -46,7 +30,7 @@ void beAnnoying( SPtr<Annoy> bob ) | |||
46 | 30 | ||
47 | int main() | 31 | int main() |
48 | { | 32 | { |
49 | SPtr<Annoy> pt( new Annoy2 ); | 33 | SPtr<Annoy> pt( new Annoy ); |
50 | printf("Count: %d\n", pt.count() ); | 34 | printf("Count: %d\n", pt.count() ); |
51 | pt->go(); | 35 | pt->go(); |
52 | 36 | ||
@@ -63,14 +47,6 @@ int main() | |||
63 | pt3->go(); | 47 | pt3->go(); |
64 | 48 | ||
65 | beAnnoying( pt3 ); | 49 | beAnnoying( pt3 ); |
66 | |||
67 | { | ||
68 | SPtr<Annoy2> pt4( SPtrCast<Annoy2>( pt3 ) ); | ||
69 | printf("Count: %d\n", pt4.count() ); | ||
70 | |||
71 | pt4->go2(); | ||
72 | } | ||
73 | printf("Count: %d\n", pt.count() ); | ||
74 | } | 50 | } |
75 | printf("Count: %d\n", pt.count() ); | 51 | printf("Count: %d\n", pt.count() ); |
76 | } | 52 | } |
diff --git a/src/tests/srvstress.cpp b/src/old/tests/srvstress.cpp index d9a9a1c..d9a9a1c 100644 --- a/src/tests/srvstress.cpp +++ b/src/old/tests/srvstress.cpp | |||
diff --git a/src/tests/strhash.cpp b/src/old/tests/strhash.cpp index f6528ca..f6528ca 100644 --- a/src/tests/strhash.cpp +++ b/src/old/tests/strhash.cpp | |||
diff --git a/src/tests/teltest/main.cpp b/src/old/tests/teltest/main.cpp index 5d3ec26..5d3ec26 100644 --- a/src/tests/teltest/main.cpp +++ b/src/old/tests/teltest/main.cpp | |||
diff --git a/src/tests/teltest/telnetmonitor.cpp b/src/old/tests/teltest/telnetmonitor.cpp index 65954eb..65954eb 100644 --- a/src/tests/teltest/telnetmonitor.cpp +++ b/src/old/tests/teltest/telnetmonitor.cpp | |||
diff --git a/src/tests/teltest/telnetmonitor.h b/src/old/tests/teltest/telnetmonitor.h index ba5761e..ba5761e 100644 --- a/src/tests/teltest/telnetmonitor.h +++ b/src/old/tests/teltest/telnetmonitor.h | |||
diff --git a/src/tests/xmlreadtest.cpp b/src/old/tests/xmlreadtest.cpp index d061810..d061810 100644 --- a/src/tests/xmlreadtest.cpp +++ b/src/old/tests/xmlreadtest.cpp | |||
diff --git a/src/tests/xmlrepltest.cpp b/src/old/tests/xmlrepltest.cpp index 9667705..9667705 100644 --- a/src/tests/xmlrepltest.cpp +++ b/src/old/tests/xmlrepltest.cpp | |||
diff --git a/src/tests/xmlwritetest.cpp b/src/old/tests/xmlwritetest.cpp index a22d19d..a22d19d 100644 --- a/src/tests/xmlwritetest.cpp +++ b/src/old/tests/xmlwritetest.cpp | |||
diff --git a/src/tokenstring.cpp b/src/old/tokenstring.cpp index e57ba69..e57ba69 100644 --- a/src/tokenstring.cpp +++ b/src/old/tokenstring.cpp | |||
diff --git a/src/tokenstring.h b/src/old/tokenstring.h index 42f7309..42f7309 100644 --- a/src/tokenstring.h +++ b/src/old/tokenstring.h | |||
diff --git a/src/tqsort.h b/src/old/tqsort.h index c836b4f..c836b4f 100644 --- a/src/tqsort.h +++ b/src/old/tqsort.h | |||
diff --git a/src/unit/hashtable/hashtable.cpp b/src/old/unit/hashtable/hashtable.cpp index b2e1cf5..b2e1cf5 100644 --- a/src/unit/hashtable/hashtable.cpp +++ b/src/old/unit/hashtable/hashtable.cpp | |||
diff --git a/src/unit/xml/xml.cpp b/src/old/unit/xml/xml.cpp index e4d779c..e4d779c 100644 --- a/src/unit/xml/xml.cpp +++ b/src/old/unit/xml/xml.cpp | |||
diff --git a/src/xmldocument.cpp b/src/old/xmldocument.cpp index d7867d5..95b9788 100644 --- a/src/xmldocument.cpp +++ b/src/old/xmldocument.cpp | |||
@@ -1,6 +1,6 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include "xmlwriter.h" | 3 | #include "xmldocument.h" |
4 | 4 | ||
5 | XmlDocument::XmlDocument( XmlNode *pRoot ) | 5 | XmlDocument::XmlDocument( XmlNode *pRoot ) |
6 | { | 6 | { |
@@ -17,28 +17,23 @@ XmlDocument::~XmlDocument() | |||
17 | } | 17 | } |
18 | } | 18 | } |
19 | 19 | ||
20 | void XmlDocument::addNode( const char *sName, const char *sContent, bool bClose ) | 20 | void XmlDocument::addNode( const Bu::FString &sName ) |
21 | { | 21 | { |
22 | if( pRoot == NULL ) | 22 | if( pRoot == NULL ) |
23 | { | 23 | { |
24 | // This is the first node, so ignore position and just insert it. | 24 | // This is the first node, so ignore position and just insert it. |
25 | pCurrent = pRoot = new XmlNode( sName, NULL, sContent ); | 25 | pCurrent = pRoot = new XmlNode( sName ); |
26 | } | 26 | } |
27 | else | 27 | else |
28 | { | 28 | { |
29 | pCurrent = pCurrent->addChild( sName, sContent ); | 29 | pCurrent = pCurrent->addChild( sName ); |
30 | } | ||
31 | |||
32 | if( bClose ) | ||
33 | { | ||
34 | closeNode(); | ||
35 | } | 30 | } |
36 | } | 31 | } |
37 | 32 | /* | |
38 | void XmlDocument::setName( const char *sName ) | 33 | void XmlDocument::setName( const char *sName ) |
39 | { | 34 | { |
40 | pCurrent->setName( sName ); | 35 | pCurrent->setName( sName ); |
41 | } | 36 | }*/ |
42 | 37 | ||
43 | bool XmlDocument::isCompleted() | 38 | bool XmlDocument::isCompleted() |
44 | { | 39 | { |
@@ -143,7 +138,8 @@ void XmlDocument::setContent( const char *sContent ) | |||
143 | { | 138 | { |
144 | if( pCurrent ) | 139 | if( pCurrent ) |
145 | { | 140 | { |
146 | pCurrent->setContent( sContent ); | 141 | printf("XmlDocument::setContent: not yet implemented.\n"); |
142 | //pCurrent->setContent( sContent ); | ||
147 | } | 143 | } |
148 | } | 144 | } |
149 | 145 | ||
diff --git a/src/xmldocument.h b/src/old/xmldocument.h index 6671c41..e0c36eb 100644 --- a/src/xmldocument.h +++ b/src/old/xmldocument.h | |||
@@ -39,13 +39,7 @@ public: | |||
39 | * the node and setting the content and name. If this is set to true the | 39 | * the node and setting the content and name. If this is set to true the |
40 | * node is appended, but the context node doesn't change. | 40 | * node is appended, but the context node doesn't change. |
41 | */ | 41 | */ |
42 | void addNode( const char *sName=NULL, const char *sContent=NULL, bool bClose=false ); | 42 | void addNode( const Bu::FString &sName ); |
43 | |||
44 | /** | ||
45 | * Set the name of the current node context. | ||
46 | *@param sName The new name of the node. | ||
47 | */ | ||
48 | void setName( const char *sName ); | ||
49 | 43 | ||
50 | /** | 44 | /** |
51 | * Close the current node context. This will move the current context to | 45 | * Close the current node context. This will move the current context to |
diff --git a/src/xmlfilereader.cpp b/src/old/xmlfilereader.cpp index ed674a8..ed674a8 100644 --- a/src/xmlfilereader.cpp +++ b/src/old/xmlfilereader.cpp | |||
diff --git a/src/xmlfilereader.h b/src/old/xmlfilereader.h index e3e02c2..e3e02c2 100644 --- a/src/xmlfilereader.h +++ b/src/old/xmlfilereader.h | |||
diff --git a/src/xmlfilewriter.cpp b/src/old/xmlfilewriter.cpp index 3c6fb41..3c6fb41 100644 --- a/src/xmlfilewriter.cpp +++ b/src/old/xmlfilewriter.cpp | |||
diff --git a/src/xmlfilewriter.h b/src/old/xmlfilewriter.h index e328f96..e328f96 100644 --- a/src/xmlfilewriter.h +++ b/src/old/xmlfilewriter.h | |||
diff --git a/src/xmlnode.cpp b/src/old/xmlnode.cpp index b1ed9a9..96d5850 100644 --- a/src/xmlnode.cpp +++ b/src/old/xmlnode.cpp | |||
@@ -1,53 +1,15 @@ | |||
1 | #include "xmlnode.h" | 1 | #include "xmlnode.h" |
2 | #include "hashfunctionstring.h" | ||
3 | 2 | ||
4 | XmlNode::XmlNode( const char *sName, XmlNode *pParent, const char *sContent ) : | 3 | XmlNode::XmlNode( const Bu::FString &sName, XmlNode *pParent ) : |
5 | hProperties( new HashFunctionString(), 53, false ), | 4 | sName( sName ), |
6 | hChildren( new HashFunctionString(), 53, true ) | 5 | pParent( pParent ) |
7 | { | 6 | { |
8 | this->pParent = pParent; | ||
9 | if( sName != NULL ) | ||
10 | { | ||
11 | setName( sName ); | ||
12 | } | ||
13 | if( sContent != NULL ) | ||
14 | { | ||
15 | this->sPreContent = new std::string( sContent ); | ||
16 | } | ||
17 | else | ||
18 | { | ||
19 | this->sPreContent = NULL; | ||
20 | } | ||
21 | nCurContent = 0; | ||
22 | } | 7 | } |
23 | 8 | ||
24 | XmlNode::~XmlNode() | 9 | XmlNode::~XmlNode() |
25 | { | 10 | { |
26 | for( int j = 0; j < lChildren.getSize(); j++ ) | ||
27 | { | ||
28 | delete (XmlNode *)lChildren[j]; | ||
29 | } | ||
30 | for( int j = 0; j < lPropNames.getSize(); j++ ) | ||
31 | { | ||
32 | delete (std::string *)lPropNames[j]; | ||
33 | } | ||
34 | for( int j = 0; j < lPropValues.getSize(); j++ ) | ||
35 | { | ||
36 | delete (std::string *)lPropValues[j]; | ||
37 | } | ||
38 | for( int j = 0; j < lPostContent.getSize(); j++ ) | ||
39 | { | ||
40 | if( lPostContent[j] != NULL ) | ||
41 | { | ||
42 | delete (std::string *)lPostContent[j]; | ||
43 | } | ||
44 | } | ||
45 | if( sPreContent ) | ||
46 | { | ||
47 | delete sPreContent; | ||
48 | } | ||
49 | } | 11 | } |
50 | 12 | /* | |
51 | void XmlNode::setName( const char *sName ) | 13 | void XmlNode::setName( const char *sName ) |
52 | { | 14 | { |
53 | if( pParent ) | 15 | if( pParent ) |
@@ -120,18 +82,18 @@ const char *XmlNode::getContent( int nIndex ) | |||
120 | } | 82 | } |
121 | 83 | ||
122 | return NULL; | 84 | return NULL; |
123 | } | 85 | }*/ |
124 | 86 | ||
125 | XmlNode *XmlNode::addChild( const char *sName, const char *sContent ) | 87 | XmlNode *XmlNode::addChild( const Bu::FString &sName ) |
126 | { | 88 | { |
127 | return addChild( new XmlNode( sName, this, sContent ) ); | 89 | return addChild( new XmlNode( sName, this ) ); |
128 | } | 90 | } |
129 | 91 | ||
130 | XmlNode *XmlNode::addChild( XmlNode *pNode ) | 92 | XmlNode *XmlNode::addChild( XmlNode *pNode ) |
131 | { | 93 | { |
132 | lChildren.append( pNode ); | 94 | Child c = { typeNode }; |
133 | lPostContent.append( NULL ); | 95 | c.pNode = pNode; |
134 | nCurContent++; | 96 | lChildren.append( c ); |
135 | pNode->pParent = this; | 97 | pNode->pParent = this; |
136 | 98 | ||
137 | return pNode; | 99 | return pNode; |
@@ -142,21 +104,16 @@ XmlNode *XmlNode::getParent() | |||
142 | return pParent; | 104 | return pParent; |
143 | } | 105 | } |
144 | 106 | ||
145 | void XmlNode::addProperty( const char *sName, const char *sValue ) | 107 | void XmlNode::addProperty( const Bu::FString &sName, const Bu::FString &sValue ) |
146 | { | 108 | { |
147 | std::string *pName = new std::string( sName ); | 109 | hProperties.insert( sName, sValue ); |
148 | std::string *pValue = new std::string( sValue ); | ||
149 | |||
150 | hProperties.insert( pName->c_str(), pValue->c_str() ); | ||
151 | lPropNames.append( pName ); | ||
152 | lPropValues.append( pValue ); | ||
153 | } | 110 | } |
154 | 111 | ||
155 | int XmlNode::getNumProperties() | 112 | int XmlNode::getNumProperties() |
156 | { | 113 | { |
157 | return lPropNames.getSize(); | 114 | return hProperties.size(); |
158 | } | 115 | } |
159 | 116 | /* | |
160 | const char *XmlNode::getPropertyName( int nIndex ) | 117 | const char *XmlNode::getPropertyName( int nIndex ) |
161 | { | 118 | { |
162 | std::string *tmp = ((std::string *)lPropNames[nIndex]); | 119 | std::string *tmp = ((std::string *)lPropNames[nIndex]); |
@@ -172,15 +129,12 @@ const char *XmlNode::getProperty( int nIndex ) | |||
172 | return NULL; | 129 | return NULL; |
173 | return tmp->c_str(); | 130 | return tmp->c_str(); |
174 | } | 131 | } |
175 | 132 | */ | |
176 | const char *XmlNode::getProperty( const char *sName ) | 133 | Bu::FString XmlNode::getProperty( const Bu::FString &sName ) |
177 | { | 134 | { |
178 | const char *tmp = (const char *)hProperties[sName]; | 135 | return hProperties[sName]; |
179 | if( tmp == NULL ) | ||
180 | return NULL; | ||
181 | return tmp; | ||
182 | } | 136 | } |
183 | 137 | /* | |
184 | void XmlNode::deleteProperty( int nIndex ) | 138 | void XmlNode::deleteProperty( int nIndex ) |
185 | { | 139 | { |
186 | hProperties.del( ((std::string *)lPropNames[nIndex])->c_str() ); | 140 | hProperties.del( ((std::string *)lPropNames[nIndex])->c_str() ); |
@@ -194,29 +148,33 @@ void XmlNode::deleteProperty( int nIndex ) | |||
194 | 148 | ||
195 | bool XmlNode::hasChildren() | 149 | bool XmlNode::hasChildren() |
196 | { | 150 | { |
197 | return lChildren.getSize()>0; | 151 | return hChildren.getSize()>0; |
198 | } | 152 | }*/ |
199 | 153 | ||
200 | int XmlNode::getNumChildren() | 154 | int XmlNode::getNumChildren() |
201 | { | 155 | { |
202 | return lChildren.getSize(); | 156 | return lChildren.getSize(); |
203 | } | 157 | } |
204 | 158 | /* | |
205 | XmlNode *XmlNode::getChild( int nIndex ) | 159 | XmlNode *XmlNode::getChild( int nIndex ) |
206 | { | 160 | { |
207 | return (XmlNode *)lChildren[nIndex]; | 161 | return (XmlNode *)lChildren[nIndex]; |
208 | } | 162 | } |
209 | 163 | */ | |
210 | XmlNode *XmlNode::getChild( const char *sName, int nSkip ) | 164 | XmlNode *XmlNode::getChild( const Bu::FString &sName, int nSkip ) |
211 | { | 165 | { |
212 | return (XmlNode *)hChildren.get( sName, nSkip ); | 166 | if( !hChildren.has( sName ) ) |
167 | return NULL; | ||
168 | |||
169 | Bu::List<XmlNode *>::iterator i = hChildren[sName]->begin(); | ||
170 | return *i; | ||
213 | } | 171 | } |
214 | 172 | ||
215 | const char *XmlNode::getName() | 173 | Bu::FString XmlNode::getName() |
216 | { | 174 | { |
217 | return sName.c_str(); | 175 | return sName; |
218 | } | 176 | } |
219 | 177 | /* | |
220 | void XmlNode::deleteNode( int nIndex, const char *sReplacementText ) | 178 | void XmlNode::deleteNode( int nIndex, const char *sReplacementText ) |
221 | { | 179 | { |
222 | XmlNode *xRet = detatchNode( nIndex, sReplacementText ); | 180 | XmlNode *xRet = detatchNode( nIndex, sReplacementText ); |
@@ -442,4 +400,4 @@ void XmlNode::deleteNodeKeepChildren( int nIndex ) | |||
442 | void XmlNode::replaceNodeWithChildren( int nIndex, XmlNode *pNewNode ) | 400 | void XmlNode::replaceNodeWithChildren( int nIndex, XmlNode *pNewNode ) |
443 | { | 401 | { |
444 | } | 402 | } |
445 | 403 | */ | |
diff --git a/src/xmlnode.h b/src/old/xmlnode.h index 7525306..c895cd8 100644 --- a/src/xmlnode.h +++ b/src/old/xmlnode.h | |||
@@ -2,8 +2,9 @@ | |||
2 | #define XMLNODE | 2 | #define XMLNODE |
3 | 3 | ||
4 | #include <iostream> | 4 | #include <iostream> |
5 | #include "linkedlist.h" | 5 | #include "bu/list.h" |
6 | #include "hashtable.h" | 6 | #include "bu/hash.h" |
7 | #include "bu/fstring.h" | ||
7 | 8 | ||
8 | /** | 9 | /** |
9 | * Maintains all data pertient to an XML node, including sub-nodes and content. | 10 | * Maintains all data pertient to an XML node, including sub-nodes and content. |
@@ -25,9 +26,8 @@ public: | |||
25 | *@param sContent The initial content string. | 26 | *@param sContent The initial content string. |
26 | */ | 27 | */ |
27 | XmlNode( | 28 | XmlNode( |
28 | const char *sName=NULL, | 29 | const Bu::FString &sName, |
29 | XmlNode *pParent = NULL, | 30 | XmlNode *pParent=NULL |
30 | const char *sContent=NULL | ||
31 | ); | 31 | ); |
32 | 32 | ||
33 | /** | 33 | /** |
@@ -39,7 +39,7 @@ public: | |||
39 | * Change the name of the node. | 39 | * Change the name of the node. |
40 | *@param sName The new name of the node. | 40 | *@param sName The new name of the node. |
41 | */ | 41 | */ |
42 | void setName( const char *sName ); | 42 | //void setName( const char *sName ); |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Construct a new node and add it as a child to this node, also return a | 45 | * Construct a new node and add it as a child to this node, also return a |
@@ -48,7 +48,7 @@ public: | |||
48 | *@param sContent The initial content of the new node. | 48 | *@param sContent The initial content of the new node. |
49 | *@returns A pointer to the newly created child node. | 49 | *@returns A pointer to the newly created child node. |
50 | */ | 50 | */ |
51 | XmlNode *addChild( const char *sName, const char *sContent=NULL ); | 51 | XmlNode *addChild( const Bu::FString &sName ); |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Add an already created XmlNode as a child to this node. The new child | 54 | * Add an already created XmlNode as a child to this node. The new child |
@@ -65,7 +65,7 @@ public: | |||
65 | * in use will overwrite that property. | 65 | * in use will overwrite that property. |
66 | *@param sValue The textual value of the property. | 66 | *@param sValue The textual value of the property. |
67 | */ | 67 | */ |
68 | void addProperty( const char *sName, const char *sValue ); | 68 | void addProperty( const Bu::FString &sName, const Bu::FString &sValue ); |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * Get a pointer to the parent node, if any. | 71 | * Get a pointer to the parent node, if any. |
@@ -86,14 +86,6 @@ public: | |||
86 | int getNumChildren(); | 86 | int getNumChildren(); |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * Get a child node at a specific index. | ||
90 | *@param nIndex The zero-based index of the child to retreive. | ||
91 | *@returns A pointer to the child, or NULL if you requested an invalid | ||
92 | * index. | ||
93 | */ | ||
94 | XmlNode *getChild( int nIndex ); | ||
95 | |||
96 | /** | ||
97 | * Get a child with the specified name, and possibly skip value. For an | 89 | * Get a child with the specified name, and possibly skip value. For an |
98 | * explination of skip values see the HashTable. | 90 | * explination of skip values see the HashTable. |
99 | *@param sName The name of the child to find. | 91 | *@param sName The name of the child to find. |
@@ -101,14 +93,14 @@ public: | |||
101 | *@returns A pointer to the child, or NULL if no child with that name was | 93 | *@returns A pointer to the child, or NULL if no child with that name was |
102 | * found. | 94 | * found. |
103 | */ | 95 | */ |
104 | XmlNode *getChild( const char *sName, int nSkip=0 ); | 96 | XmlNode *getChild( const Bu::FString &sName, int nSkip=0 ); |
105 | 97 | ||
106 | /** | 98 | /** |
107 | * Get a pointer to the name of this node. Do not change this, use setName | 99 | * Get a pointer to the name of this node. Do not change this, use setName |
108 | * instead. | 100 | * instead. |
109 | *@returns A pointer to the name of this node. | 101 | *@returns A pointer to the name of this node. |
110 | */ | 102 | */ |
111 | const char *getName(); | 103 | Bu::FString getName(); |
112 | 104 | ||
113 | /** | 105 | /** |
114 | * Set the content of this node, optionally at a specific index. Using the | 106 | * Set the content of this node, optionally at a specific index. Using the |
@@ -116,14 +108,7 @@ public: | |||
116 | *@param sContent The content string to use. | 108 | *@param sContent The content string to use. |
117 | *@param nIndex The index of the content. | 109 | *@param nIndex The index of the content. |
118 | */ | 110 | */ |
119 | void setContent( const char *sContent, int nIndex=-1 ); | 111 | //void setContent( const char *sContent, int nIndex=-1 ); |
120 | |||
121 | /** | ||
122 | * Get the content string at a given index, or zero for initial content. | ||
123 | *@param nIndex The index of the content. | ||
124 | *@returns A pointer to the content at that location. | ||
125 | */ | ||
126 | const char *getContent( int nIndex = 0 ); | ||
127 | 112 | ||
128 | /** | 113 | /** |
129 | * Get the number of properties in this node. | 114 | * Get the number of properties in this node. |
@@ -132,36 +117,12 @@ public: | |||
132 | int getNumProperties(); | 117 | int getNumProperties(); |
133 | 118 | ||
134 | /** | 119 | /** |
135 | * Get a property's name by index. | ||
136 | *@param nIndex The index of the property to examine. | ||
137 | *@returns A pointer to the name of the property specified, or NULL if none | ||
138 | * found. | ||
139 | */ | ||
140 | const char *getPropertyName( int nIndex ); | ||
141 | |||
142 | /** | ||
143 | * Get a proprty's value by index. | ||
144 | *@param nIndex The index of the property to examine. | ||
145 | *@returns A pointer to the value of the property specified, or NULL if none | ||
146 | * found. | ||
147 | */ | ||
148 | const char *getProperty( int nIndex ); | ||
149 | |||
150 | /** | ||
151 | * Get a propery's value by name. | 120 | * Get a propery's value by name. |
152 | *@param sName The name of the property to examine. | 121 | *@param sName The name of the property to examine. |
153 | *@returns A pointer to the value of the property specified, or NULL if none | 122 | *@returns A pointer to the value of the property specified, or NULL if none |
154 | * found. | 123 | * found. |
155 | */ | 124 | */ |
156 | const char *getProperty( const char *sName ); | 125 | Bu::FString getProperty( const Bu::FString &sName ); |
157 | |||
158 | /** | ||
159 | * Delete a property by index. | ||
160 | *@param nIndex The index of the property to delete. | ||
161 | *@returns True if the property was found and deleted, false if it wasn't | ||
162 | * found. | ||
163 | */ | ||
164 | void deleteProperty( int nIndex ); | ||
165 | 126 | ||
166 | /** | 127 | /** |
167 | * Delete a child node, possibly replacing it with some text. This actually | 128 | * Delete a child node, possibly replacing it with some text. This actually |
@@ -171,7 +132,7 @@ public: | |||
171 | *@returns True of the node was found, and deleted, false if it wasn't | 132 | *@returns True of the node was found, and deleted, false if it wasn't |
172 | * found. | 133 | * found. |
173 | */ | 134 | */ |
174 | void deleteNode( int nIndex, const char *sReplacementText = NULL ); | 135 | //void deleteNode( int nIndex, const char *sReplacementText = NULL ); |
175 | 136 | ||
176 | /** | 137 | /** |
177 | * Delete a given node, but move all of it's children and content up to | 138 | * Delete a given node, but move all of it's children and content up to |
@@ -180,7 +141,7 @@ public: | |||
180 | *@param nIndex The node to delete. | 141 | *@param nIndex The node to delete. |
181 | *@returns True if the node was found and deleted, false if it wasn't. | 142 | *@returns True if the node was found and deleted, false if it wasn't. |
182 | */ | 143 | */ |
183 | void deleteNodeKeepChildren( int nIndex ); | 144 | //void deleteNodeKeepChildren( int nIndex ); |
184 | 145 | ||
185 | /** | 146 | /** |
186 | * Detatch a given child node from this node. This effectively works just | 147 | * Detatch a given child node from this node. This effectively works just |
@@ -192,7 +153,7 @@ public: | |||
192 | *@returns A pointer to the newly detatched node, which then passes | 153 | *@returns A pointer to the newly detatched node, which then passes |
193 | * ownership to the caller. | 154 | * ownership to the caller. |
194 | */ | 155 | */ |
195 | XmlNode *detatchNode( int nIndex, const char *sReplacementText = NULL ); | 156 | //XmlNode *detatchNode( int nIndex, const char *sReplacementText = NULL ); |
196 | 157 | ||
197 | /** | 158 | /** |
198 | * Replace a given node with a different node that is not currently owned by | 159 | * Replace a given node with a different node that is not currently owned by |
@@ -201,7 +162,7 @@ public: | |||
201 | *@param pNewNode The new node to replace the old node with. | 162 | *@param pNewNode The new node to replace the old node with. |
202 | *@returns True if the node was found and replaced, false if it wasn't. | 163 | *@returns True if the node was found and replaced, false if it wasn't. |
203 | */ | 164 | */ |
204 | void replaceNode( int nIndex, XmlNode *pNewNode ); | 165 | //void replaceNode( int nIndex, XmlNode *pNewNode ); |
205 | 166 | ||
206 | /** | 167 | /** |
207 | * Replace a given node with the children and content of a given node. | 168 | * Replace a given node with the children and content of a given node. |
@@ -210,24 +171,34 @@ public: | |||
210 | * replace the node specified by nIndex. | 171 | * replace the node specified by nIndex. |
211 | *@returns True if the node was found and replaced, false if it wasn't. | 172 | *@returns True if the node was found and replaced, false if it wasn't. |
212 | */ | 173 | */ |
213 | void replaceNodeWithChildren( int nIndex, XmlNode *pNewNode ); | 174 | //void replaceNodeWithChildren( int nIndex, XmlNode *pNewNode ); |
214 | 175 | ||
215 | /** | 176 | /** |
216 | * Get a copy of this node and all children. getCopy is recursive, so | 177 | * Get a copy of this node and all children. getCopy is recursive, so |
217 | * beware copying large trees of xml. | 178 | * beware copying large trees of xml. |
218 | *@returns A newly created copy of this node and all of it's children. | 179 | *@returns A newly created copy of this node and all of it's children. |
219 | */ | 180 | */ |
220 | XmlNode *getCopy(); | 181 | //XmlNode *getCopy(); |
182 | |||
183 | enum ChildType | ||
184 | { | ||
185 | typeNode, | ||
186 | typeContent | ||
187 | }; | ||
221 | 188 | ||
222 | private: | 189 | private: |
223 | std::string sName; /**< The name of the node. */ | 190 | typedef struct |
224 | std::string *sPreContent; /**< The content that goes before any node. */ | 191 | { |
225 | LinkedList lChildren; /**< The children. */ | 192 | uint8_t nType; |
226 | LinkedList lPostContent; /**< The content that comes after children. */ | 193 | union { |
227 | HashTable hProperties; /**< Property hashtable. */ | 194 | XmlNode *pNode; |
228 | HashTable hChildren; /**< Children hashtable. */ | 195 | Bu::FString *pContent; |
229 | LinkedList lPropNames; /**< List of property names. */ | 196 | }; |
230 | LinkedList lPropValues; /**< List of property values. */ | 197 | } Child; |
198 | Bu::FString sName; /**< The name of the node. */ | ||
199 | Bu::List<Child> lChildren; /**< The children. */ | ||
200 | Bu::Hash<Bu::FString, Bu::FString> hProperties; /**< Property hashtable. */ | ||
201 | Bu::Hash<Bu::FString, Bu::List<XmlNode *> > hChildren; /**< Children hashtable. */ | ||
231 | XmlNode *pParent; /**< A pointer to the parent of this node. */ | 202 | XmlNode *pParent; /**< A pointer to the parent of this node. */ |
232 | int nCurContent; /**< The current content we're on, for using the -1 on | 203 | int nCurContent; /**< The current content we're on, for using the -1 on |
233 | setContent. */ | 204 | setContent. */ |
diff --git a/src/xmlreader.cpp b/src/old/xmlreader.cpp index 18df69c..38cad5f 100644 --- a/src/xmlreader.cpp +++ b/src/old/xmlreader.cpp | |||
@@ -1,32 +1,49 @@ | |||
1 | #include "xmlreader.h" | 1 | #include "bu/xmlreader.h" |
2 | #include "exceptions.h" | 2 | #include "bu/exceptions.h" |
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include "hashfunctionstring.h" | ||
5 | 4 | ||
6 | XmlReader::XmlReader( bool bStrip ) : | 5 | XmlReader::XmlReader( Bu::Stream &sIn, bool bStrip ) : |
7 | bStrip( bStrip ), | 6 | sIn( sIn ), |
8 | htEntity( new HashFunctionString(), 11 ) | 7 | bStrip( bStrip ) |
9 | { | 8 | { |
9 | buildDoc(); | ||
10 | } | 10 | } |
11 | 11 | ||
12 | XmlReader::~XmlReader() | 12 | XmlReader::~XmlReader() |
13 | { | 13 | { |
14 | void *i = htEntity.getFirstItemPos(); | 14 | } |
15 | while( (i = htEntity.getNextItemPos( i ) ) ) | 15 | |
16 | char XmlReader::getChar( int nIndex ) | ||
17 | { | ||
18 | if( sBuf.getSize() <= nIndex ) | ||
16 | { | 19 | { |
17 | free( (char *)(htEntity.getItemID( i )) ); | 20 | int nInc = nIndex-sBuf.getSize()+1; |
18 | delete (StaticString *)htEntity.getItemData( i ); | 21 | char *buf = new char[nInc]; |
22 | sIn.read( buf, nInc ); | ||
23 | sBuf.append( buf, nInc ); | ||
24 | delete[] buf; | ||
19 | } | 25 | } |
26 | |||
27 | return sBuf[nIndex]; | ||
20 | } | 28 | } |
21 | 29 | ||
22 | void XmlReader::addEntity( const char *name, const char *value ) | 30 | void XmlReader::usedChar( int nAmnt ) |
23 | { | 31 | { |
24 | if( htEntity[name] ) return; | 32 | if( nAmnt >= sBuf.getSize() ) |
25 | 33 | { | |
26 | char *sName = strdup( name ); | 34 | sBuf.clear(); |
27 | StaticString *sValue = new StaticString( value ); | 35 | } |
36 | else | ||
37 | { | ||
38 | char *s = sBuf.getStr(); | ||
39 | memcpy( s, s+nAmnt, sBuf.getSize()-nAmnt ); | ||
40 | sBuf.resize( sBuf.getSize()-nAmnt ); | ||
41 | } | ||
42 | } | ||
28 | 43 | ||
29 | htEntity.insert( sName, sValue ); | 44 | void XmlReader::addEntity( const Bu::FString &name, const Bu::FString &value ) |
45 | { | ||
46 | htEntity[name] = value; | ||
30 | } | 47 | } |
31 | 48 | ||
32 | #define gcall( x ) if( x == false ) return false; | 49 | #define gcall( x ) if( x == false ) return false; |
@@ -99,7 +116,7 @@ void XmlReader::entity() | |||
99 | { | 116 | { |
100 | usedChar( 2 ); | 117 | usedChar( 2 ); |
101 | ws(); | 118 | ws(); |
102 | std::string buf; | 119 | Bu::FString buf; |
103 | for(;;) | 120 | for(;;) |
104 | { | 121 | { |
105 | char chr = getChar(); | 122 | char chr = getChar(); |
@@ -111,7 +128,7 @@ void XmlReader::entity() | |||
111 | if( strcmp( buf.c_str(), "ENTITY") == 0 ) | 128 | if( strcmp( buf.c_str(), "ENTITY") == 0 ) |
112 | { | 129 | { |
113 | ws(); | 130 | ws(); |
114 | std::string name; | 131 | Bu::FString name; |
115 | for(;;) | 132 | for(;;) |
116 | { | 133 | { |
117 | char chr = getChar(); | 134 | char chr = getChar(); |
@@ -124,21 +141,19 @@ void XmlReader::entity() | |||
124 | usedChar(); | 141 | usedChar(); |
125 | if( quot != '\'' && quot != '\"' ) | 142 | if( quot != '\'' && quot != '\"' ) |
126 | { | 143 | { |
127 | throw XmlException( | 144 | throw Bu::XmlException( |
128 | "Only quoted entity values are supported." | 145 | "Only quoted entity values are supported." |
129 | ); | 146 | ); |
130 | } | 147 | } |
131 | std::string value; | 148 | Bu::FString value; |
132 | for(;;) | 149 | for(;;) |
133 | { | 150 | { |
134 | char chr = getChar(); | 151 | char chr = getChar(); |
135 | usedChar(); | 152 | usedChar(); |
136 | if( chr == '&' ) | 153 | if( chr == '&' ) |
137 | { | 154 | { |
138 | StaticString *tmp = getEscape(); | 155 | Bu::FString tmp = getEscape(); |
139 | if( tmp == NULL ) throw XmlException("Entity thing"); | 156 | value += tmp; |
140 | value += tmp->getString(); | ||
141 | delete tmp; | ||
142 | } | 157 | } |
143 | else if( chr == quot ) | 158 | else if( chr == quot ) |
144 | { | 159 | { |
@@ -158,7 +173,7 @@ void XmlReader::entity() | |||
158 | } | 173 | } |
159 | else | 174 | else |
160 | { | 175 | { |
161 | throw XmlException( | 176 | throw Bu::XmlException( |
162 | "Malformed ENTITY: unexpected '%c' found.", | 177 | "Malformed ENTITY: unexpected '%c' found.", |
163 | getChar() | 178 | getChar() |
164 | ); | 179 | ); |
@@ -166,7 +181,7 @@ void XmlReader::entity() | |||
166 | } | 181 | } |
167 | else | 182 | else |
168 | { | 183 | { |
169 | throw XmlException( | 184 | throw Bu::XmlException( |
170 | "Unsupported header symbol: %s", | 185 | "Unsupported header symbol: %s", |
171 | buf.c_str() | 186 | buf.c_str() |
172 | ); | 187 | ); |
@@ -203,12 +218,12 @@ bool XmlReader::node() | |||
203 | } | 218 | } |
204 | else | 219 | else |
205 | { | 220 | { |
206 | throw XmlException("Close node in singleNode malformed!"); | 221 | throw Bu::XmlException("Close node in singleNode malformed!"); |
207 | } | 222 | } |
208 | } | 223 | } |
209 | else | 224 | else |
210 | { | 225 | { |
211 | throw XmlException("Close node expected, but not found."); | 226 | throw Bu::XmlException("Close node expected, but not found."); |
212 | return false; | 227 | return false; |
213 | } | 228 | } |
214 | 229 | ||
@@ -224,7 +239,7 @@ bool XmlReader::startNode() | |||
224 | if( getChar() == '/' ) | 239 | if( getChar() == '/' ) |
225 | { | 240 | { |
226 | // Heh, it's actually a close node, go figure | 241 | // Heh, it's actually a close node, go figure |
227 | FlexBuf fbName; | 242 | Bu::FString sName; |
228 | usedChar(); | 243 | usedChar(); |
229 | gcall( ws() ); | 244 | gcall( ws() ); |
230 | 245 | ||
@@ -235,19 +250,19 @@ bool XmlReader::startNode() | |||
235 | { | 250 | { |
236 | // Here we actually compare the name we got to the name | 251 | // Here we actually compare the name we got to the name |
237 | // we already set, they have to match exactly. | 252 | // we already set, they have to match exactly. |
238 | if( !strcasecmp( getCurrent()->getName(), fbName.getData() ) ) | 253 | if( getCurrent()->getName() == sName ) |
239 | { | 254 | { |
240 | closeNode(); | 255 | closeNode(); |
241 | break; | 256 | break; |
242 | } | 257 | } |
243 | else | 258 | else |
244 | { | 259 | { |
245 | throw XmlException("Got a mismatched node close tag."); | 260 | throw Bu::XmlException("Got a mismatched node close tag."); |
246 | } | 261 | } |
247 | } | 262 | } |
248 | else | 263 | else |
249 | { | 264 | { |
250 | fbName.appendData( chr ); | 265 | sName += chr; |
251 | usedChar(); | 266 | usedChar(); |
252 | } | 267 | } |
253 | } | 268 | } |
@@ -260,13 +275,13 @@ bool XmlReader::startNode() | |||
260 | } | 275 | } |
261 | else | 276 | else |
262 | { | 277 | { |
263 | throw XmlException("Got extra junk data instead of node close tag."); | 278 | throw Bu::XmlException("Got extra junk data instead of node close tag."); |
264 | } | 279 | } |
265 | } | 280 | } |
266 | else | 281 | else |
267 | { | 282 | { |
268 | // We're good, format is consistant | 283 | // We're good, format is consistant |
269 | addNode(); | 284 | //addNode(); |
270 | 285 | ||
271 | // Skip extra whitespace | 286 | // Skip extra whitespace |
272 | gcall( ws() ); | 287 | gcall( ws() ); |
@@ -278,7 +293,7 @@ bool XmlReader::startNode() | |||
278 | } | 293 | } |
279 | else | 294 | else |
280 | { | 295 | { |
281 | throw XmlException("Expected to find node opening char, '<'."); | 296 | throw Bu::XmlException("Expected to find node opening char, '<'."); |
282 | } | 297 | } |
283 | 298 | ||
284 | return true; | 299 | return true; |
@@ -286,19 +301,19 @@ bool XmlReader::startNode() | |||
286 | 301 | ||
287 | bool XmlReader::name() | 302 | bool XmlReader::name() |
288 | { | 303 | { |
289 | FlexBuf fbName; | 304 | Bu::FString sName; |
290 | 305 | ||
291 | while( true ) | 306 | while( true ) |
292 | { | 307 | { |
293 | char chr = getChar(); | 308 | char chr = getChar(); |
294 | if( isws( chr ) || chr == '>' || chr == '/' ) | 309 | if( isws( chr ) || chr == '>' || chr == '/' ) |
295 | { | 310 | { |
296 | setName( fbName.getData() ); | 311 | addNode( sName ); |
297 | return true; | 312 | return true; |
298 | } | 313 | } |
299 | else | 314 | else |
300 | { | 315 | { |
301 | fbName.appendData( chr ); | 316 | sName += chr; |
302 | usedChar(); | 317 | usedChar(); |
303 | } | 318 | } |
304 | } | 319 | } |
@@ -325,7 +340,7 @@ bool XmlReader::paramlist() | |||
325 | return true; | 340 | return true; |
326 | } | 341 | } |
327 | 342 | ||
328 | StaticString *XmlReader::getEscape() | 343 | Bu::FString XmlReader::getEscape() |
329 | { | 344 | { |
330 | if( getChar( 1 ) == '#' ) | 345 | if( getChar( 1 ) == '#' ) |
331 | { | 346 | { |
@@ -349,12 +364,12 @@ StaticString *XmlReader::getEscape() | |||
349 | buf[0] = (char)strtol( buf, (char **)NULL, base ); | 364 | buf[0] = (char)strtol( buf, (char **)NULL, base ); |
350 | buf[1] = '\0'; | 365 | buf[1] = '\0'; |
351 | 366 | ||
352 | return new StaticString( buf ); | 367 | return buf; |
353 | } | 368 | } |
354 | else | 369 | else |
355 | { | 370 | { |
356 | // ...otherwise replace with the appropriate string... | 371 | // ...otherwise replace with the appropriate string... |
357 | std::string buf; | 372 | Bu::FString buf; |
358 | usedChar(); | 373 | usedChar(); |
359 | for(;;) | 374 | for(;;) |
360 | { | 375 | { |
@@ -364,18 +379,14 @@ StaticString *XmlReader::getEscape() | |||
364 | buf += cbuf; | 379 | buf += cbuf; |
365 | } | 380 | } |
366 | 381 | ||
367 | StaticString *tmp = (StaticString *)htEntity[buf.c_str()]; | 382 | return htEntity[buf]; |
368 | if( tmp == NULL ) return NULL; | ||
369 | |||
370 | StaticString *ret = new StaticString( *tmp ); | ||
371 | return ret; | ||
372 | } | 383 | } |
373 | } | 384 | } |
374 | 385 | ||
375 | bool XmlReader::param() | 386 | bool XmlReader::param() |
376 | { | 387 | { |
377 | FlexBuf fbName; | 388 | Bu::FString sName; |
378 | FlexBuf fbValue; | 389 | Bu::FString sValue; |
379 | 390 | ||
380 | while( true ) | 391 | while( true ) |
381 | { | 392 | { |
@@ -386,7 +397,7 @@ bool XmlReader::param() | |||
386 | } | 397 | } |
387 | else | 398 | else |
388 | { | 399 | { |
389 | fbName.appendData( chr ); | 400 | sName.append( chr ); |
390 | usedChar(); | 401 | usedChar(); |
391 | } | 402 | } |
392 | } | 403 | } |
@@ -411,21 +422,18 @@ bool XmlReader::param() | |||
411 | if( chr == '"' ) | 422 | if( chr == '"' ) |
412 | { | 423 | { |
413 | usedChar(); | 424 | usedChar(); |
414 | addProperty( fbName.getData(), fbValue.getData() ); | 425 | addProperty( sName.getStr(), sValue.getStr() ); |
415 | return true; | 426 | return true; |
416 | } | 427 | } |
417 | else | 428 | else |
418 | { | 429 | { |
419 | if( chr == '&' ) | 430 | if( chr == '&' ) |
420 | { | 431 | { |
421 | StaticString *tmp = getEscape(); | 432 | sValue += getEscape(); |
422 | if( tmp == NULL ) return false; | ||
423 | fbValue.appendData( tmp->getString() ); | ||
424 | delete tmp; | ||
425 | } | 433 | } |
426 | else | 434 | else |
427 | { | 435 | { |
428 | fbValue.appendData( chr ); | 436 | sValue += chr; |
429 | usedChar(); | 437 | usedChar(); |
430 | } | 438 | } |
431 | } | 439 | } |
@@ -439,21 +447,18 @@ bool XmlReader::param() | |||
439 | chr = getChar(); | 447 | chr = getChar(); |
440 | if( isws( chr ) || chr == '/' || chr == '>' ) | 448 | if( isws( chr ) || chr == '/' || chr == '>' ) |
441 | { | 449 | { |
442 | addProperty( fbName.getData(), fbValue.getData() ); | 450 | addProperty( sName.getStr(), sValue.getStr() ); |
443 | return true; | 451 | return true; |
444 | } | 452 | } |
445 | else | 453 | else |
446 | { | 454 | { |
447 | if( chr == '&' ) | 455 | if( chr == '&' ) |
448 | { | 456 | { |
449 | StaticString *tmp = getEscape(); | 457 | sValue += getEscape(); |
450 | if( tmp == NULL ) return false; | ||
451 | fbValue.appendData( tmp->getString() ); | ||
452 | delete tmp; | ||
453 | } | 458 | } |
454 | else | 459 | else |
455 | { | 460 | { |
456 | fbValue.appendData( chr ); | 461 | sValue += chr; |
457 | usedChar(); | 462 | usedChar(); |
458 | } | 463 | } |
459 | } | 464 | } |
@@ -462,7 +467,7 @@ bool XmlReader::param() | |||
462 | } | 467 | } |
463 | else | 468 | else |
464 | { | 469 | { |
465 | throw XmlException("Expected an equals to seperate the params."); | 470 | throw Bu::XmlException("Expected an equals to seperate the params."); |
466 | return false; | 471 | return false; |
467 | } | 472 | } |
468 | 473 | ||
@@ -471,7 +476,7 @@ bool XmlReader::param() | |||
471 | 476 | ||
472 | bool XmlReader::content() | 477 | bool XmlReader::content() |
473 | { | 478 | { |
474 | FlexBuf fbContent; | 479 | Bu::FString sContent; |
475 | 480 | ||
476 | if( bStrip ) gcall( ws() ); | 481 | if( bStrip ) gcall( ws() ); |
477 | 482 | ||
@@ -482,37 +487,37 @@ bool XmlReader::content() | |||
482 | { | 487 | { |
483 | if( getChar(1) == '/' ) | 488 | if( getChar(1) == '/' ) |
484 | { | 489 | { |
485 | if( fbContent.getLength() > 0 ) | 490 | if( sContent.getSize() > 0 ) |
486 | { | 491 | { |
487 | if( bStrip ) | 492 | if( bStrip ) |
488 | { | 493 | { |
489 | int j; | 494 | int j; |
490 | for( j = fbContent.getLength()-1; isws(fbContent.getData()[j]); j-- ); | 495 | for( j = sContent.getSize()-1; isws(sContent[j]); j-- ); |
491 | ((char *)fbContent.getData())[j+1] = '\0'; | 496 | sContent[j+1] = '\0'; |
492 | } | 497 | } |
493 | setContent( fbContent.getData() ); | 498 | setContent( sContent.getStr() ); |
494 | } | 499 | } |
495 | usedChar( 2 ); | 500 | usedChar( 2 ); |
496 | gcall( ws() ); | 501 | gcall( ws() ); |
497 | FlexBuf fbName; | 502 | Bu::FString sName; |
498 | while( true ) | 503 | while( true ) |
499 | { | 504 | { |
500 | chr = getChar(); | 505 | chr = getChar(); |
501 | if( isws( chr ) || chr == '>' ) | 506 | if( isws( chr ) || chr == '>' ) |
502 | { | 507 | { |
503 | if( !strcasecmp( getCurrent()->getName(), fbName.getData() ) ) | 508 | if( !strcasecmp( getCurrent()->getName().getStr(), sName.getStr() ) ) |
504 | { | 509 | { |
505 | closeNode(); | 510 | closeNode(); |
506 | break; | 511 | break; |
507 | } | 512 | } |
508 | else | 513 | else |
509 | { | 514 | { |
510 | throw XmlException("Mismatched close tag found: <%s> to <%s>.", getCurrent()->getName(), fbName.getData() ); | 515 | throw Bu::XmlException("Mismatched close tag found: <%s> to <%s>.", getCurrent()->getName().getStr(), sName.getStr() ); |
511 | } | 516 | } |
512 | } | 517 | } |
513 | else | 518 | else |
514 | { | 519 | { |
515 | fbName.appendData( chr ); | 520 | sName += chr; |
516 | usedChar(); | 521 | usedChar(); |
517 | } | 522 | } |
518 | } | 523 | } |
@@ -524,7 +529,7 @@ bool XmlReader::content() | |||
524 | } | 529 | } |
525 | else | 530 | else |
526 | { | 531 | { |
527 | throw XmlException("Malformed close tag."); | 532 | throw Bu::XmlException("Malformed close tag."); |
528 | } | 533 | } |
529 | } | 534 | } |
530 | else if( getChar(1) == '!' ) | 535 | else if( getChar(1) == '!' ) |
@@ -534,7 +539,7 @@ bool XmlReader::content() | |||
534 | getChar(3) != '-' ) | 539 | getChar(3) != '-' ) |
535 | { | 540 | { |
536 | // Not a valid XML comment | 541 | // Not a valid XML comment |
537 | throw XmlException("Malformed comment start tag found."); | 542 | throw Bu::XmlException("Malformed comment start tag found."); |
538 | } | 543 | } |
539 | 544 | ||
540 | usedChar( 4 ); | 545 | usedChar( 4 ); |
@@ -549,7 +554,7 @@ bool XmlReader::content() | |||
549 | // The next one has to be a '>' now | 554 | // The next one has to be a '>' now |
550 | if( getChar( 2 ) != '>' ) | 555 | if( getChar( 2 ) != '>' ) |
551 | { | 556 | { |
552 | throw XmlException("Malformed comment close tag found. You cannot have a '--' that isn't followed by a '>' in a comment."); | 557 | throw Bu::XmlException("Malformed comment close tag found. You cannot have a '--' that isn't followed by a '>' in a comment."); |
553 | } | 558 | } |
554 | usedChar( 3 ); | 559 | usedChar( 3 ); |
555 | break; | 560 | break; |
@@ -569,16 +574,16 @@ bool XmlReader::content() | |||
569 | } | 574 | } |
570 | else | 575 | else |
571 | { | 576 | { |
572 | if( fbContent.getLength() > 0 ) | 577 | if( sContent.getSize() > 0 ) |
573 | { | 578 | { |
574 | if( bStrip ) | 579 | if( bStrip ) |
575 | { | 580 | { |
576 | int j; | 581 | int j; |
577 | for( j = fbContent.getLength()-1; isws(fbContent.getData()[j]); j-- ); | 582 | for( j = sContent.getSize()-1; isws(sContent[j]); j-- ); |
578 | ((char *)fbContent.getData())[j+1] = '\0'; | 583 | sContent[j+1] = '\0'; |
579 | } | 584 | } |
580 | setContent( fbContent.getData() ); | 585 | setContent( sContent.getStr() ); |
581 | fbContent.clearData(); | 586 | sContent.clear(); |
582 | } | 587 | } |
583 | gcall( node() ); | 588 | gcall( node() ); |
584 | } | 589 | } |
@@ -587,14 +592,11 @@ bool XmlReader::content() | |||
587 | } | 592 | } |
588 | else if( chr == '&' ) | 593 | else if( chr == '&' ) |
589 | { | 594 | { |
590 | StaticString *tmp = getEscape(); | 595 | sContent += getEscape(); |
591 | if( tmp == NULL ) return false; | ||
592 | fbContent.appendData( tmp->getString() ); | ||
593 | delete tmp; | ||
594 | } | 596 | } |
595 | else | 597 | else |
596 | { | 598 | { |
597 | fbContent.appendData( chr ); | 599 | sContent += chr; |
598 | usedChar(); | 600 | usedChar(); |
599 | } | 601 | } |
600 | } | 602 | } |
diff --git a/src/xmlreader.h b/src/old/xmlreader.h index c8f7202..7c85ddb 100644 --- a/src/xmlreader.h +++ b/src/old/xmlreader.h | |||
@@ -2,10 +2,10 @@ | |||
2 | #define XMLREADER | 2 | #define XMLREADER |
3 | 3 | ||
4 | #include <stdio.h> | 4 | #include <stdio.h> |
5 | #include "xmldocument.h" | 5 | #include "bu/xmldocument.h" |
6 | #include "flexbuf.h" | 6 | #include "bu/hash.h" |
7 | #include "hashtable.h" | 7 | #include "bu/fstring.h" |
8 | #include "staticstring.h" | 8 | #include "bu/stream.h" |
9 | 9 | ||
10 | /** | 10 | /** |
11 | * Takes care of reading in xml formatted data from a file. This could/should | 11 | * Takes care of reading in xml formatted data from a file. This could/should |
@@ -32,7 +32,7 @@ public: | |||
32 | * in content, a-la html. | 32 | * in content, a-la html. |
33 | *@param bStrip Strip out leading and trailing whitespace? | 33 | *@param bStrip Strip out leading and trailing whitespace? |
34 | */ | 34 | */ |
35 | XmlReader( bool bStrip=false ); | 35 | XmlReader( Bu::Stream &sIn, bool bStrip=false ); |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * Destroy this XmlReader. | 38 | * Destroy this XmlReader. |
@@ -54,12 +54,12 @@ private: | |||
54 | *@returns A single character at the requested position, or 0 for end of | 54 | *@returns A single character at the requested position, or 0 for end of |
55 | * stream. | 55 | * stream. |
56 | */ | 56 | */ |
57 | virtual char getChar( int nIndex = 0 ) = 0; | 57 | virtual char getChar( int nIndex = 0 ); |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * Called to increment the current stream position by a single character. | 60 | * Called to increment the current stream position by a single character. |
61 | */ | 61 | */ |
62 | virtual void usedChar( int nAmnt = 1) = 0; | 62 | virtual void usedChar( int nAmnt = 1 ); |
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Automoton function: is whitespace. | 65 | * Automoton function: is whitespace. |
@@ -108,9 +108,9 @@ private: | |||
108 | *@param name The name of the entity | 108 | *@param name The name of the entity |
109 | *@param value The value of the entity | 109 | *@param value The value of the entity |
110 | */ | 110 | */ |
111 | void addEntity( const char *name, const char *value ); | 111 | void addEntity( const Bu::FString &name, const Bu::FString &value ); |
112 | 112 | ||
113 | StaticString *getEscape(); | 113 | Bu::FString getEscape(); |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * Automoton function: paramlist. Processes a list of node params. | 116 | * Automoton function: paramlist. Processes a list of node params. |
@@ -130,12 +130,15 @@ private: | |||
130 | */ | 130 | */ |
131 | bool content(); | 131 | bool content(); |
132 | 132 | ||
133 | FlexBuf fbContent; /**< buffer for the current node's content. */ | 133 | Bu::FString sContent; /**< buffer for the current node's content. */ |
134 | FlexBuf fbParamName; /**< buffer for the current param's name. */ | 134 | Bu::FString sParamName; /**< buffer for the current param's name. */ |
135 | FlexBuf fbParamValue; /**< buffer for the current param's value. */ | 135 | Bu::FString sParamValue; /**< buffer for the current param's value. */ |
136 | bool bStrip; /**< Are we stripping whitespace? */ | 136 | Bu::Stream &sIn; |
137 | bool bStrip; /**< Are we stripping whitespace? */ | ||
137 | 138 | ||
138 | HashTable htEntity; /**< Entity type definitions. */ | 139 | Bu::Hash<Bu::FString,Bu::FString> htEntity; /**< Entity type definitions. */ |
140 | |||
141 | Bu::FString sBuf; | ||
139 | }; | 142 | }; |
140 | 143 | ||
141 | #endif | 144 | #endif |
diff --git a/src/xmlstringreader.cpp b/src/old/xmlstringreader.cpp index 3956ff3..3956ff3 100644 --- a/src/xmlstringreader.cpp +++ b/src/old/xmlstringreader.cpp | |||
diff --git a/src/xmlstringreader.h b/src/old/xmlstringreader.h index 1239ef4..1239ef4 100644 --- a/src/xmlstringreader.h +++ b/src/old/xmlstringreader.h | |||
diff --git a/src/xmlstringwriter.cpp b/src/old/xmlstringwriter.cpp index adeed6a..adeed6a 100644 --- a/src/xmlstringwriter.cpp +++ b/src/old/xmlstringwriter.cpp | |||
diff --git a/src/xmlstringwriter.h b/src/old/xmlstringwriter.h index 0d567b9..0d567b9 100644 --- a/src/xmlstringwriter.h +++ b/src/old/xmlstringwriter.h | |||
diff --git a/src/xmlwriter.cpp b/src/old/xmlwriter.cpp index 56880b6..7dc6ca9 100644 --- a/src/xmlwriter.cpp +++ b/src/old/xmlwriter.cpp | |||
@@ -2,17 +2,10 @@ | |||
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include "xmlwriter.h" | 3 | #include "xmlwriter.h" |
4 | 4 | ||
5 | XmlWriter::XmlWriter( const char *sIndent, XmlNode *pRoot ) : | 5 | XmlWriter::XmlWriter( const Bu::FString &sIndent, XmlNode *pRoot ) : |
6 | XmlDocument( pRoot ) | 6 | XmlDocument( pRoot ), |
7 | sIndent( sIndent ) | ||
7 | { | 8 | { |
8 | if( sIndent == NULL ) | ||
9 | { | ||
10 | this->sIndent = ""; | ||
11 | } | ||
12 | else | ||
13 | { | ||
14 | this->sIndent = sIndent; | ||
15 | } | ||
16 | } | 9 | } |
17 | 10 | ||
18 | XmlWriter::~XmlWriter() | 11 | XmlWriter::~XmlWriter() |
@@ -24,7 +17,7 @@ void XmlWriter::write() | |||
24 | write( getRoot(), sIndent.c_str() ); | 17 | write( getRoot(), sIndent.c_str() ); |
25 | } | 18 | } |
26 | 19 | ||
27 | void XmlWriter::write( XmlNode *pRoot, const char *sIndent ) | 20 | void XmlWriter::write( XmlNode *pRoot, const Bu::FString &sIndent ) |
28 | { | 21 | { |
29 | writeNode( pRoot, 0, sIndent ); | 22 | writeNode( pRoot, 0, sIndent ); |
30 | } | 23 | } |
@@ -39,7 +32,7 @@ void XmlWriter::closeNode() | |||
39 | } | 32 | } |
40 | } | 33 | } |
41 | 34 | ||
42 | void XmlWriter::writeIndent( int nIndent, const char *sIndent ) | 35 | void XmlWriter::writeIndent( int nIndent, const Bu::FString &sIndent ) |
43 | { | 36 | { |
44 | if( sIndent == NULL ) return; | 37 | if( sIndent == NULL ) return; |
45 | for( int j = 0; j < nIndent; j++ ) | 38 | for( int j = 0; j < nIndent; j++ ) |
@@ -48,26 +41,27 @@ void XmlWriter::writeIndent( int nIndent, const char *sIndent ) | |||
48 | } | 41 | } |
49 | } | 42 | } |
50 | 43 | ||
51 | std::string XmlWriter::escape( std::string sIn ) | 44 | Bu::FString XmlWriter::escape( const Bu::FString &sIn ) |
52 | { | 45 | { |
53 | std::string sOut; | 46 | Bu::FString sOut; |
54 | 47 | ||
55 | std::string::const_iterator i; | 48 | int nMax = sIn.getSize(); |
56 | for( i = sIn.begin(); i != sIn.end(); i++ ) | 49 | for( int j = 0; j < nMax; j++ ) |
57 | { | 50 | { |
58 | if( ((*i >= ' ' && *i <= '9') || | 51 | char c = sIn[j]; |
59 | (*i >= 'a' && *i <= 'z') || | 52 | if( ((c >= ' ' && c <= '9') || |
60 | (*i >= 'A' && *i <= 'Z') ) && | 53 | (c >= 'a' && c <= 'z') || |
61 | (*i != '\"' && *i != '\'' && *i != '&') | 54 | (c >= 'A' && c <= 'Z') ) && |
55 | (c != '\"' && c != '\'' && c != '&') | ||
62 | ) | 56 | ) |
63 | { | 57 | { |
64 | sOut += *i; | 58 | sOut += c; |
65 | } | 59 | } |
66 | else | 60 | else |
67 | { | 61 | { |
68 | sOut += "&#"; | 62 | sOut += "&#"; |
69 | char buf[4]; | 63 | char buf[4]; |
70 | sprintf( buf, "%u", (unsigned char)*i ); | 64 | sprintf( buf, "%u", (unsigned char)c ); |
71 | sOut += buf; | 65 | sOut += buf; |
72 | sOut += ';'; | 66 | sOut += ';'; |
73 | } | 67 | } |
@@ -76,19 +70,19 @@ std::string XmlWriter::escape( std::string sIn ) | |||
76 | return sOut; | 70 | return sOut; |
77 | } | 71 | } |
78 | 72 | ||
79 | void XmlWriter::writeNodeProps( XmlNode *pNode, int nIndent, const char *sIndent ) | 73 | void XmlWriter::writeNodeProps( XmlNode *pNode, int nIndent, const Bu::FString &sIndent ) |
80 | { | 74 | { |
81 | for( int j = 0; j < pNode->getNumProperties(); j++ ) | 75 | for( int j = 0; j < pNode->getNumProperties(); j++ ) |
82 | { | 76 | { |
83 | writeString(" "); | 77 | writeString(" "); |
84 | writeString( pNode->getPropertyName( j ) ); | 78 | //writeString( pNode->getPropertyName( j ) ); |
85 | writeString("=\""); | 79 | writeString("=\""); |
86 | writeString( escape( pNode->getProperty( j ) ).c_str() ); | 80 | //writeString( escape( pNode->getProperty( j ) ).c_str() ); |
87 | writeString("\""); | 81 | writeString("\""); |
88 | } | 82 | } |
89 | } | 83 | } |
90 | 84 | ||
91 | void XmlWriter::writeNode( XmlNode *pNode, int nIndent, const char *sIndent ) | 85 | void XmlWriter::writeNode( XmlNode *pNode, int nIndent, const Bu::FString &sIndent ) |
92 | { | 86 | { |
93 | if( pNode->hasChildren() ) | 87 | if( pNode->hasChildren() ) |
94 | { | 88 | { |
@@ -96,15 +90,15 @@ void XmlWriter::writeNode( XmlNode *pNode, int nIndent, const char *sIndent ) | |||
96 | writeString("<"); | 90 | writeString("<"); |
97 | writeString( pNode->getName() ); | 91 | writeString( pNode->getName() ); |
98 | writeNodeProps( pNode, nIndent, sIndent ); | 92 | writeNodeProps( pNode, nIndent, sIndent ); |
99 | if( sIndent ) | 93 | if( sIndent != "" ) |
100 | writeString(">\n"); | 94 | writeString(">\n"); |
101 | else | 95 | else |
102 | writeString(">"); | 96 | writeString(">"); |
103 | 97 | /* | |
104 | if( pNode->getContent( 0 ) ) | 98 | if( pNode->getContent( 0 ) ) |
105 | { | 99 | { |
106 | writeIndent( nIndent+1, sIndent ); | 100 | writeIndent( nIndent+1, sIndent ); |
107 | if( sIndent ) | 101 | if( sIndent != "" ) |
108 | { | 102 | { |
109 | writeString( pNode->getContent( 0 ) ); | 103 | writeString( pNode->getContent( 0 ) ); |
110 | writeString("\n"); | 104 | writeString("\n"); |
@@ -129,9 +123,9 @@ void XmlWriter::writeNode( XmlNode *pNode, int nIndent, const char *sIndent ) | |||
129 | writeString( pNode->getContent( j+1 ) ); | 123 | writeString( pNode->getContent( j+1 ) ); |
130 | } | 124 | } |
131 | } | 125 | } |
132 | 126 | */ | |
133 | writeIndent( nIndent, sIndent ); | 127 | writeIndent( nIndent, sIndent ); |
134 | if( sIndent ) | 128 | if( sIndent != "" ) |
135 | { | 129 | { |
136 | writeString("</"); | 130 | writeString("</"); |
137 | writeString( pNode->getName() ); | 131 | writeString( pNode->getName() ); |
@@ -143,7 +137,7 @@ void XmlWriter::writeNode( XmlNode *pNode, int nIndent, const char *sIndent ) | |||
143 | writeString( pNode->getName() ); | 137 | writeString( pNode->getName() ); |
144 | writeString(">"); | 138 | writeString(">"); |
145 | } | 139 | } |
146 | } | 140 | }/* |
147 | else if( pNode->getContent() ) | 141 | else if( pNode->getContent() ) |
148 | { | 142 | { |
149 | writeIndent( nIndent, sIndent ); | 143 | writeIndent( nIndent, sIndent ); |
@@ -157,14 +151,14 @@ void XmlWriter::writeNode( XmlNode *pNode, int nIndent, const char *sIndent ) | |||
157 | writeString(">"); | 151 | writeString(">"); |
158 | if( sIndent ) | 152 | if( sIndent ) |
159 | writeString("\n"); | 153 | writeString("\n"); |
160 | } | 154 | }*/ |
161 | else | 155 | else |
162 | { | 156 | { |
163 | writeIndent( nIndent, sIndent ); | 157 | writeIndent( nIndent, sIndent ); |
164 | writeString("<"); | 158 | writeString("<"); |
165 | writeString( pNode->getName() ); | 159 | writeString( pNode->getName() ); |
166 | writeNodeProps( pNode, nIndent, sIndent ); | 160 | writeNodeProps( pNode, nIndent, sIndent ); |
167 | if( sIndent ) | 161 | if( sIndent != "" ) |
168 | writeString("/>\n"); | 162 | writeString("/>\n"); |
169 | else | 163 | else |
170 | writeString("/>"); | 164 | writeString("/>"); |
diff --git a/src/xmlwriter.h b/src/old/xmlwriter.h index c48e810..7e3c876 100644 --- a/src/xmlwriter.h +++ b/src/old/xmlwriter.h | |||
@@ -31,7 +31,7 @@ public: | |||
31 | * this to a tab or some spaces it will never effect the content of your | 31 | * this to a tab or some spaces it will never effect the content of your |
32 | * file. | 32 | * file. |
33 | */ | 33 | */ |
34 | XmlWriter( const char *sIndent=NULL, XmlNode *pRoot=NULL ); | 34 | XmlWriter( const Bu::FString &sIndent="", XmlNode *pRoot=NULL ); |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Destroy the writer. | 37 | * Destroy the writer. |
@@ -49,16 +49,16 @@ public: | |||
49 | void write(); | 49 | void write(); |
50 | 50 | ||
51 | private: | 51 | private: |
52 | std::string sIndent; /**< The indent string */ | 52 | Bu::FString sIndent; /**< The indent string */ |
53 | 53 | ||
54 | std::string escape( std::string sIn ); | 54 | Bu::FString escape( const Bu::FString &sIn ); |
55 | 55 | ||
56 | /** | 56 | /** |
57 | * Write the file. | 57 | * Write the file. |
58 | *@param pNode The root node | 58 | *@param pNode The root node |
59 | *@param sIndent The indent text. | 59 | *@param sIndent The indent text. |
60 | */ | 60 | */ |
61 | void write( XmlNode *pNode, const char *sIndent=NULL ); | 61 | void write( XmlNode *pNode, const Bu::FString &sIndent ); |
62 | 62 | ||
63 | /** | 63 | /** |
64 | * Write a node in the file, including children. | 64 | * Write a node in the file, including children. |
@@ -66,7 +66,7 @@ private: | |||
66 | *@param nIndent The indent level (the number of times to include sIndent) | 66 | *@param nIndent The indent level (the number of times to include sIndent) |
67 | *@param sIndent The indent text. | 67 | *@param sIndent The indent text. |
68 | */ | 68 | */ |
69 | void writeNode( XmlNode *pNode, int nIndent, const char *sIndent ); | 69 | void writeNode( XmlNode *pNode, int nIndent, const Bu::FString &sIndent ); |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * Write the properties of a node. | 72 | * Write the properties of a node. |
@@ -74,14 +74,14 @@ private: | |||
74 | *@param nIndent The indent level of the containing node | 74 | *@param nIndent The indent level of the containing node |
75 | *@param sIndent The indent text. | 75 | *@param sIndent The indent text. |
76 | */ | 76 | */ |
77 | void writeNodeProps( XmlNode *pNode, int nIndent, const char *sIndent ); | 77 | void writeNodeProps( XmlNode *pNode, int nIndent, const Bu::FString &sIndent ); |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * Called to write the actual indent. | 80 | * Called to write the actual indent. |
81 | *@param nIndent The indent level. | 81 | *@param nIndent The indent level. |
82 | *@param sIndent The indent text. | 82 | *@param sIndent The indent text. |
83 | */ | 83 | */ |
84 | void writeIndent( int nIndent, const char *sIndent ); | 84 | void writeIndent( int nIndent, const Bu::FString &sIndent ); |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * This is the function that must be overridden in order to use this class. | 87 | * This is the function that must be overridden in order to use this class. |
@@ -90,7 +90,7 @@ private: | |||
90 | * will break the XML formatting. | 90 | * will break the XML formatting. |
91 | *@param sString The string data to write to the output. | 91 | *@param sString The string data to write to the output. |
92 | */ | 92 | */ |
93 | virtual void writeString( const char *sString ) = 0; | 93 | virtual void writeString( const Bu::FString &sString ) = 0; |
94 | }; | 94 | }; |
95 | 95 | ||
96 | #endif | 96 | #endif |