#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 &) |
const SimpleSAXParser & | operator= (const SimpleSAXParser &)=delete |
void | parse (void) |
SimpleSAXParser (std::istream &f) | |
SimpleSAXParser (const SimpleSAXParser &)=delete | |
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) |
std::string | parseEntity (const std::string &entity) |
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 69 of file SimpleSAXParser.h.
typedef std::vector<Attribute> SimpleSAXParser::Attributes |
Definition at line 82 of file SimpleSAXParser.h.
Definition at line 93 of file SimpleSAXParser.h.
|
inline |
Definition at line 110 of file SimpleSAXParser.h.
|
virtual |
|
delete |
|
inlinevirtual |
Reimplemented in FWXMLConfigParser.
Definition at line 119 of file SimpleSAXParser.h.
Referenced by parse().
|
inlinevirtual |
Reimplemented in FWXMLConfigParser.
Definition at line 118 of file SimpleSAXParser.h.
Referenced by parse().
|
inlineprivate |
Definition at line 126 of file SimpleSAXParser.h.
References fgettoken(), m_buffer, m_bufferSize, m_in, and m_nextChar.
Referenced by parse().
|
inlineprivate |
Definition at line 131 of file SimpleSAXParser.h.
References visDQMUpload::buf, fgettoken(), m_buffer, m_bufferSize, m_in, and m_nextChar.
|
inlineprivate |
|
delete |
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 46 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, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, m_attributes, m_elementTags, nextChar(), parseEntity(), skipChar(), startElement(), AlCaHLTBitMon_QueryRunRegistry::string, and createJobs::tmp.
Referenced by FWConfigurationManager::readFromFile().
|
private |
Helper function to handle entities, i.e. characters specified with the "&label;" syntax.
Definition at line 6 of file SimpleSAXParser.cc.
Referenced by parse().
|
inlineprivate |
Definition at line 138 of file SimpleSAXParser.h.
References c, m_in, and m_nextChar.
Referenced by parse().
|
inlinevirtual |
Reimplemented in FWXMLConfigParser.
Definition at line 117 of file SimpleSAXParser.h.
Referenced by parse().
|
private |
Definition at line 152 of file SimpleSAXParser.h.
Referenced by parse().
|
private |
Definition at line 149 of file SimpleSAXParser.h.
Referenced by getToken(), and ~SimpleSAXParser().
|
private |
Definition at line 148 of file SimpleSAXParser.h.
Referenced by getToken().
|
private |
Definition at line 151 of file SimpleSAXParser.h.
Referenced by parse().
|
private |
Definition at line 147 of file SimpleSAXParser.h.
Referenced by getToken(), and skipChar().
|
private |
Definition at line 150 of file SimpleSAXParser.h.
Referenced by getToken(), nextChar(), and skipChar().