Class to build the configuration table from parser events. More...
#include <TsBuilder.h>
Data Structures | |
struct | Handler |
Public Types | |
typedef Builder | self |
Public Member Functions | |
Builder () | |
Default constructor. | |
virtual | ~Builder () |
Destructor. | |
Builder (Configuration const &config) | |
Construct with existing configuration. | |
Rv< Configuration > | build (Buffer const &buffer) |
Build the table. | |
Protected Member Functions | |
virtual void | groupOpen (Token const &token) |
Dispatch methods. | |
virtual void | groupClose (Token const &token) |
virtual void | groupName (Token const &token) |
virtual void | listOpen (Token const &token) |
virtual void | listClose (Token const &token) |
virtual void | pathOpen (Token const &token) |
virtual void | pathTag (Token const &token) |
virtual void | pathIndex (Token const &token) |
virtual void | pathClose (Token const &token) |
virtual void | literalValue (Token const &token) |
virtual void | invalidToken (Token const &token) |
virtual int | syntaxError (char const *text) |
Syntax error handler. | |
self & | init () |
Initialization, called from constructors. | |
Static Protected Member Functions | |
static void | dispatch (void *data, Token *token) |
Static method to handle parser event callbacks. | |
static int | syntaxErrorDispatch (void *data, char const *text) |
Static method for syntax errors. | |
Protected Attributes | |
Handler | _dispatch [TS_CONFIG_N_EVENT_TYPES] |
Dispatch table for parse events. | |
TsConfigHandlers | _handlers |
Event handler table for the parser. | |
Configuration | _config |
Configuration to update. | |
Errata | _errata |
Error accumulator. | |
Value | _v |
Current value. | |
Buffer | _name |
Pending group name, if any. | |
Buffer | _extent |
Accumulator for multi-token text. | |
Location | _loc |
Cache for multi-token text. | |
Path | _path |
Path accumulator. |
Class to build the configuration table from parser events.
Definition at line 35 of file TsBuilder.h.
typedef Builder ts::config::Builder::self |
Definition at line 37 of file TsBuilder.h.
ts::config::Builder::Builder | ( | ) | [inline] |
virtual ts::config::Builder::~Builder | ( | ) | [inline, virtual] |
Destructor.
Definition at line 50 of file TsBuilder.h.
ts::config::Builder::Builder | ( | Configuration const & | config | ) | [inline] |
Construct with existing configuration.
Definition at line 97 of file TsBuilder.h.
References init().
Rv< Configuration > ts::config::Builder::build | ( | Buffer const & | buffer | ) |
Build the table.
buffer | Input text. |
Definition at line 125 of file TsBuilder.cc.
References _config, _errata, _handlers, ts::Buffer::_ptr, ts::Buffer::_size, _v, ts::Errata::clear(), ts::config::Configuration::getRoot(), ts::MakeRv(), and tsconfig_parse_buffer().
void ts::config::Builder::dispatch | ( | void * | data, | |
Token * | token | |||
) | [static, protected] |
Static method to handle parser event callbacks.
Definition at line 93 of file TsBuilder.cc.
References ts::config::Builder::Handler::_method, ts::config::Builder::Handler::_ptr, ts::msg::logf(), PRE, and ts::msg::WARN.
void ts::config::Builder::groupClose | ( | Token const & | token | ) | [protected, virtual] |
Definition at line 137 of file TsBuilder.cc.
References _v, and ts::config::Value::getParent().
void ts::config::Builder::groupName | ( | Token const & | token | ) | [protected, virtual] |
Definition at line 140 of file TsBuilder.cc.
References Token::_n, _name, Token::_s, and ts::Buffer::set().
void ts::config::Builder::groupOpen | ( | Token const & | token | ) | [protected, virtual] |
Dispatch methods.
Definition at line 133 of file TsBuilder.cc.
References Location::_col, Location::_line, Token::_loc, _name, _v, ts::config::Value::makeGroup(), and ts::config::Value::setSource().
Builder & ts::config::Builder::init | ( | void | ) | [protected] |
Initialization, called from constructors.
Definition at line 57 of file TsBuilder.cc.
References TsConfigErrorHandler::_data, TsConfigEventHandler::_data, _dispatch, TsConfigErrorHandler::_f, TsConfigEventHandler::_f, _handlers, ts::config::Builder::Handler::_method, ts::config::Builder::Handler::_ptr, TsConfigHandlers::error, and TsConfigHandlers::handler.
Referenced by Builder().
void ts::config::Builder::invalidToken | ( | Token const & | token | ) | [protected, virtual] |
Definition at line 212 of file TsBuilder.cc.
void ts::config::Builder::listClose | ( | Token const & | token | ) | [protected, virtual] |
Definition at line 147 of file TsBuilder.cc.
References _v, and ts::config::Value::getParent().
void ts::config::Builder::listOpen | ( | Token const & | token | ) | [protected, virtual] |
Definition at line 143 of file TsBuilder.cc.
References Location::_col, Location::_line, Token::_loc, _name, _v, ts::config::Value::makeList(), and ts::config::Value::setSource().
void ts::config::Builder::literalValue | ( | Token const & | token | ) | [protected, virtual] |
Definition at line 185 of file TsBuilder.cc.
References Location::_col, _errata, Location::_line, Token::_loc, Token::_n, _name, ts::Buffer::_ptr, Token::_s, ts::Buffer::_size, Token::_type, _v, ts::Rv< R >::errata(), ts::RvBase::isOK(), ts::msg::logf(), ts::config::Value::makeInteger(), ts::config::Value::makeString(), PRE, ts::Errata::pull(), ts::Rv< R >::result(), ts::Buffer::set(), and ts::msg::WARN.
void ts::config::Builder::pathClose | ( | Token const & | token | ) | [protected, virtual] |
Definition at line 173 of file TsBuilder.cc.
References Location::_col, _extent, Location::_line, _loc, _name, _path, ts::Buffer::_ptr, ts::Buffer::_size, _v, ts::RvBase::isOK(), ts::config::Value::makePath(), ts::Buffer::reset(), and ts::Rv< R >::result().
void ts::config::Builder::pathIndex | ( | Token const & | token | ) | [protected, virtual] |
Definition at line 164 of file TsBuilder.cc.
References _extent, Token::_n, _path, ts::Buffer::_ptr, Token::_s, ts::Buffer::_size, ts::config::Path::append(), and ts::Buffer::set().
void ts::config::Builder::pathOpen | ( | Token const & | token | ) | [protected, virtual] |
Definition at line 151 of file TsBuilder.cc.
References _extent, _path, ts::Buffer::reset(), and ts::config::Path::reset().
void ts::config::Builder::pathTag | ( | Token const & | token | ) | [protected, virtual] |
Definition at line 155 of file TsBuilder.cc.
References _extent, Token::_loc, _loc, Token::_n, _path, ts::Buffer::_ptr, Token::_s, ts::Buffer::_size, ts::config::Path::append(), and ts::Buffer::set().
int ts::config::Builder::syntaxError | ( | char const * | text | ) | [protected, virtual] |
Syntax error handler.
Definition at line 116 of file TsBuilder.cc.
References _errata, ts::msg::logf(), tsconfiglex_current_col(), tsconfiglex_current_line(), and ts::msg::WARN.
Referenced by syntaxErrorDispatch().
int ts::config::Builder::syntaxErrorDispatch | ( | void * | data, | |
char const * | text | |||
) | [static, protected] |
Static method for syntax errors.
Definition at line 111 of file TsBuilder.cc.
References syntaxError().
Configuration ts::config::Builder::_config [protected] |
Handler ts::config::Builder::_dispatch[TS_CONFIG_N_EVENT_TYPES] [protected] |
Errata ts::config::Builder::_errata [protected] |
Error accumulator.
Definition at line 84 of file TsBuilder.h.
Referenced by build(), literalValue(), and syntaxError().
Buffer ts::config::Builder::_extent [protected] |
Accumulator for multi-token text.
Definition at line 87 of file TsBuilder.h.
Referenced by pathClose(), pathIndex(), pathOpen(), and pathTag().
TsConfigHandlers ts::config::Builder::_handlers [protected] |
Event handler table for the parser.
Definition at line 62 of file TsBuilder.h.
Location ts::config::Builder::_loc [protected] |
Cache for multi-token text.
Definition at line 88 of file TsBuilder.h.
Referenced by pathClose(), and pathTag().
Buffer ts::config::Builder::_name [protected] |
Pending group name, if any.
Definition at line 86 of file TsBuilder.h.
Referenced by groupName(), groupOpen(), listOpen(), literalValue(), and pathClose().
Path ts::config::Builder::_path [protected] |
Path accumulator.
Definition at line 89 of file TsBuilder.h.
Referenced by pathClose(), pathIndex(), pathOpen(), and pathTag().
Value ts::config::Builder::_v [protected] |
Current value.
Definition at line 85 of file TsBuilder.h.
Referenced by build(), groupClose(), groupOpen(), listClose(), listOpen(), literalValue(), and pathClose().