MLBookProc 2.1
Loading...
Searching...
No Matches
FormatAnnotation.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 FORMATANNOTATION_H
18#define FORMATANNOTATION_H
19
20#include <MLBookProc.h>
21#include <ReplaceTagItem.h>
22#include <XMLParserCPP.h>
23#include <memory>
24#include <string>
25#include <vector>
26
33{
34public:
39 FormatAnnotation(const std::shared_ptr<MLBookProc> &mlbp);
40
41 virtual ~FormatAnnotation();
42
53 void
54 removeEscapeSequences(std::string &annotation);
55
65 void
66 replaceTags(std::string &annotation);
67
78 void
79 finalCleaning(std::string &annotation);
80
88 void
89 removeAllTags(std::string &annotation);
90
102 void
104 const std::vector<ReplaceTagItem> &replacement_table,
105 const std::vector<std::tuple<std::string, std::string>>
106 &symbols_replacement);
107
108private:
109 void
110 recursiveReplacement(const std::vector<XMLElement> &elements,
111 std::string &annotation);
112
113 void
114 recursiveTagRemoving(const std::vector<XMLElement> &elements,
115 std::string &annotation);
116
117 std::string
118 replaceSymbols(const std::string &source);
119
120 XMLParserCPP *xml_parser;
121
122 std::vector<ReplaceTagItem> replacement_table;
123
124 std::vector<std::tuple<std::string, std::string>> symbols_replacement;
125
126 std::shared_ptr<MLBookProc> mlbp;
127};
128
129#endif // FORMATANNOTATION_H
void finalCleaning(std::string &annotation)
Cleans some sequences from annotation.
void setTagReplacementTable(const std::vector< ReplaceTagItem > &replacement_table, const std::vector< std::tuple< std::string, std::string > > &symbols_replacement)
Sets tag replacement table.
FormatAnnotation(const std::shared_ptr< MLBookProc > &mlbp)
FormatAnnotation constructor.
void removeAllTags(std::string &annotation)
Simply removes all XML tags.
void removeEscapeSequences(std::string &annotation)
Removes escape sequences from annotation.
void replaceTags(std::string &annotation)
Replaces XML tags.