#include <SimpleSAXParser.h>
Classes | |
struct | Attribute |
class | ParserError |
Public Types | |
typedef std::vector< Attribute > | Attributes |
enum | PARSER_STATES { IN_DOCUMENT, IN_BEGIN_TAG, IN_DONE, IN_BEGIN_ELEMENT, IN_ELEMENT_WHITESPACE, IN_END_ELEMENT, IN_ATTRIBUTE_KEY, IN_END_TAG, IN_DATA, IN_BEGIN_ATTRIBUTE_VALUE, IN_STRING, IN_END_ATTRIBUTE_VALUE, IN_STRING_ENTITY, IN_DATA_ENTITY } |
Public Member Functions | |
virtual void | data (const std::string &) |
virtual void | endElement (const std::string &) |
void | parse (void) |
SimpleSAXParser (std::istream &f) | |
virtual void | startElement (const std::string &, Attributes &) |
virtual | ~SimpleSAXParser () |
Private Member Functions | |
std::string | getToken (const char *delim) |
std::string | getToken (const char delim) |
int | nextChar (void) |
const SimpleSAXParser & | operator= (const SimpleSAXParser &) |
std::string | parseEntity (const std::string &entity) |
SimpleSAXParser (const SimpleSAXParser &) | |
bool | skipChar (int c) |
Private Attributes | |
Attributes | m_attributes |
char * | m_buffer |
size_t | m_bufferSize |
std::vector< std::string > | m_elementTags |
std::istream & | m_in |
int | m_nextChar |
A simple SAX parser which is able to parse the configuration.
State machine for the parser can be drawn by cut and pasting the following to graphviz:
digraph { IN_DOCUMENT->IN_BEGIN_TAG [label="nextChar == '<'"]; IN_DOCUMENT->IN_DATA [label="nextChar != '<'"];
IN_BEGIN_TAG->IN_BEGIN_ELEMENT [label="nextChar >= 'a' && nextChar < 'Z'"]; IN_BEGIN_TAG->IN_END_ELEMENT [label= "nextChar == '/'"];
IN_BEGIN_ELEMENT->IN_END_ELEMENT [label="nextChar == '/'"]; IN_BEGIN_ELEMENT->IN_ELEMENT_WHITESPACE [label="nextChar == ' '"]; IN_BEGIN_ELEMENT->IN_END_TAG [label="nextChar == '>'"];
IN_ELEMENT_WHITESPACE->IN_ELEMENT_WHITESPACE [ label = "nextChar == \"\ \t\n""] IN_ELEMENT_WHITESPACE->IN_ATTRIBUTE_KEY [ label = "nextChar >= 'a' && nextChar < 'Z'"] IN_ELEMENT_WHITESPACE->IN_END_ELEMENT [label="nextChar == '/'"]
IN_END_ELEMENT->IN_END_TAG [label = "nextChar == '>'"];
IN_END_TAG->IN_BEGIN_TAG [label="nextChar == '<'"]; IN_END_TAG->IN_DATA [label="nextChar != '<'"]
IN_DATA->IN_BEGIN_TAG [label="nextChar == '<'"]; IN_DATA->IN_DATA_ENTITY [label="nextChar == '&'"]; IN_DATA->IN_DONE [label = "nextChar == EOF"];
IN_DATA_ENTITY->IN_DATA [label="nextChar == ';'"];
IN_ATTRIBUTE_KEY->IN_BEGIN_ATTRIBUTE_VALUE [label = "nextChar == '='"]
IN_BEGIN_ATTRIBUTE_VALUE->IN_STRING [label = "nextChar == '\"' || nextChar == '\'' "]
IN_STRING->IN_END_ATTRIBUTE_VALUE [label = "nextChar == quote"] IN_STRING->IN_STRING_ENTITY [label = "nextChar == '&'"]
IN_END_ATTRIBUTE_VALUE->IN_ELEMENT_WHITESPACE [label = "nextChar == ' '"] IN_END_ATTRIBUTE_VALUE->IN_END_ELEMENT [label = "nextChar == '/'"] IN_END_ATTRIBUTE_VALUE->IN_END_TAG [label = "nextChar == '>'"]
IN_STRING_ENTITY->IN_STRING [label = "nextChar == ';'"] }
Definition at line 71 of file SimpleSAXParser.h.
typedef std::vector<Attribute> SimpleSAXParser::Attributes |
Definition at line 93 of file SimpleSAXParser.h.
Definition at line 106 of file SimpleSAXParser.h.
|
inline |
Definition at line 123 of file SimpleSAXParser.h.
|
virtual |
|
private |
|
inlinevirtual |
Reimplemented in FWXMLConfigParser.
Definition at line 137 of file SimpleSAXParser.h.
Referenced by cuy.FindIssue::__init__(), and parse().
|
inlinevirtual |
Reimplemented in FWXMLConfigParser.
Definition at line 136 of file SimpleSAXParser.h.
Referenced by parse().
|
inlineprivate |
Definition at line 144 of file SimpleSAXParser.h.
References fgettoken(), m_buffer, m_bufferSize, m_in, and m_nextChar.
Referenced by parse().
|
inlineprivate |
Definition at line 150 of file SimpleSAXParser.h.
References fgettoken(), m_buffer, m_bufferSize, m_in, and m_nextChar.
|
inlineprivate |
|
private |
void SimpleSAXParser::parse | ( | void | ) |
Runs the state machine of the parser, invoking startElement(), setAttribute(), endElement(), data() virtual methods as approppriate. In order have the parser doing something usefull you need to derive from it and specialize the above mentioned virtual methods.
Default implementation is in any case useful to check syntax.
Definition at line 53 of file SimpleSAXParser.cc.
References asciidump::attr, data(), debug_state_machine(), endElement(), getToken(), i, IN_ATTRIBUTE_KEY, IN_BEGIN_ATTRIBUTE_VALUE, IN_BEGIN_ELEMENT, IN_BEGIN_TAG, IN_DATA, IN_DATA_ENTITY, IN_DOCUMENT, IN_DONE, IN_ELEMENT_WHITESPACE, IN_END_ATTRIBUTE_VALUE, IN_END_ELEMENT, IN_END_TAG, IN_STRING, IN_STRING_ENTITY, SimpleSAXParser::Attribute::key, m_attributes, m_elementTags, nextChar(), parseEntity(), skipChar(), startElement(), AlCaHLTBitMon_QueryRunRegistry::string, and tmp.
Referenced by FWPartialConfigGUI::FWPartialConfigGUI(), FWConfigurationManager::readFromFile(), and FWPartialConfigSaveGUI::WriteConfig().
|
private |
Helper function to handle entities, i.e. characters specified with the "&label;" syntax.
Definition at line 7 of file SimpleSAXParser.cc.
Referenced by parse().
|
inlineprivate |
Definition at line 158 of file SimpleSAXParser.h.
References m_in, and m_nextChar.
Referenced by parse().
|
inlinevirtual |
Reimplemented in FWXMLConfigParser.
Definition at line 134 of file SimpleSAXParser.h.
Referenced by parse().
|
private |
Definition at line 173 of file SimpleSAXParser.h.
Referenced by parse().
|
private |
Definition at line 170 of file SimpleSAXParser.h.
Referenced by getToken(), and ~SimpleSAXParser().
|
private |
Definition at line 169 of file SimpleSAXParser.h.
Referenced by getToken().
|
private |
Definition at line 172 of file SimpleSAXParser.h.
Referenced by parse().
|
private |
Definition at line 168 of file SimpleSAXParser.h.
Referenced by getToken(), and skipChar().
|
private |
Definition at line 171 of file SimpleSAXParser.h.
Referenced by getToken(), nextChar(), and skipChar().