1#ifndef LIBFILEZILLA_XML_HEADER
2#define LIBFILEZILLA_XML_HEADER
17enum class callback_event
56 typedef std::function<bool(callback_event type, std::string_view path, std::string_view name, std::string && value)>
callback_t;
68 bool parse(std::string_view data);
78 bool FZ_PRIVATE_SYMBOL decode_ref();
79 bool FZ_PRIVATE_SYMBOL is_valid_tag_or_attr(std::string_view s)
const;
80 bool FZ_PRIVATE_SYMBOL normalize_value();
82 bool FZ_PRIVATE_SYMBOL parse_valid_utf8(std::string_view data);
83 bool FZ_PRIVATE_SYMBOL parse(
char const*
const begin,
char const*
const end);
84 void FZ_PRIVATE_SYMBOL set_error(std::string_view msg,
size_t offset);
86 bool FZ_PRIVATE_SYMBOL deduce_encoding(std::string_view & data);
124 std::vector<size_t> nodes_;
127 std::string converted_{};
130 size_t utf8_state_{};
131 uint32_t utf16_state_;
134 state s_{ state::content };
136 enum class encoding {
142 encoding encoding_{};
145 size_t tag_match_pos_{};
147 unsigned char dashes_;
177 bool parse(std::string_view data);
180 std::string get_error()
const;
183 typedef std::function<bool(callback_event type, std::string_view path, std::string_view name, std::string_view value)>
raw_callback_t;
187 std::string_view FZ_PRIVATE_SYMBOL apply_namespaces(std::string_view in);
188 bool FZ_PRIVATE_SYMBOL apply_namespace_to_path();
190 bool FZ_PRIVATE_SYMBOL on_callback(callback_event type, std::string_view path, std::string_view name, std::string && value);
199 std::vector<size_t> nodes_;
200 std::vector<std::pair<std::string, std::string>> attributes_;
201 std::vector<std::tuple<size_t, std::string, std::string>> namespaces_;
202 bool needs_namespace_expansion_{};
213 void log(callback_event type, std::string_view, std::string_view name, std::string_view value);
216 virtual void on_line(std::string_view line) = 0;
219 void FZ_PRIVATE_SYMBOL finish_line();
220 void FZ_PRIVATE_SYMBOL print_line();
234 virtual void on_line(std::string_view line)
override;
The buffer class is a simple buffer where data can be appended at the end and consumed at the front....
Definition: buffer.hpp:27
Abstract interface for logging strings.
Definition: logger.hpp:51
A stremable XML parser that resolves namespace declarations and namespace prefixes.
Definition: xml.hpp:168
std::function< bool(callback_event type, std::string_view path, std::string_view name, std::string_view value)> raw_callback_t
Additional raw callback to look at events before namespace processing takes place.
Definition: xml.hpp:183
A streaming XML parser.
Definition: xml.hpp:48
void set_callback(callback_t &&cb)
std::string get_error() const
Returns an error description. Empty if parsing was stopped by a callback.
bool parse(std::string_view data)
Processes the block of data. Can be partial.
std::function< bool(callback_event type, std::string_view path, std::string_view name, std::string &&value)> callback_t
Definition: xml.hpp:56
A slow pretty printer for XML as it is being parsed.
Definition: xml.hpp:229
A slow pretty printer for XML as it is being parsed.
Definition: xml.hpp:208
type
Definition: logger.hpp:16
The namespace used by libfilezilla.
Definition: apply.hpp:17