1 #ifndef LIBFILEZILLA_XML_HEADER
2 #define LIBFILEZILLA_XML_HEADER
23 enum class callback_event
62 typedef std::function<bool(callback_event type, std::string_view path, std::string_view name, std::string && value)>
callback_t;
65 parser(callback_t
const& cb);
70 void set_callback(callback_t && cb);
71 void set_callback(callback_t
const& cb);
74 bool parse(std::string_view data);
81 std::string get_error()
const;
85 void set_limits(
size_t value_size_limit,
size_t path_size_limit);
88 bool FZ_PRIVATE_SYMBOL decode_ref();
89 bool FZ_PRIVATE_SYMBOL is_valid_tag_or_attr(std::string_view s)
const;
90 bool FZ_PRIVATE_SYMBOL normalize_value();
92 bool FZ_PRIVATE_SYMBOL parse_valid_utf8(std::string_view data);
93 bool FZ_PRIVATE_SYMBOL parse(
char const*
const begin,
char const*
const end);
94 void FZ_PRIVATE_SYMBOL set_error(std::string_view msg,
size_t offset);
96 bool FZ_PRIVATE_SYMBOL deduce_encoding(std::string_view & data);
136 std::vector<size_t> nodes_;
140 std::string converted_{};
142 size_t path_size_limit_{1024*1024};
143 size_t value_size_limit_{10*1024*1024};
146 size_t utf8_state_{};
147 uint32_t utf16_state_;
150 state s_{ state::content };
152 enum class encoding {
158 encoding encoding_{};
161 size_t tag_match_pos_{};
163 unsigned char dashes_;
193 bool parse(std::string_view data);
196 std::string get_error()
const;
199 typedef std::function<bool(callback_event type, std::string_view path, std::string_view name, std::string_view value)>
raw_callback_t;
200 void set_raw_callback(raw_callback_t && cb);
201 void set_raw_callback(raw_callback_t
const& cb);
203 std::string_view FZ_PRIVATE_SYMBOL apply_namespaces(std::string_view in);
204 bool FZ_PRIVATE_SYMBOL apply_namespace_to_path();
206 bool FZ_PRIVATE_SYMBOL on_callback(callback_event type, std::string_view path, std::string_view name, std::string && value);
211 raw_callback_t raw_cb_;
215 std::vector<size_t> nodes_;
216 std::vector<std::pair<std::string, std::string>> attributes_;
217 std::vector<std::tuple<size_t, std::string, std::string>> namespaces_;
218 bool needs_namespace_expansion_{};
229 void log(callback_event type, std::string_view, std::string_view name, std::string_view value);
232 virtual void on_line(std::string_view line) = 0;
235 void FZ_PRIVATE_SYMBOL finish_line();
236 void FZ_PRIVATE_SYMBOL print_line();
250 virtual void on_line(std::string_view line)
override;
Pretty-prints XML as it is being parsed to a logger.
Definition: xml.hpp:244
A streaming XML parser.
Definition: xml.hpp:53
A stremable XML parser that resolves namespace declarations and namespace prefixes.
Definition: xml.hpp:183
The namespace used by libfilezilla.
Definition: apply.hpp:17
A slow pretty printer for XML as it is being parsed.
Definition: xml.hpp:223
std::function< bool(callback_event type, std::string_view path, std::string_view name, std::string &&value)> callback_t
Definition: xml.hpp:62
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:199
The buffer class is a simple buffer where data can be appended at the end and consumed at the front...
Definition: buffer.hpp:26
Abstract interface for logging strings.
Definition: logger.hpp:50