openMSX
Public Types | Public Member Functions | Static Public Member Functions | List of all members
openmsx::XMLElement Class Reference

#include <XMLElement.hh>

Public Types

using Children = std::vector< XMLElement >
 

Public Member Functions

 XMLElement ()=default
 
 XMLElement (std::string name_)
 
 XMLElement (std::string name_, std::string data_)
 
const std::string & getName () const
 
void setName (std::string name_)
 
void clearName ()
 
const std::string & getData () const
 
void setData (std::string data_)
 
void addAttribute (std::string name, std::string value)
 
void setAttribute (string_view name, std::string value)
 
void removeAttribute (string_view name)
 
bool hasAttribute (string_view name) const
 
const std::string & getAttribute (string_view attName) const
 
string_view getAttribute (string_view attName, string_view defaultValue) const
 
const std::string * findAttribute (string_view attName) const
 
XMLElementaddChild (std::string name)
 
XMLElementaddChild (std::string name, std::string data)
 
void removeChild (const XMLElement &child)
 
const ChildrengetChildren () const
 
bool hasChildren () const
 
bool getAttributeAsBool (string_view attName, bool defaultValue=false) const
 
int getAttributeAsInt (string_view attName, int defaultValue=0) const
 
bool findAttributeInt (string_view attName, unsigned &result) const
 
const XMLElementfindChild (string_view name) const
 
XMLElementfindChild (string_view name)
 
const XMLElementgetChild (string_view name) const
 
XMLElementgetChild (string_view name)
 
const XMLElementfindChildWithAttribute (string_view name, string_view attName, string_view attValue) const
 
XMLElementfindChildWithAttribute (string_view name, string_view attName, string_view attValue)
 
const XMLElementfindNextChild (string_view name, size_t &fromIndex) const
 
std::vector< const XMLElement * > getChildren (string_view name) const
 
XMLElementgetCreateChild (string_view name, string_view defaultValue={})
 
XMLElementgetCreateChildWithAttribute (string_view name, string_view attName, string_view attValue)
 
const std::string & getChildData (string_view name) const
 
string_view getChildData (string_view name, string_view defaultValue) const
 
bool getChildDataAsBool (string_view name, bool defaultValue=false) const
 
int getChildDataAsInt (string_view name, int defaultValue=0) const
 
void setChildData (string_view name, std::string value)
 
void removeAllChildren ()
 
std::string dump () const
 
template<typename Archive >
void serialize (Archive &ar, unsigned version)
 

Static Public Member Functions

static std::string XMLEscape (const std::string &str)
 
static std::unique_ptr< FileContextgetLastSerializedFileContext ()
 

Detailed Description

Definition at line 14 of file XMLElement.hh.

Member Typedef Documentation

◆ Children

Definition at line 53 of file XMLElement.hh.

Constructor & Destructor Documentation

◆ XMLElement() [1/3]

openmsx::XMLElement::XMLElement ( )
default

◆ XMLElement() [2/3]

openmsx::XMLElement::XMLElement ( std::string  name_)
inlineexplicit

Definition at line 24 of file XMLElement.hh.

◆ XMLElement() [3/3]

openmsx::XMLElement::XMLElement ( std::string  name_,
std::string  data_ 
)
inline

Definition at line 26 of file XMLElement.hh.

Member Function Documentation

◆ addAttribute()

void openmsx::XMLElement::addAttribute ( std::string  name,
std::string  value 
)

◆ addChild() [1/2]

XMLElement & openmsx::XMLElement::addChild ( std::string  name)

◆ addChild() [2/2]

XMLElement & openmsx::XMLElement::addChild ( std::string  name,
std::string  data 
)

Definition at line 24 of file XMLElement.cc.

◆ clearName()

void openmsx::XMLElement::clearName ( )
inline

Definition at line 32 of file XMLElement.hh.

◆ dump()

string openmsx::XMLElement::dump ( ) const

◆ findAttribute()

const string * openmsx::XMLElement::findAttribute ( string_view  attName) const

◆ findAttributeInt()

bool openmsx::XMLElement::findAttributeInt ( string_view  attName,
unsigned &  result 
) const

Definition at line 241 of file XMLElement.cc.

References findAttribute(), and StringOp::stringToInt().

Referenced by hasChildren().

◆ findChild() [1/2]

const XMLElement * openmsx::XMLElement::findChild ( string_view  name) const

◆ findChild() [2/2]

XMLElement * openmsx::XMLElement::findChild ( string_view  name)

Definition at line 88 of file XMLElement.cc.

References end(), and ranges::find_if().

◆ findChildWithAttribute() [1/2]

const XMLElement * openmsx::XMLElement::findChildWithAttribute ( string_view  name,
string_view  attName,
string_view  attValue 
) const

Definition at line 129 of file XMLElement.cc.

Referenced by getCreateChildWithAttribute(), and hasChildren().

◆ findChildWithAttribute() [2/2]

XMLElement * openmsx::XMLElement::findChildWithAttribute ( string_view  name,
string_view  attName,
string_view  attValue 
)

Definition at line 117 of file XMLElement.cc.

References end(), and ranges::find_if().

◆ findNextChild()

