7#include <kernel/util/xml_scanner.hpp> 
   14    DummyParser::DummyParser()
 
   34      return std::make_shared<DummyParser>();
 
   46    DumpParser::DumpParser(
const String& name, 
bool lines, std::size_t indent) :
 
   47      _name(name), _lines(lines), _indent(indent)
 
   58      if(
_lines) std::cout << std::setw(5) << iline << 
":";
 
   59      std::cout << std::string(
_indent, 
' ');
 
   60      std::cout << 
"<" << name;
 
   61      for(
auto it = attrs.begin(); it != attrs.end(); ++it)
 
   63        std::cout << 
" " << it->first << 
"=\"" << it->second << 
"\"";
 
   65      std::cout << (closed ? 
" />" : 
">") << 
"\n";
 
   70      if(
_lines) std::cout << std::setw(5) << iline << 
":";
 
   71      std::cout << std::string(
_indent, 
' ');
 
   72      std::cout << 
"</" << 
_name << 
">\n";
 
   82      if(
_lines) std::cout << std::setw(5) << iline << 
":";
 
   83      std::cout << std::string(
_indent+2, 
' ');
 
   84      std::cout << sline << 
"\n";
 
  121      XASSERTM(parser != 
nullptr, 
"root parser must not be nullptr");
 
  210      if((!xhead) && (!xtail))
 
  230      if(sdata.find(
'<') != sdata.npos)
 
  232      if (sdata.find(
'>') != sdata.npos)
 
  250      if((sdata = sdata.
trim()).empty())
 
  255        size_t n0 = sdata.find_first_of(sdata.
whitespaces());
 
  275        for(std::size_t i(1); i < 
_cur_name.size(); ++i)
 
  294      while(!sdata.empty())
 
  297        size_t p = sdata.find_first_of(
'=');
 
  310        if(std::isalpha(akey.front()) == 0)
 
  311          throw_syntax(
"Invalid first character in attribute name '" + akey + 
"'");
 
  312        for(std::size_t i(1); i < akey.size(); ++i)
 
  314          if(std::isalnum(akey.at(i)) == 0)
 
  315            throw_syntax(
String(
"Invalid character '") + akey.at(i) + 
"' in attribute name '" + akey + 
"'");
 
  319        if(sdata.empty() || sdata.front() != 
'"')
 
  323        size_t q = sdata.find_first_of(
'"', 1);
 
  371      if(parser == 
nullptr)
 
  394      std::map<String, bool> parser_attribs;
 
  395      if(
_markups.back().parser()->attribs(parser_attribs))
 
  400          if(parser_attribs.find(it->first) == parser_attribs.end())
 
  407        for(
auto jt = parser_attribs.begin(); jt != parser_attribs.end(); ++jt)
 
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
String class implementation.
void pop_front()
Removes the first character from the string.
static const char * whitespaces()
Returns a null-terminated char string containing all white-space characters.
bool ends_with(const String &tail) const
Checks whether this string ends with another string.
String & trim_me(const String &charset)
Trims this string.
void pop_back()
Removes the last character from the string.
bool starts_with(const String &head) const
Checks whether this string starts with another string.
String trim(const String &charset) const
Trims the string.
virtual bool attribs(std::map< String, bool > &) const override
Specifies the mandatory and optional attributes.
virtual bool content(int, const String &) override
Called to process a content line.
virtual void create(int, const String &, const String &, const std::map< String, String > &, bool) override
Creates this markup parser node.
virtual void close(int, const String &) override
Closes this markup parser node.
virtual std::shared_ptr< MarkupParser > markup(int, const String &, const String &) override
Called to process a child markup node.
virtual std::shared_ptr< MarkupParser > markup(int, const String &, const String &name) override
Called to process a child markup node.
virtual void create(int iline, const String &, const String &, const std::map< String, String > &attrs, bool closed) override
Creates this markup parser node.
bool _lines
specifies whether to write line numbers
std::size_t _indent
indentation for this parser node
String _name
the name of this markup parser node
virtual bool attribs(std::map< String, bool > &) const override
Specifies the mandatory and optional attributes.
virtual bool content(int iline, const String &sline) override
Called to process a content line.
virtual void close(int iline, const String &) override
Closes this markup parser node.
void set_root_parser(std::shared_ptr< MarkupParser > parser)
Sets the root markup parser node.
String _cur_sline
current line string
bool read_next_line()
Reads the next non-empty line from the stream.
bool _cur_is_termin
specifies whether the markup is a terminator
bool scan_markup()
Tries to interpret the current line as a XML markup line.
int _cur_iline
current line number
std::map< String, String > _cur_attribs
specifies the markup attributes of the current line
void read_root()
Tries to read the XML root markup.
bool _have_read_root
specifies whether the root has been read
void throw_grammar(const String &msg) const
Throws a GrammarError for the current line.
String _cur_name
specifies the markup name of the current line
void create_top_parser()
Creates the top parser node.
void process_markup()
Tries to process the current XML markup line.
void throw_syntax(const String &msg) const
Throws a SyntaxError for the current line.
bool _cur_is_markup
specifies whether this line is a markup
std::vector< MarkupInfo > _markups
the markup stack
void process_content()
Tries to process the current XML content line.
bool _cur_is_closed
specifies whether the markup is closed
void scan()
Scans the stream.
std::istream & _stream
the input stream