MLBookProc 1.3
Loading...
Searching...
No Matches
XMLParser.h
1/*
2 * Copyright (C) 2024-2025 Yury Bobylev <bobilev_yury@mail.ru>
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation, version 3.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16
17#ifndef XMLPARSER_H
18#define XMLPARSER_H
19
20#include <AuxFunc.h>
21#include <MLException.h>
22#include <XMLTag.h>
23#include <memory>
24#include <string>
25#include <vector>
26
36class __attribute__((deprecated)) XMLParser
37{
38public:
43 XMLParser(const std::shared_ptr<AuxFunc> &af);
44
56 std::vector<XMLTag>
57 get_tag(const std::string &book, const std::string &tag_id);
58
71 std::string
72 get_book_encoding(const std::string &book);
73
81 std::string
82 get_element_attribute(const std::string &element,
83 const std::string &attr_name);
84
95 std::vector<XMLTag>
96 listAllTags(const std::string &book);
97
107 void
108 searchTag(const std::vector<XMLTag> &list, const std::string &tag_id,
109 std::vector<XMLTag> &result);
110
119 void
120 htmlSymbolsReplacement(std::string &book);
121
132 void
133 removeAllTags(std::string &book);
134
135private:
136 enum tag_type
137 {
138 single,
139 has_content,
140 end_tag,
141 spec_tag
142 };
143
144 std::string
145 tagElement(const std::string &book, const std::string::size_type &start,
146 std::string::size_type &end, tag_type &tg_type);
147
148 void
149 tagContent(const std::string &book, const std::string::size_type &start,
150 const std::string::size_type &book_end, XMLTag &tag,
151 std::string::size_type &tag_end);
152
153 void
154 tagId(XMLTag &tag);
155
156 std::shared_ptr<AuxFunc> af;
157};
158
159#endif // XMLPARSER_H
void searchTag(const std::vector< XMLTag > &list, const std::string &tag_id, std::vector< XMLTag > &result)
Searches tag in tag list.
void removeAllTags(std::string &book)
Removes all tag elements from XML document.
void htmlSymbolsReplacement(std::string &book)
Replaces symbols encoded by "&..." sequences.
std::vector< XMLTag > get_tag(const std::string &book, const std::string &tag_id)
Returns all tags with particular name.
std::vector< XMLTag > listAllTags(const std::string &book)
Parses XML document.
XMLParser(const std::shared_ptr< AuxFunc > &af)
XMLParser constructor.
std::string get_element_attribute(const std::string &element, const std::string &attr_name)
Returns XML tag attribute if it was found.
std::string get_book_encoding(const std::string &book)
Returns XML document encoding.
The XMLTag class.
Definition XMLTag.h:35