libfilezilla
Public Types | Public Member Functions | List of all members
parser Class Referencefinal

A streaming XML parser. More...

#include <xml.hpp>

Public Types

typedef std::function< bool(callback_event type, std::string_view path, std::string_view name, std::string &&value)> callback_t
 

Public Member Functions

 parser (callback_t const &cb)
 
 parser (callback_t &&cb)
 
void set_callback (callback_t &&cb)
 
void set_callback (callback_t const &cb)
 
bool parse (std::string_view data)
 Processes the block of data. Can be partial.
 
bool finalize ()
 
std::string get_error () const
 Returns an error description. Empty if parsing was stopped by a callback.
 
void set_limits (size_t value_size_limit, size_t path_size_limit)
 

Detailed Description

A streaming XML parser.

Supports input data in UTF-8, UTF-16-BE and UTF-16-LE, detected automatically.

Can parse XML in chunks of any size, including bytewise in all supported character sets.

Examples
xml_pp.cpp.

Member Typedef Documentation

◆ callback_t

typedef std::function<bool(callback_event type, std::string_view path, std::string_view name, std::string && value)> callback_t

Callbacks return whether parsing should continue.

  • path is the full path of the parent element, which is formed by concatenating all parent elements' names, separated by <

Member Function Documentation

◆ finalize()

bool finalize ( )

After parsing all data, finalize the document to check that it is terminated properly.

Examples
xml_pp.cpp.

◆ set_callback()

void set_callback ( callback_t &&  cb)

The passed callback function will be invoked for each event during the parse. Don't call any parser function from a callback.

Examples
xml_pp.cpp.

◆ set_limits()

void set_limits ( size_t  value_size_limit,
size_t  path_size_limit 
)

These limits are checked after processing a block of input data. They may be temporarily exceeded by the size of the last block of input data.


The documentation for this class was generated from the following file: