blob: cf53807e8469d9a21a2fd5a61c17c3014ef76de9 (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#ifndef MODXML_SAX_PROCESSOR_HH
#define MODXML_SAX_PROCESSOR_HH
#include <memory>
#include <span>
namespace modxml {
namespace sax {
class Delegate;
/**
* The XML processor, or parser if you like that term better.
* Feed it data and the processor will give the delegate calls with events or
* possibly errors.
*/
class Processor {
public:
virtual ~Processor() = default;
/**
* Construct a Processor. Same as creating a ProcessorBuilder
* and not changing any options and just calling build.
*/
static std::unique_ptr<Processor> create(std::shared_ptr<Delegate> delegate);
/**
* Process (consume) input data.
* Returns bytes consumed, can be zero.
*/
virtual std::size_t process(std::span<uint8_t const> data,
std::size_t offset = 0) = 0;
/**
* When called from delegate, points to the start of the element that
* triggered the callback.
* When called otherwise, points to the last element that was processed.
* Lines start at 1.
* Columns start at 0.
*/
virtual uint64_t line() const = 0;
virtual uint64_t column() const = 0;
protected:
Processor() = default;
private:
Processor(Processor const&) = delete;
Processor& operator=(Processor const&) = delete;
};
} // namespace sax
} // namespace modxml
#endif // MODXML_SAX_PROCESSOR_HH
|