basic-xml 1.0.1
Very basic loader/writer of XML tags with attributes and content.
parser.h
Go to the documentation of this file.
1// Copyright (c) 2019-2024 Made to Order Software Corp. All Rights Reserved
2//
3// https://snapwebsites.org/project/basic-xml
4// contact@m2osw.com
5//
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19
27// self
28//
29#include <basic-xml/node.h>
30
31
32// C++
33//
34#include <istream>
35
36
37
38namespace basic_xml
39{
40
41
42
43class parser
44{
45public:
46 parser(std::string const & filename, std::istream & in, node::pointer_t & root);
47
48private:
49 enum class token_t
50 {
51 TOK_CLOSE_TAG,
52 TOK_EMPTY_TAG,
53 TOK_END_TAG,
54 TOK_EOF,
55 TOK_EQUAL,
56 TOK_IDENTIFIER,
57 TOK_OPEN_TAG,
58 TOK_PROCESSOR,
59 TOK_STRING,
60 TOK_TEXT
61 };
62
63 void load(node::pointer_t & root);
64 token_t skip_empty(token_t tok);
65 token_t read_tag_attributes(node::pointer_t & tag);
66 token_t get_token(bool parsing_attributes);
67 void unescape_entities();
68 char32_t getc();
69 void ungetc(char32_t c);
70
71 std::string f_filename = std::string();
72 std::istream & f_in;
73 std::size_t f_ungetc_pos = 0;
74 char32_t f_ungetc[4] = { '\0' };
75 int f_line = 1;
76 std::string f_value = std::string();
77};
78
79
80
81} // namespace basic_xml
82// vim: ts=4 sw=4 et
void load(node::pointer_t &root)
Load the XML as node in root.
Definition parser.cpp:75
Node for the basic XML tree.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.