#ifndef MODXML_SAX_PROCESSOR_HH #define MODXML_SAX_PROCESSOR_HH #include #include 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 create(std::shared_ptr delegate); /** * Process (consume) input data. * Returns bytes consumed, can be zero. */ virtual std::size_t process(std::span 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