Parser Class Reference
[System]
Reads an XML file, breaking it up into tags.
More...
#include <Parser.hpp>
List of all members.
Public Member Functions |
int | getLineNumber () const |
vector< Tag > | getTags () const |
void | open (string filename) |
void | print () |
Static Public Member Functions |
static Tag | create (string text) |
Protected Member Functions |
void | advance () |
void | advance (int times) |
string | findTag () |
bool | match (const string &text) |
void | parse () |
string | peek (int length) |
void | skip (const string &text) |
void | skipWhitespace () |
Static Protected Member Functions |
static string | findAttribute (stringstream &stream) |
static void | findKeyValue (const string &text, Tag &tag) |
static string | findKeyIn (const string &text) |
static string | findValueIn (const string &text) |
Private Attributes |
char | character |
ifstream | file |
int | lineNumber |
ostringstream | buffer |
string | filename |
vector< Tag > | tags |
Detailed Description
Reads an XML file, breaking it up into tags.
Supports
- Spaces between attribute name, equals, and value
- Spaces in attribute value
Unsupported (or undetermined)
- Spaces between closing slash and > of leaf tag
- Empty attribute values
- Multiple lines in a tag
Member Function Documentation
void advance |
( |
int |
times |
) |
[protected] |
Moves the input, checking for new lines as it goes.
void advance |
( |
|
) |
[protected] |
Moves the input, checking for new lines as it goes.
Tag create |
( |
string |
text |
) |
[static] |
- Returns:
- Tag created from raw text without '<' and '>'.
string findAttribute |
( |
stringstream & |
stream |
) |
[static, protected] |
Finds the next attribute in stream by counting quotes.
string findKeyIn |
( |
const string & |
text |
) |
[static, protected] |
Returns the key in an attribute key/value pair.
- Exceptions:
-
| Exception | if attribute does not have an equals sign. |
void findKeyValue |
( |
const string & |
attribute, |
|
|
Tag & |
tag | |
|
) |
| | [static, protected] |
Parses an attribute into a key and value, and then stores it.
- Parameters:
-
| attribute | Attribute as a raw string from the file. |
| tag | Tag object to store the attribute in. |
string findTag |
( |
|
) |
[protected] |
- Returns:
- Next tag in the file as text without '<' and '>'.
string findValueIn |
( |
const string & |
text |
) |
[static, protected] |
Returns the value in an attribute key/value pair.
- Exceptions:
-
| Exception | if there is no text between the quotes. |
bool match |
( |
const string & |
text |
) |
[protected] |
Checks if the current character and the next few matches some text.
- Parameters:
-
| text | String to match against. |
- Returns:
- True if everything matches.
void open |
( |
string |
filename |
) |
|
Opens a file and starts parsing it.
- Parameters:
-
| filename | Path of the file to open. |
- Exceptions:
-
| const_char* | if file cannot be opened. |
void parse |
( |
|
) |
[protected] |
Reads XML tags from an input file.
string peek |
( |
int |
length |
) |
[protected] |
Looks at length characters of input without consuming them.
Prints all the tags in the parser.
void skip |
( |
const string & |
text |
) |
[protected] |
Skips input until it matches text.
void skipWhitespace |
( |
|
) |
[protected] |
Skips spaces, newlines, etc. in the input.
The documentation for this class was generated from the following files: