diff options
Diffstat (limited to '')
| -rw-r--r-- | src/inprogress/xmlreader.h | 128 |
1 files changed, 0 insertions, 128 deletions
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 | ||
