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 (XMLElement &&)=default
 
XMLElementoperator= (const XMLElement &)=default
 
XMLElementoperator= (XMLElement &&)=default
 
 XMLElement (const XMLElement &e)
 
 XMLElement (XMLElement &x)
 
template<typename String >
 XMLElement (String &&name_)
 
template<typename String1 , typename String2 >
 XMLElement (String1 &&name_, String2 &&data_)
 
const std::string & getName () const
 
void clearName ()
 
template<typename String >
void setName (String &&name_)
 
const std::string & getData () const
 
template<typename String >
void setData (String &&data_)
 
template<typename String1 , typename String2 >
void addAttribute (String1 &&attrName, String2 &&value)
 
template<typename String1 , typename String2 >
void setAttribute (String1 &&attrName, String2 &&value)
 
void removeAttribute (std::string_view name)
 
bool hasAttribute (std::string_view name) const
 
const std::string & getAttribute (std::string_view attrName) const
 
std::string_view getAttribute (std::string_view attrName, std::string_view defaultValue) const
 
const std::string * findAttribute (std::string_view attrName) const
 
template<typename String >
XMLElementaddChild (String &&childName)
 
template<typename String1 , typename String2 >
XMLElementaddChild (String1 &&childName, String2 &&childData)
 
void removeChild (const XMLElement &child)
 
const ChildrengetChildren () const
 
bool hasChildren () const
 
bool getAttributeAsBool (std::string_view attrName, bool defaultValue=false) const
 
int getAttributeAsInt (std::string_view attrName, int defaultValue=0) const
 
bool findAttributeInt (std::string_view attrName, unsigned &result) const
 
const XMLElementfindChild (std::string_view childName) const
 
XMLElementfindChild (std::string_view childName)
 
const XMLElementgetChild (std::string_view childName) const
 
XMLElementgetChild (std::string_view childName)
 
const XMLElementfindChildWithAttribute (std::string_view childName, std::string_view attrName, std::string_view attValue) const
 
XMLElementfindChildWithAttribute (std::string_view childName, std::string_view attrName, std::string_view attValue)
 
const XMLElementfindNextChild (std::string_view name, size_t &fromIndex) const
 
std::vector< const XMLElement * > getChildren (std::string_view childName) const
 
template<typename String >
XMLElementgetCreateChild (String &&childName)
 
template<typename String1 , typename String2 >
XMLElementgetCreateChild (String1 &&childName, String2 &&defaultValue)
 
template<typename String1 , typename String2 , typename String3 >
XMLElementgetCreateChildWithAttribute (String1 &&childName, String2 &&attrName, String3 &&attValue)
 
const std::string & getChildData (std::string_view childName) const
 
std::string_view getChildData (std::string_view childName, std::string_view defaultValue) const
 
bool getChildDataAsBool (std::string_view childName, bool defaultValue=false) const
 
int getChildDataAsInt (std::string_view childName, int defaultValue=0) const
 
