sptk2 logo
SPTK Home Page
XMLDocType.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <sptk5/Buffer.h>
30#include <sptk5/xdoc/XMLEntities.h>
31
32#include <map>
33#include <string>
34
35namespace sptk::xdoc {
36
49class SP_EXPORT XMLDocType
50{
51 friend class ImportXML;
52
53public:
57 XMLDocType() = default;
58
62 explicit XMLDocType(const char* name, const char* public_id = nullptr, const char* system_id = nullptr);
63
67 const String& name() const
68 {
69 return m_name;
70 }
71
77 const String& publicID() const
78 {
79 return m_public_id;
80 }
81
87 const String& systemID() const
88 {
89 return m_system_id;
90 }
91
98 {
99 return m_entities;
100 }
101
107 const Entities& entities() const
108 {
109 return m_entities;
110 }
111
120 bool encodeEntities(const char* str, Buffer& ret);
121
130 void decodeEntities(const char* str, size_t sz, Buffer& ret);
131
136 void removeEntity(const char* name)
137 {
138 m_entities.removeEntity(name);
139 }
140
148 const char* getReplacement(const char* name, uint32_t& replacementLength);
149
158 void setEntity(const String& name, const String& replacement)
159 {
160 m_entities.setEntity(name, replacement);
161 }
162
163private:
164 std::array<char, 16> m_replacementBuffer {};
165 std::array<Buffer, 2> m_encodeBuffers;
166 Entities m_entities;
167 String m_name;
168 String m_public_id;
169 String m_system_id;
170
171 char* appendDecodedEntity(Buffer& ret, const char* ent_start, char* ent_end);
172};
173
177} // namespace sptk::xdoc
Definition: Buffer.h:51
Definition: String.h:49
Definition: XMLEntities.h:66
Definition: ImportXML.h:51
Definition: XMLDocType.h:50
bool encodeEntities(const char *str, Buffer &ret)
const char * getReplacement(const char *name, uint32_t &replacementLength)
void removeEntity(const char *name)
Definition: XMLDocType.h:136
void setEntity(const String &name, const String &replacement)
Definition: XMLDocType.h:158
Entities & entities()
Definition: XMLDocType.h:97
const String & publicID() const
Definition: XMLDocType.h:77
const Entities & entities() const
Definition: XMLDocType.h:107
XMLDocType(const char *name, const char *public_id=nullptr, const char *system_id=nullptr)
const String & name() const
Definition: XMLDocType.h:67
const String & systemID() const
Definition: XMLDocType.h:87
void decodeEntities(const char *str, size_t sz, Buffer &ret)

Fri Oct 14 2022 09:58:32: SPTK 5.4.1