summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorThomas Schmucker <ts@its1.de>2026-07-15 21:05:19 +0200
committerThomas Schmucker <ts@its1.de>2026-07-15 21:05:19 +0200
commit4f3760fc3b647fa166da4ab777eb612b14ac500b (patch)
tree2f9faece24cac31f8dcb842572cdd9a486402637 /include
parent0cf833840b19e603f480dead5ca211f947503f9b (diff)
downloadexpat++-4f3760fc3b647fa166da4ab777eb612b14ac500b.tar.gz
expat++-4f3760fc3b647fa166da4ab777eb612b14ac500b.tar.bz2
expat++-4f3760fc3b647fa166da4ab777eb612b14ac500b.zip
Umbau auf modernes C++
Diffstat (limited to 'include')
-rw-r--r--include/xml.hpp45
1 files changed, 25 insertions, 20 deletions
diff --git a/include/xml.hpp b/include/xml.hpp
index cc593a3..bc1fe47 100644
--- a/include/xml.hpp
+++ b/include/xml.hpp
@@ -1,28 +1,33 @@
1#ifndef XML_HPP_INCLUDED 1#pragma once
2#define XML_HPP_INCLUDED
3 2
4// Standard C++ 3// Standard C++
5#include <iostream> 4#include <istream>
6#include <string> 5#include <span>
6#include <string_view>
7#include <vector> 7#include <vector>
8 8
9class XML { 9class XML {
10 public: 10public:
11 void parse(std::istream& in); 11 XML() = default;
12 virtual ~XML() = default;
13 XML(const XML&) = default;
14 XML(XML&&) = default;
15 XML& operator=(const XML&) = default;
16 XML& operator=(XML&&) = default;
12 17
13 protected: 18 void parse(std::istream& ins);
14 virtual void handle_start(const std::string& name, const std::vector<std::pair<std::string, std::string>>& attr) = 0;
15 virtual void handle_end(const std::string& name) = 0;
16 virtual void handle_cdata_start() {}
17 virtual void handle_cdata_end() {}
18 virtual void handle_data(const std::vector<char>&) {}
19 19
20 private: 20protected:
21 static void tag_start(void* me, const char* name, const char* attr[]); 21 virtual void handle_start(std::string_view name, const std::vector<std::tuple<std::string_view, std::string_view>>& attr) = 0;
22 static void tag_end(void* me, const char* name); 22 virtual void handle_end(std::string_view name) = 0;
23 static void cdata_start(void* me); 23 virtual void handle_cdata_start() {}
24 static void cdata_end(void* me); 24 virtual void handle_cdata_end() {}
25 static void data(void* me, const char* dat, int len); 25 virtual void handle_character_data(std::span<const char> /* data */) {}
26};
27 26
28#endif 27private:
28 static void tag_start(void* self, const char* name, const char** attr);
29 static void tag_end(void* self, const char* name);
30 static void cdata_start(void* self);
31 static void cdata_end(void* self);
32 static void data(void* self, const char* dat, int len);
33};