Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::runtime::XmlDocument Class Reference

Parsed XML document (RAII wrapper over pugi::xml_document). More...

#include <xml.hpp>

Public Member Functions

 XmlDocument ()
 ~XmlDocument ()
bool parse (std::string_view xml_string)
 Parse XML from a string. Returns false on failure.
bool load_file (std::string_view path)
 Load XML from a file. Returns false on failure.
std::string to_string () const
 Save the document to a string.
bool save_file (std::string_view path) const
 Save the document to a file. Returns false on failure.
std::string root_name () const
 Get the root element name.
std::optional< std::string > root_attribute (std::string_view name) const
 Get an attribute value from the root element.
std::vector< std::string > xpath_strings (std::string_view xpath) const
 Find all elements matching an XPath expression.
std::optional< std::string > xpath_string (std::string_view xpath) const
 Get text content of the first element matching an XPath expression.
void walk (std::function< void(std::string_view name, std::string_view text)> fn) const
 Walk all elements, calling fn with (element_name, text_content).
bool is_valid () const
 Whether the document was parsed successfully.
const std::string & error () const
 Last parse error message.
 XmlDocument (const XmlDocument &)=delete
XmlDocument & operator= (const XmlDocument &)=delete
 XmlDocument (XmlDocument &&) noexcept
XmlDocument & operator= (XmlDocument &&) noexcept

Detailed Description

Parsed XML document (RAII wrapper over pugi::xml_document).

Constructor & Destructor Documentation

◆ XmlDocument() [1/3]

pulp::runtime::XmlDocument::XmlDocument ( )

◆ ~XmlDocument()

pulp::runtime::XmlDocument::~XmlDocument ( )

◆ XmlDocument() [2/3]

pulp::runtime::XmlDocument::XmlDocument ( const XmlDocument & )
delete

◆ XmlDocument() [3/3]

pulp::runtime::XmlDocument::XmlDocument ( XmlDocument && )
noexcept

Member Function Documentation

◆ error()

const std::string & pulp::runtime::XmlDocument::error ( ) const
inline

Last parse error message.

◆ is_valid()

bool pulp::runtime::XmlDocument::is_valid ( ) const
inline

Whether the document was parsed successfully.

◆ load_file()

bool pulp::runtime::XmlDocument::load_file ( std::string_view path)

Load XML from a file. Returns false on failure.

◆ operator=() [1/2]

XmlDocument & pulp::runtime::XmlDocument::operator= ( const XmlDocument & )
delete

◆ operator=() [2/2]

XmlDocument & pulp::runtime::XmlDocument::operator= ( XmlDocument && )
noexcept

◆ parse()

bool pulp::runtime::XmlDocument::parse ( std::string_view xml_string)

Parse XML from a string. Returns false on failure.

◆ root_attribute()

std::optional< std::string > pulp::runtime::XmlDocument::root_attribute ( std::string_view name) const

Get an attribute value from the root element.

◆ root_name()

std::string pulp::runtime::XmlDocument::root_name ( ) const

Get the root element name.

◆ save_file()

bool pulp::runtime::XmlDocument::save_file ( std::string_view path) const

Save the document to a file. Returns false on failure.

◆ to_string()

std::string pulp::runtime::XmlDocument::to_string ( ) const

Save the document to a string.

◆ walk()

void pulp::runtime::XmlDocument::walk ( std::function< void(std::string_view name, std::string_view text)> fn) const

Walk all elements, calling fn with (element_name, text_content).

◆ xpath_string()

std::optional< std::string > pulp::runtime::XmlDocument::xpath_string ( std::string_view xpath) const

Get text content of the first element matching an XPath expression.

◆ xpath_strings()

std::vector< std::string > pulp::runtime::XmlDocument::xpath_strings ( std::string_view xpath) const

Find all elements matching an XPath expression.

Returns their text content.


The documentation for this class was generated from the following file:
  • /home/runner/work/pulp/pulp/core/runtime/include/pulp/runtime/xml.hpp