#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 &)=delete |
std::string | parseEntity (const std::string &entity) |
SimpleSAXParser (const SimpleSAXParser &)=delete | |
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.
References parse(), and ~SimpleSAXParser().
Referenced by data().
|
virtual |
Definition at line 223 of file SimpleSAXParser.cc.
References m_buffer.
Referenced by SimpleSAXParser().
|
privatedelete |
|
inlinevirtual |
Reimplemented in FWXMLConfigParser.
Definition at line 137 of file SimpleSAXParser.h.
References operator=(), parseEntity(), SimpleSAXParser(), and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by 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 tablePrinter::delim, fgettoken(), m_buffer, m_bufferSize, m_in, and m_nextChar.
|
inlineprivate |
|
privatedelete |
Referenced by data().
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 data(), debug_state_machine(), endElement(), getToken(), mps_fire::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(), SimpleSAXParser(), 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.
|
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().