template<typename String1 , typename String2 >
void setChildData (String1 &&childName, String2 &&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 90 of file XMLElement.hh.

Constructor & Destructor Documentation

◆ XMLElement() [1/6]

openmsx::XMLElement::XMLElement ( )
default

◆ XMLElement() [2/6]

openmsx::XMLElement::XMLElement ( XMLElement &&  )
default

◆ XMLElement() [3/6]

openmsx::XMLElement::XMLElement ( const XMLElement e)
inline

Definition at line 31 of file XMLElement.hh.

◆ XMLElement() [4/6]

openmsx::XMLElement::XMLElement ( XMLElement x)
inline

Definition at line 36 of file XMLElement.hh.

◆ XMLElement() [5/6]

template<typename String >
openmsx::XMLElement::XMLElement ( String &&  name_)
inlineexplicit

Definition at line 39 of file XMLElement.hh.

◆ XMLElement() [6/6]

template<typename String1 , typename String2 >
openmsx::XMLElement::XMLElement ( String1 &&  name_,
String2 &&  data_ 
)
inline

Definition at line 43 of file XMLElement.hh.

Member Function Documentation

◆ addAttribute()

template<typename String1 , typename String2 >
void openmsx::XMLElement::addAttribute ( String1 &&  attrName,
String2 &&  value 
)
inline

Definition at line 64 of file XMLElement.hh.

References hasAttribute().

Referenced by openmsx::XmlOutputArchive::XmlOutputArchive().

◆ addChild() [1/2]

template<typename String >
XMLElement& openmsx::XMLElement::addChild ( String &&  childName)
inline

◆ addChild() [2/2]

template<typename String1 , typename String2 >
XMLElement& openmsx::XMLElement::addChild ( String1 &&  childName,
String2 &&  childData 
)
inline

Definition at line 99 of file XMLElement.hh.

◆ clearName()

void openmsx::XMLElement::clearName ( )
inline

Definition at line 48 of file XMLElement.hh.

Referenced by openmsx::XmlInputArchive::endTag().

◆ dump()

string openmsx::XMLElement::dump ( ) const

◆ findAttribute()

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

Definition at line 37 of file XMLElement.cc.

References end().

Referenced by findAttributeInt(), getAttribute(), getAttributeAsBool(), getAttributeAsInt(), and hasAttribute().

◆ findAttributeInt()

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

Definition at line 188 of file XMLElement.cc.

References findAttribute().

◆ findChild() [1/2]

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

Definition at line 61 of file XMLElement.cc.

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

◆ findChild() [2/2]

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

◆ findChildWithAttribute() [1/2]

XMLElement * openmsx::XMLElement::findChildWithAttribute ( std::string_view  childName,
std::string_view  attrName,
std::string_view  attValue 
)

Definition at line 90 of file XMLElement.cc.

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

◆ findChildWithAttribute() [2/2]

const XMLElement * openmsx::XMLElement::findChildWithAttribute ( std::string_view  childName,
std::string_view  attrName,
std::string_view  attValue 
) const

Definition at line 102 of file XMLElement.cc.

Referenced by getCreateChildWithAttribute().

◆ findNextChild()

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

Definition at line 72 of file XMLElement.cc.

References getName(), and xrange().

◆ getAttribute() [1/2]

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

Definition at line 157 of file XMLElement.cc.

References findAttribute().

Referenced by openmsx::DeviceConfig::getAttribute().

◆ getAttribute() [2/2]

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

Definition at line 165 of file XMLElement.cc.

References findAttribute().

◆ getAttributeAsBool()

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

Definition at line 172 of file XMLElement.cc.

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

◆ getAttributeAsInt()

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

Definition at line 179 of file XMLElement.cc.

References findAttribute().

Referenced by openmsx::DeviceConfig::getAttributeAsInt().

◆ getChild() [1/2]

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

Definition at line 109 of file XMLElement.cc.

References findChild().

◆ getChild() [2/2]

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

◆ getChildData() [1/2]

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

◆ getChildData() [2/2]

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

Definition at line 126 of file XMLElement.cc.

References findChild().

◆ getChildDataAsBool()

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

Definition at line 133 of file XMLElement.cc.

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

Referenced by openmsx::DeviceConfig::getChildDataAsBool().

◆ getChildDataAsInt()

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

Definition at line 50 of file XMLElement.cc.

◆ getCreateChild() [1/2]

template<typename String >
XMLElement& openmsx::XMLElement::getCreateChild ( String &&  childName)
inline

Definition at line 138 of file XMLElement.hh.

References addChild(), and findChild().

Referenced by openmsx::HotKey::saveBindings().

◆ getCreateChild() [2/2]

template<typename String1 , typename String2 >
XMLElement& openmsx::XMLElement::getCreateChild ( String1 &&  childName,
String2 &&  defaultValue 
)
inline

Definition at line 146 of file XMLElement.hh.

References addChild(), and findChild().

◆ getCreateChildWithAttribute()

template<typename String1 , typename String2 , typename String3 >
XMLElement& openmsx::XMLElement::getCreateChildWithAttribute ( String1 &&  childName,
String2 &&  attrName,
String3 &&  attValue 
)
inline

Definition at line 155 of file XMLElement.hh.

References addChild(), and findChildWithAttribute().

◆ getData()

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

◆ getLastSerializedFileContext()

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

Definition at line 266 of file XMLElement.cc.

Referenced by openmsx::HardwareConfig::serialize().

◆ getName()

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

Definition at line 47 of file XMLElement.hh.

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

◆ hasAttribute()

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

Definition at line 152 of file XMLElement.cc.

References findAttribute().

Referenced by addAttribute().

◆ hasChildren()

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

Definition at line 106 of file XMLElement.hh.

◆ operator=() [1/2]

XMLElement& openmsx::XMLElement::operator= ( const XMLElement )
default

◆ operator=() [2/2]

XMLElement& openmsx::XMLElement::operator= ( XMLElement &&  )
default

◆ removeAllChildren()

void openmsx::XMLElement::removeAllChildren ( )

Definition at line 147 of file XMLElement.cc.

Referenced by openmsx::HotKey::saveBindings().

◆ removeAttribute()

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

Definition at line 43 of file XMLElement.cc.

References end().

◆ removeChild()

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

Definition at line 20 of file XMLElement.cc.

References rfind_if_unguarded().

◆ serialize()

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

Definition at line 283 of file XMLElement.cc.

References gl::context.

◆ setAttribute()

template<typename String1 , typename String2 >
void openmsx::XMLElement::setAttribute ( String1 &&  attrName,
String2 &&  value 
)
inline

Definition at line 71 of file XMLElement.hh.

References end().

Referenced by openmsx::HardwareConfig::parseSlots().

◆ setChildData()

template<typename String1 , typename String2 >
void openmsx::XMLElement::setChildData ( String1 &&  childName,
String2 &&  value 
)
inline

Definition at line 176 of file XMLElement.hh.

References addChild(), and findChild().

Referenced by openmsx::RomFactory::create().

◆ setData()

template<typename String >
void openmsx::XMLElement::setData ( String &&  data_)
inline

Definition at line 57 of file XMLElement.hh.

◆ setName()

template<typename String >
void openmsx::XMLElement::setName ( String &&  name_)
inline

◆ XMLEscape()

string openmsx::XMLElement::XMLEscape ( std::string_view  str)
static

Definition at line 237 of file XMLElement.cc.

References openmsx::x.


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