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 (std::string_view name, std::string value)
 
void removeAttribute (std::string_view name)
 
bool hasAttribute (std::string_view name) const
 
const std::string & getAttribute (std::string_view attName) const
 
std::string_view getAttribute (std::string_view attName, std::string_view defaultValue) const
 
const std::string * findAttribute (std::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 (std::string_view attName, bool defaultValue=false) const
 
int getAttributeAsInt (std::string_view attName, int defaultValue=0) const
 
bool findAttributeInt (std::string_view attName, unsigned &result) const
 
const XMLElementfindChild (std::string_view name) const
 
XMLElementfindChild (std::string_view name)
 
const XMLElementgetChild (std::string_view name) const
 
XMLElementgetChild (std::string_view name)
 
const XMLElementfindChildWithAttribute (std::string_view name, std::string_view attName, std::string_view attValue) const
 
XMLElementfindChildWithAttribute (std::string_view name, std::string_view attName, std::string_view attValue)
 
const XMLElementfindNextChild (std::string_view name, size_t &fromIndex) const
 
std::vector< const XMLElement * > getChildren (std::string_view name) const
 
XMLElementgetCreateChild (std::string_view name, std::string_view defaultValue={})
 
XMLElementgetCreateChildWithAttribute (std::string_view name, std::string_view attName, std::string_view attValue)
 
const std::string & getChildData (std::string_view name) const
 
std::string_view getChildData (std::string_view name, std::string_view defaultValue) const
 
bool getChildDataAsBool (std::string_view name, bool defaultValue=false) const
 
int getChildDataAsInt (std::string_view name, int defaultValue=0) const
 
void setChildData (std::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 (std::string_view str)
 
static std::unique_ptr< FileContextgetLastSerializedFileContext ()
 

Detailed Description

Definition at line 15 of file XMLElement.hh.

Member Typedef Documentation

◆ Children

Definition at line 54 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 25 of file XMLElement.hh.

◆ XMLElement() [3/3]

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

Definition at line 27 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 33 of file XMLElement.hh.

◆ dump()

string openmsx::XMLElement::dump ( ) const

◆ findAttribute()

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

◆ findAttributeInt()

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

Definition at line 240 of file XMLElement.cc.

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

Referenced by hasChildren().

◆ findChild() [1/2]

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

◆ findChild() [2/2]

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

◆ findChildWithAttribute() [1/2]

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

◆ findChildWithAttribute() [2/2]

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

◆ findNextChild()

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

Definition at line 98 of file XMLElement.cc.

References ranges::find_if(), findChild(), findChildWithAttribute(), getChild(), getName(), and xrange().

Referenced by hasChildren().

◆ getAttribute() [1/2]

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

◆ getAttribute() [2/2]

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

◆ getAttributeAsBool()

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

Definition at line 226 of file XMLElement.cc.

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

Referenced by hasChildren().

◆ getAttributeAsInt()

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

◆ getChild() [1/2]

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

◆ getChild() [2/2]

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

◆ getChildData() [1/2]

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

◆ getChildData() [2/2]

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

◆ getChildDataAsBool()

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

Definition at line 180 of file XMLElement.cc.

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

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

◆ getChildDataAsInt()

int openmsx::XMLElement::getChildDataAsInt ( std::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 ( std::string_view  name) const

◆ getCreateChild()

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

Definition at line 147 of file XMLElement.cc.

References addChild(), and findChild().

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

◆ getCreateChildWithAttribute()

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

Definition at line 156 of file XMLElement.cc.

References addChild(), findChild(), findChildWithAttribute(), getChild(), getChildData(), and getData().

Referenced by hasChildren().

◆ getData()

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

◆ getLastSerializedFileContext()

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

Definition at line 314 of file XMLElement.cc.

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

◆ getName()

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

Definition at line 31 of file XMLElement.hh.

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

◆ hasAttribute()

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

Definition at line 206 of file XMLElement.cc.

References findAttribute(), and getAttribute().

Referenced by addAttribute(), and setData().

◆ hasChildren()

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

◆ removeAllChildren()

void openmsx::XMLElement::removeAllChildren ( )

Definition at line 201 of file XMLElement.cc.

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

◆ removeAttribute()

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

Definition at line 68 of file XMLElement.cc.

References ranges::find_if(), findChild(), and getChildren().

Referenced by setData().

◆ removeChild()

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

Definition at line 29 of file XMLElement.cc.

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

◆ serialize()

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

Definition at line 331 of file XMLElement.cc.

References gl::context.

Referenced by hasChildren().

◆ setAttribute()

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

◆ setChildData()

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

Definition at line 192 of file XMLElement.cc.

References addChild(), and findChild().

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 ( std::string_view  str)
static

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