blob: bc1fe4769e63cb40238db0e0fe975e3f41fa38c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#pragma once
// Standard C++
#include <istream>
#include <span>
#include <string_view>
#include <vector>
class XML {
public:
XML() = default;
virtual ~XML() = default;
XML(const XML&) = default;
XML(XML&&) = default;
XML& operator=(const XML&) = default;
XML& operator=(XML&&) = default;
void parse(std::istream& ins);
protected:
virtual void handle_start(std::string_view name, const std::vector<std::tuple<std::string_view, std::string_view>>& attr) = 0;
virtual void handle_end(std::string_view name) = 0;
virtual void handle_cdata_start() {}
virtual void handle_cdata_end() {}
virtual void handle_character_data(std::span<const char> /* data */) {}
private:
static void tag_start(void* self, const char* name, const char** attr);
static void tag_end(void* self, const char* name);
static void cdata_start(void* self);
static void cdata_end(void* self);
static void data(void* self, const char* dat, int len);
};
|