const XMLElement * openmsx::XMLElement::findNextChild ( string_view  name,
size_t &  fromIndex 
) const

Definition at line 99 of file XMLElement.cc.

References getName(), and xrange().

Referenced by hasChildren().

◆ getAttribute() [1/2]

const string & openmsx::XMLElement::getAttribute ( string_view  attName) const

◆ getAttribute() [2/2]

string_view openmsx::XMLElement::getAttribute ( string_view  attName,
string_view  defaultValue 
) const

Definition at line 220 of file XMLElement.cc.

References findAttribute().

◆ getAttributeAsBool()

bool openmsx::XMLElement::getAttributeAsBool ( string_view  attName,
bool  defaultValue = false 
) const

Definition at line 227 of file XMLElement.cc.

References findAttribute(), and StringOp::stringToBool().

Referenced by hasChildren().

◆ getAttributeAsInt()

int openmsx::XMLElement::getAttributeAsInt ( string_view  attName,
int  defaultValue = 0 
) const

◆ getChild() [1/2]

const XMLElement & openmsx::XMLElement::getChild ( string_view  name) const

◆ getChild() [2/2]

XMLElement & openmsx::XMLElement::getChild ( string_view  name)

Definition at line 136 of file XMLElement.cc.

References findChild().

◆ getChildData() [1/2]

const string & openmsx::XMLElement::getChildData ( string_view  name) const

◆ getChildData() [2/2]

string_view openmsx::XMLElement::getChildData ( string_view  name,
string_view  defaultValue 
) const

Definition at line 174 of file XMLElement.cc.

References findChild().

◆ getChildDataAsBool()

bool openmsx::XMLElement::getChildDataAsBool ( string_view  name,
bool  defaultValue = false 
) const

Definition at line 181 of file XMLElement.cc.

References findChild(), and StringOp::stringToBool().

Referenced by openmsx::DeviceConfig::getChildDataAsBool(), and hasChildren().

◆ getChildDataAsInt()

int openmsx::XMLElement::getChildDataAsInt ( string_view  name,
int  defaultValue = 0 
) const

◆ getChildren() [1/2]

const Children& openmsx::XMLElement::getChildren ( ) const
inline

◆ getChildren() [2/2]

std::vector< const XMLElement * > openmsx::XMLElement::getChildren ( string_view  name) const

Definition at line 77 of file XMLElement.cc.

◆ getCreateChild()

XMLElement & openmsx::XMLElement::getCreateChild ( string_view  name,
string_view  defaultValue = {} 
)

◆ getCreateChildWithAttribute()

XMLElement & openmsx::XMLElement::getCreateChildWithAttribute ( string_view  name,
string_view  attName,
string_view  attValue 
)

Definition at line 157 of file XMLElement.cc.

References addAttribute(), addChild(), findChildWithAttribute(), and string_view::str().

Referenced by hasChildren().

◆ getData()

const std::string& openmsx::XMLElement::getData ( ) const
inline

◆ getLastSerializedFileContext()

unique_ptr< FileContext > openmsx::XMLElement::getLastSerializedFileContext ( )
static

Definition at line 316 of file XMLElement.cc.

Referenced by hasChildren(), and openmsx::HardwareConfig::serialize().

◆ getName()

const std::string& openmsx::XMLElement::getName ( ) const
inline

Definition at line 30 of file XMLElement.hh.

Referenced by openmsx::DeviceFactory::create(), dump(), and findNextChild().

◆ hasAttribute()

bool openmsx::XMLElement::hasAttribute ( string_view  name) const

Definition at line 207 of file XMLElement.cc.

References findAttribute().

Referenced by addAttribute(), and setData().

◆ hasChildren()

bool openmsx::XMLElement::hasChildren ( ) const
inline

◆ removeAllChildren()

void openmsx::XMLElement::removeAllChildren ( )

Definition at line 202 of file XMLElement.cc.

Referenced by hasChildren(), and openmsx::HotKey::saveBindings().

◆ removeAttribute()

void openmsx::XMLElement::removeAttribute ( string_view  name)

Definition at line 69 of file XMLElement.cc.

References end().

Referenced by setData().

◆ removeChild()

void openmsx::XMLElement::removeChild ( const XMLElement child)

Definition at line 30 of file XMLElement.cc.

References ranges::find_if(), and rfind_if_unguarded().

Referenced by openmsx::Setting::setValue().

◆ serialize()

template<typename Archive >
void openmsx::XMLElement::serialize ( Archive &  ar,
unsigned  version 
)

Definition at line 333 of file XMLElement.cc.

References gl::context.

Referenced by hasChildren().

◆ setAttribute()

void openmsx::XMLElement::setAttribute ( string_view  name,
std::string  value 
)

◆ setChildData()

void openmsx::XMLElement::setChildData ( string_view  name,
std::string  value 
)

Definition at line 193 of file XMLElement.cc.

References addChild(), findChild(), and string_view::str().

Referenced by openmsx::RomFactory::create(), and hasChildren().

◆ setData()

void openmsx::XMLElement::setData ( std::string  data_)
inline

◆ setName()

void openmsx::XMLElement::setName ( std::string  name_)
inline

◆ XMLEscape()

string openmsx::XMLElement::XMLEscape ( const std::string &  str)
static

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