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 ()
 
 XMLElement (string_ref name)
 
 XMLElement (string_ref name, string_ref data)
 
const std::string & getName () const
 
void setName (string_ref name)
 
void clearName ()
 
const std::string & getData () const
 
void setData (string_ref data)
 
void addAttribute (string_ref name, string_ref value)
 
void setAttribute (string_ref name, string_ref value)
 
void removeAttribute (string_ref name)
 
XMLElementaddChild (string_ref name)
 
XMLElementaddChild (string_ref name, string_ref data)
 
void removeChild (const XMLElement &child)
 
const ChildrengetChildren () const
 
bool hasChildren () const
 
bool hasAttribute (string_ref name) const
 
const std::string & getAttribute (string_ref attName) const
 
string_ref getAttribute (string_ref attName, string_ref defaultValue) const
 
bool getAttributeAsBool (string_ref attName, bool defaultValue=false) const
 
int getAttributeAsInt (string_ref attName, int defaultValue=0) const
 
bool findAttributeInt (string_ref attName, unsigned &result) const
 
const XMLElementfindChild (string_ref name) const
 
XMLElementfindChild (string_ref name)
 
const XMLElementgetChild (string_ref name) const
 
XMLElementgetChild (string_ref name)
 
const XMLElementfindChildWithAttribute (string_ref name, string_ref attName, string_ref attValue) const
 
XMLElementfindChildWithAttribute (string_ref name, string_ref attName, string_ref attValue)
 
const XMLElementfindNextChild (string_ref name, size_t &fromIndex) const
 
std::vector< const XMLElement * > getChildren (string_ref name) const
 
XMLElementgetCreateChild (string_ref name, string_ref defaultValue={})
 
XMLElementgetCreateChildWithAttribute (string_ref name, string_ref attName, string_ref attValue)
 
const std::string & getChildData (string_ref name) const
 
string_ref getChildData (string_ref name, string_ref defaultValue) const
 
bool getChildDataAsBool (string_ref name, bool defaultValue=false) const
 
int getChildDataAsInt (string_ref name, int defaultValue=0) const
 
void setChildData (string_ref name, string_ref 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 16 of file XMLElement.hh.

Member Typedef Documentation

◆ Children

Definition at line 44 of file XMLElement.hh.

Constructor & Destructor Documentation

◆ XMLElement() [1/3]

openmsx::XMLElement::XMLElement ( )
inline

Definition at line 25 of file XMLElement.hh.

References data(), and openmsx::XMLElement.

◆ XMLElement() [2/3]

openmsx::XMLElement::XMLElement ( string_ref  name)
explicit

Definition at line 18 of file XMLElement.cc.

◆ XMLElement() [3/3]

openmsx::XMLElement::XMLElement ( string_ref  name,
string_ref  data 
)

Definition at line 23 of file XMLElement.cc.

Member Function Documentation

◆ addAttribute()

void openmsx::XMLElement::addAttribute ( string_ref  name,
string_ref  value 
)

◆ addChild() [1/2]

XMLElement & openmsx::XMLElement::addChild ( string_ref  name)

◆ addChild() [2/2]

XMLElement & openmsx::XMLElement::addChild ( string_ref  name,
string_ref  data 
)

Definition at line 34 of file XMLElement.cc.

◆ clearName()

void openmsx::XMLElement::clearName ( )

Definition at line 86 of file XMLElement.cc.

◆ dump()

string openmsx::XMLElement::dump ( ) const

◆ findAttributeInt()

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

Definition at line 269 of file XMLElement.cc.

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

◆ findChild() [1/2]

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

◆ findChild() [2/2]

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

Definition at line 108 of file XMLElement.cc.

◆ findChildWithAttribute() [1/2]

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

Definition at line 152 of file XMLElement.cc.

Referenced by getCreateChildWithAttribute().

◆ findChildWithAttribute() [2/2]

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

Definition at line 140 of file XMLElement.cc.

◆ findNextChild()

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

Definition at line 122 of file XMLElement.cc.

References getName(), and xrange().

◆ getAttribute() [1/2]

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

◆ getAttribute() [2/2]

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

Definition at line 246 of file XMLElement.cc.

References end().

◆ getAttributeAsBool()

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

Definition at line 253 of file XMLElement.cc.

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

◆ getAttributeAsInt()

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

Definition at line 261 of file XMLElement.cc.

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

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

◆ getChild() [1/2]

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

◆ getChild() [2/2]

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

Definition at line 159 of file XMLElement.cc.

References findChild().

◆ getChildData() [1/2]

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

◆ getChildData() [2/2]

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

Definition at line 198 of file XMLElement.cc.

References findChild().

◆ getChildDataAsBool()

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

Definition at line 205 of file XMLElement.cc.

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

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

◆ getChildDataAsInt()

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

Definition at line 97 of file XMLElement.cc.

◆ getCreateChild()

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

Definition at line 172 of file XMLElement.cc.

References addChild(), and findChild().

Referenced by openmsx::HotKey::saveBindings(), and openmsx::Setting::setValue().

◆ getCreateChildWithAttribute()

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

Definition at line 181 of file XMLElement.cc.

References addChild(), and findChildWithAttribute().

◆ getData()

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

◆ getLastSerializedFileContext()

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

Definition at line 346 of file XMLElement.cc.

Referenced by 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_ref  name) const

Definition at line 231 of file XMLElement.cc.

References end().

◆ hasChildren()

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

Definition at line 50 of file XMLElement.hh.

References data(), openmsx::serialize(), and SERIALIZE_CLASS_VERSION.

◆ removeAllChildren()

void openmsx::XMLElement::removeAllChildren ( )

Definition at line 226 of file XMLElement.cc.

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

◆ removeAttribute()

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

Definition at line 73 of file XMLElement.cc.

References end().

◆ removeChild()

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

Definition at line 40 of file XMLElement.cc.

References begin(), end(), and rfind_if_unguarded().

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

◆ serialize()

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

Definition at line 363 of file XMLElement.cc.

References gl::context.

◆ setAttribute()

void openmsx::XMLElement::setAttribute ( string_ref  name,
string_ref  value 
)

◆ setChildData()

void openmsx::XMLElement::setChildData ( string_ref  name,
string_ref  value 
)

Definition at line 217 of file XMLElement.cc.

References addChild(), and findChild().

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

◆ setData()

void openmsx::XMLElement::setData ( string_ref  data)

Definition at line 91 of file XMLElement.cc.

References string_ref::str().

◆ setName()

void openmsx::XMLElement::setName ( string_ref  name)

◆ XMLEscape()

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

Definition at line 319 of file XMLElement.cc.

References UNREACHABLE.

Referenced by openmsx::CliConnection::~CliConnection().


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