diff options
author | Mike Buland <eichlan@xagasoft.com> | 2009-02-11 05:29:41 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2009-02-11 05:29:41 +0000 |
commit | f4b191f0ea396b58465bfba40749977780a3af58 (patch) | |
tree | 891490e91ab3b67524be67b2b71c85d84fd2f92a /src/inprogress | |
parent | 292ae9453e7fdb2f1023ed9dfc99cbcd751f8b90 (diff) | |
download | libbu++-f4b191f0ea396b58465bfba40749977780a3af58.tar.gz libbu++-f4b191f0ea396b58465bfba40749977780a3af58.tar.bz2 libbu++-f4b191f0ea396b58465bfba40749977780a3af58.tar.xz libbu++-f4b191f0ea396b58465bfba40749977780a3af58.zip |
Just removing some things that are cluttering up the source tree.
Diffstat (limited to '')
-rw-r--r-- | src/inprogress/xmldocument.cpp | 16 | ||||
-rw-r--r-- | src/inprogress/xmldocument.h | 29 | ||||
-rw-r--r-- | src/inprogress/xmlnode.cpp | 16 | ||||
-rw-r--r-- | src/inprogress/xmlnode.h | 29 | ||||
-rw-r--r-- | src/inprogress/xmlreader.cpp | 274 | ||||
-rw-r--r-- | src/inprogress/xmlreader.h | 128 | ||||
-rw-r--r-- | src/inprogress/xmlwriter.cpp | 16 | ||||
-rw-r--r-- | src/inprogress/xmlwriter.h | 29 |
8 files changed, 0 insertions, 537 deletions
diff --git a/src/inprogress/xmldocument.cpp b/src/inprogress/xmldocument.cpp deleted file mode 100644 index c3114d6..0000000 --- a/src/inprogress/xmldocument.cpp +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2008 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include "xmldocument.h" | ||
9 | |||
10 | Bu::XmlDocument::XmlDocument() | ||
11 | { | ||
12 | } | ||
13 | |||
14 | Bu::XmlDocument::~XmlDocument() | ||
15 | { | ||
16 | } | ||
diff --git a/src/inprogress/xmldocument.h b/src/inprogress/xmldocument.h deleted file mode 100644 index b4fdc9d..0000000 --- a/src/inprogress/xmldocument.h +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2008 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #ifndef XML_DOCUMENT_H | ||
9 | #define XML_DOCUMENT_H | ||
10 | |||
11 | #include <stdint.h> | ||
12 | |||
13 | namespace Bu | ||
14 | { | ||
15 | /** | ||
16 | * | ||
17 | */ | ||
18 | class XmlDocument | ||
19 | { | ||
20 | public: | ||
21 | XmlDocument(); | ||
22 | virtual ~XmlDocument(); | ||
23 | |||
24 | private: | ||
25 | |||
26 | }; | ||
27 | } | ||
28 | |||
29 | #endif | ||
diff --git a/src/inprogress/xmlnode.cpp b/src/inprogress/xmlnode.cpp deleted file mode 100644 index f31d4ae..0000000 --- a/src/inprogress/xmlnode.cpp +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2008 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include "xmlnode.h" | ||
9 | |||
10 | Bu::XmlNode::XmlNode() | ||
11 | { | ||
12 | } | ||
13 | |||
14 | Bu::XmlNode::~XmlNode() | ||
15 | { | ||
16 | } | ||
diff --git a/src/inprogress/xmlnode.h b/src/inprogress/xmlnode.h deleted file mode 100644 index ed52f32..0000000 --- a/src/inprogress/xmlnode.h +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2008 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #ifndef XML_NODE_H | ||
9 | #define XML_NODE_H | ||
10 | |||
11 | #include <stdint.h> | ||
12 | |||
13 | namespace Bu | ||
14 | { | ||
15 | /** | ||
16 | * | ||
17 | */ | ||
18 | class XmlNode | ||
19 | { | ||
20 | public: | ||
21 | XmlNode(); | ||
22 | virtual ~XmlNode(); | ||
23 | |||
24 | private: | ||
25 | |||
26 | }; | ||
27 | } | ||
28 | |||
29 | #endif | ||
diff --git a/src/inprogress/xmlreader.cpp b/src/inprogress/xmlreader.cpp deleted file mode 100644 index 5c755bb..0000000 --- a/src/inprogress/xmlreader.cpp +++ /dev/null | |||
@@ -1,274 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2008 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include "xmlreader.h" | ||
9 | |||
10 | Bu::XmlReader::XmlReader( Bu::Stream &sIn ) : | ||
11 | sIn( sIn ) | ||
12 | { | ||
13 | } | ||
14 | |||
15 | Bu::XmlReader::~XmlReader() | ||
16 | { | ||
17 | } | ||
18 | |||
19 | const char *Bu::XmlReader::lookahead( int nAmnt ) | ||
20 | { | ||
21 | if( sBuf.getSize() >= nAmnt ) | ||
22 | return sBuf.getStr(); | ||
23 | |||
24 | int nNew = nAmnt - sBuf.getSize(); | ||
25 | char *buf = new char[nNew]; | ||
26 | sIn.read( buf, nNew ); | ||
27 | sBuf.append( buf ); | ||
28 | |||
29 | return sBuf.getStr(); | ||
30 | } | ||
31 | |||
32 | void Bu::XmlReader::burn( int nAmnt ) | ||
33 | { | ||
34 | if( sBuf.getSize() < nAmnt ) | ||
35 | { | ||
36 | lookahead( nAmnt ); | ||
37 | } | ||
38 | |||
39 | //sBuf.remove( nAmnt ); | ||
40 | } | ||
41 | |||
42 | void Bu::XmlReader::checkString( const char *str, int nLen ) | ||
43 | { | ||
44 | if( !strncmp( str, lookahead( nLen ), nLen ) ) | ||
45 | { | ||
46 | burn( nLen ); | ||
47 | return; | ||
48 | } | ||
49 | |||
50 | throw Bu::ExceptionBase("Expected string '%s'", str ); | ||
51 | } | ||
52 | |||
53 | Bu::XmlNode *Bu::XmlReader::read() | ||
54 | { | ||
55 | prolog(); | ||
56 | } | ||
57 | |||
58 | void Bu::XmlReader::prolog() | ||
59 | { | ||
60 | XMLDecl(); | ||
61 | Misc(); | ||
62 | } | ||
63 | |||
64 | void Bu::XmlReader::XMLDecl() | ||
65 | { | ||
66 | checkString("<?xml", 5 ); | ||
67 | S(); | ||
68 | VersionInfo(); | ||
69 | EncodingDecl(); | ||
70 | SDDecl(); | ||
71 | Sq(); | ||
72 | checkString("?>", 2 ); | ||
73 | } | ||
74 | |||
75 | void Bu::XmlReader::Misc() | ||
76 | { | ||
77 | for(;;) | ||
78 | { | ||
79 | S(); | ||
80 | if( !strncmp("<!--", lookahead( 4 ), 4 ) ) | ||
81 | { | ||
82 | Comment(); | ||
83 | } | ||
84 | else if( !strncmp("<?", lookahead( 2 ), 2 ) ) | ||
85 | { | ||
86 | PI(); | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | return; | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | |||
95 | void Bu::XmlReader::Comment() | ||
96 | { | ||
97 | checkString("<!--", 4 ); | ||
98 | for(;;) | ||
99 | { | ||
100 | unsigned char c = *lookahead(1); | ||
101 | if( c == '-' ) | ||
102 | { | ||
103 | if( lookahead(2)[1] == '-' ) | ||
104 | { | ||
105 | checkString("-->", 3 ); | ||
106 | return; | ||
107 | } | ||
108 | } | ||
109 | burn( 1 ); | ||
110 | } | ||
111 | } | ||
112 | |||
113 | void Bu::XmlReader::PI() | ||
114 | { | ||
115 | checkString("<?", 2 ); | ||
116 | FString sName = Name(); | ||
117 | printf("PI: %s\n---\n", sName.getStr() ); | ||
118 | S(); | ||
119 | for(int j = 0;; j++ ) | ||
120 | { | ||
121 | if( !strncmp( "?>", lookahead(j+2)+j, 2 ) ) | ||
122 | { | ||
123 | burn( j+2 ); | ||
124 | return; | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | |||
129 | void Bu::XmlReader::S() | ||
130 | { | ||
131 | for( int j = 0;; j++ ) | ||
132 | { | ||
133 | char c = *lookahead( 1 ); | ||
134 | if( c == 0x20 || c == 0x9 || c == 0xD || c == 0xA ) | ||
135 | continue; | ||
136 | if( j == 0 ) | ||
137 | throw ExceptionBase("Expected whitespace."); | ||
138 | return; | ||
139 | } | ||
140 | } | ||
141 | |||
142 | void Bu::XmlReader::Sq() | ||
143 | { | ||
144 | for(;;) | ||
145 | { | ||
146 | char c = *lookahead( 1 ); | ||
147 | if( c == 0x20 || c == 0x9 || c == 0xD || c == 0xA ) | ||
148 | continue; | ||
149 | return; | ||
150 | } | ||
151 | } | ||
152 | |||
153 | void Bu::XmlReader::VersionInfo() | ||
154 | { | ||
155 | try | ||
156 | { | ||
157 | S(); | ||
158 | checkString("version", 7 ); | ||
159 | } | ||
160 | catch( ExceptionBase &e ) | ||
161 | { | ||
162 | return; | ||
163 | } | ||
164 | Eq(); | ||
165 | Bu::FString ver = AttValue(); | ||
166 | if( ver != "1.1" ) | ||
167 | throw ExceptionBase("Currently we only support xml version 1.1\n"); | ||
168 | } | ||
169 | |||
170 | void Bu::XmlReader::Eq() | ||
171 | { | ||
172 | Sq(); | ||
173 | checkString("=", 1 ); | ||
174 | Sq(); | ||
175 | } | ||
176 | |||
177 | void Bu::XmlReader::EncodingDecl() | ||
178 | { | ||
179 | S(); | ||
180 | try | ||
181 | { | ||
182 | checkString("encoding", 8 ); | ||
183 | } | ||
184 | catch( ExceptionBase &e ) | ||
185 | { | ||
186 | return; | ||
187 | } | ||
188 | |||
189 | Eq(); | ||
190 | AttValue(); | ||
191 | } | ||
192 | |||
193 | void Bu::XmlReader::SDDecl() | ||
194 | { | ||
195 | S(); | ||
196 | try | ||
197 | { | ||
198 | checkString("standalone", 10 ); | ||
199 | } | ||
200 | catch( ExceptionBase &e ) | ||
201 | { | ||
202 | return; | ||
203 | } | ||
204 | |||
205 | Eq(); | ||
206 | AttValue(); | ||
207 | } | ||
208 | |||
209 | Bu::FString Bu::XmlReader::AttValue() | ||
210 | { | ||
211 | char q = *lookahead(1); | ||
212 | if( q == '\"' ) | ||
213 | { | ||
214 | for( int j = 2;; j++ ) | ||
215 | { | ||
216 | if( lookahead(j)[j-1] == '\"' ) | ||
217 | { | ||
218 | Bu::FString ret( lookahead(j)+1, j-2 ); | ||
219 | burn( j ); | ||
220 | return ret; | ||
221 | } | ||
222 | } | ||
223 | } | ||
224 | else if( q == '\'' ) | ||
225 | { | ||
226 | for( int j = 2;; j++ ) | ||
227 | { | ||
228 | if( lookahead(j)[j-1] == '\'' ) | ||
229 | { | ||
230 | Bu::FString ret( lookahead(j)+1, j-2 ); | ||
231 | burn( j ); | ||
232 | return ret; | ||
233 | } | ||
234 | } | ||
235 | } | ||
236 | |||
237 | throw ExceptionBase("Excpected either \' or \".\n"); | ||
238 | } | ||
239 | |||
240 | Bu::FString Bu::XmlReader::Name() | ||
241 | { | ||
242 | unsigned char c = *lookahead( 1 ); | ||
243 | if( c != ':' && c != '_' && | ||
244 | (c < 'A' || c > 'Z') && | ||
245 | (c < 'a' || c > 'z') && | ||
246 | (c < 0xC0 || c > 0xD6 ) && | ||
247 | (c < 0xD8 || c > 0xF6 ) && | ||
248 | (c < 0xF8)) | ||
249 | { | ||
250 | throw ExceptionBase("Invalid entity name starting character."); | ||
251 | } | ||
252 | |||
253 | for( int j = 1;; j++ ) | ||
254 | { | ||
255 | unsigned char c = lookahead(j+1)[j]; | ||
256 | if( isS( c ) ) | ||
257 | { | ||
258 | FString ret( lookahead(j+1), j+1 ); | ||
259 | burn( j+1 ); | ||
260 | return ret; | ||
261 | } | ||
262 | if( c != ':' && c != '_' && c != '-' && c != '.' && c != 0xB7 && | ||
263 | (c < 'A' || c > 'Z') && | ||
264 | (c < 'a' || c > 'z') && | ||
265 | (c < '0' || c > '9') && | ||
266 | (c < 0xC0 || c > 0xD6 ) && | ||
267 | (c < 0xD8 || c > 0xF6 ) && | ||
268 | (c < 0xF8)) | ||
269 | { | ||
270 | throw ExceptionBase("Invalid character in name."); | ||
271 | } | ||
272 | } | ||
273 | } | ||
274 | |||
diff --git a/src/inprogress/xmlreader.h b/src/inprogress/xmlreader.h deleted file mode 100644 index 0219b0e..0000000 --- a/src/inprogress/xmlreader.h +++ /dev/null | |||
@@ -1,128 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2008 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #ifndef XML_READER_H | ||
9 | #define XML_READER_H | ||
10 | |||
11 | #include <stdint.h> | ||
12 | #include "bu/stream.h" | ||
13 | #include "bu/fstring.h" | ||
14 | #include "bu/xmlnode.h" | ||
15 | |||
16 | namespace Bu | ||
17 | { | ||
18 | /** | ||
19 | * An Xml 1.1 reader. I've decided to write this, this time, based on the | ||
20 | * official W3C reccomendation, now included with the source code. I've | ||
21 | * named the productions in the parser states the same as in that document, | ||
22 | * which may make them easier to find, etc, although possibly slightly less | ||
23 | * optimized than writing my own reduced grammer. | ||
24 | * | ||
25 | * Below I will list differences between my parser and the official standard | ||
26 | * as I come up with them. | ||
27 | * - Encoding and Standalone headings are ignored for the moment. (4.3.3, | ||
28 | * 2.9) | ||
29 | * - The standalone heading attribute can have any standard whitespace | ||
30 | * before it (the specs say only spaces, no newlines). (2.9) | ||
31 | * - Since standalone is ignored, it is currently allowed to have any | ||
32 | * value (should be restricted to "yes" or "no"). (2.9) | ||
33 | * - Currently only UTF-8 / ascii are parsed. | ||
34 | * - [optional] The content of comments is thrown away. (2.5) | ||
35 | * - The content of processing instruction blocks is parsed properly, but | ||
36 | * thrown away. (2.6) | ||
37 | */ | ||
38 | class XmlReader | ||
39 | { | ||
40 | public: | ||
41 | XmlReader( Bu::Stream &sIn ); | ||
42 | virtual ~XmlReader(); | ||
43 | |||
44 | XmlNode *read(); | ||
45 | |||
46 | private: | ||
47 | Bu::Stream &sIn; | ||
48 | Bu::FString sBuf; | ||
49 | |||
50 | private: // Helpers | ||
51 | const char *lookahead( int nAmnt ); | ||
52 | void burn( int nAmnt ); | ||
53 | void checkString( const char *str, int nLen ); | ||
54 | |||
55 | private: // States | ||
56 | /** | ||
57 | * The headers, etc. | ||
58 | */ | ||
59 | void prolog(); | ||
60 | |||
61 | /** | ||
62 | * The xml decleration (version, encoding, etc). | ||
63 | */ | ||
64 | void XMLDecl(); | ||
65 | |||
66 | /** | ||
67 | * Misc things, Includes Comments and PIData (Processing Instructions). | ||
68 | */ | ||
69 | void Misc(); | ||
70 | |||
71 | /** | ||
72 | * Comments | ||
73 | */ | ||
74 | void Comment(); | ||
75 | |||
76 | /** | ||
77 | * Processing Instructions | ||
78 | */ | ||
79 | void PI(); | ||
80 | |||
81 | /** | ||
82 | * Whitespace eater. | ||
83 | */ | ||
84 | void S(); | ||
85 | |||
86 | /** | ||
87 | * Optional whitespace eater. | ||
88 | */ | ||
89 | void Sq(); | ||
90 | |||
91 | /** | ||
92 | * XML Version spec | ||
93 | */ | ||
94 | void VersionInfo(); | ||
95 | |||
96 | /** | ||
97 | * Your basic equals sign with surrounding whitespace. | ||
98 | */ | ||
99 | void Eq(); | ||
100 | |||
101 | /** | ||
102 | * Read in an attribute value. | ||
103 | */ | ||
104 | FString AttValue(); | ||
105 | |||
106 | /** | ||
107 | * Read in the name of something. | ||
108 | */ | ||
109 | FString Name(); | ||
110 | |||
111 | /** | ||
112 | * Encoding decleration in the header | ||
113 | */ | ||
114 | void EncodingDecl(); | ||
115 | |||
116 | /** | ||
117 | * Standalone decleration in the header | ||
118 | */ | ||
119 | void SDDecl(); | ||
120 | |||
121 | bool isS( unsigned char c ) | ||
122 | { | ||
123 | return ( c == 0x20 || c == 0x9 || c == 0xD || c == 0xA ); | ||
124 | } | ||
125 | }; | ||
126 | } | ||
127 | |||
128 | #endif | ||
diff --git a/src/inprogress/xmlwriter.cpp b/src/inprogress/xmlwriter.cpp deleted file mode 100644 index 1489b28..0000000 --- a/src/inprogress/xmlwriter.cpp +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2008 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include "xmlwriter.h" | ||
9 | |||
10 | Bu::XmlWriter::XmlWriter() | ||
11 | { | ||
12 | } | ||
13 | |||
14 | Bu::XmlWriter::~XmlWriter() | ||
15 | { | ||
16 | } | ||
diff --git a/src/inprogress/xmlwriter.h b/src/inprogress/xmlwriter.h deleted file mode 100644 index 45bc22e..0000000 --- a/src/inprogress/xmlwriter.h +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2008 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #ifndef XML_WRITER_H | ||
9 | #define XML_WRITER_H | ||
10 | |||
11 | #include <stdint.h> | ||
12 | |||
13 | namespace Bu | ||
14 | { | ||
15 | /** | ||
16 | * | ||
17 | */ | ||
18 | class XmlWriter | ||
19 | { | ||
20 | public: | ||
21 | XmlWriter(); | ||
22 | virtual ~XmlWriter(); | ||
23 | |||
24 | private: | ||
25 | |||
26 | }; | ||
27 | } | ||
28 | |||
29 | #endif | ||