Holds all the very basic information for XML data. Designed to be a base class from which a user can derive custom data formats. To derive, please overload the default constructor and XMLData(std::string dataType, unsigned int ID) More...
#include <XMLDataTypes.hpp>
Collaboration diagram for BARE2D::XMLData:Public Member Functions | |
| XMLData () | |
| Just adds attributes, using the protected function addAttribute(AttributeBase* attr) or its vector counterpart, as well as the nodeName variable. More... | |
| XMLData (std::string dataType, unsigned int ID) | |
| Sets all data to a known XMLData's (Uses master map to retrieve this) More... | |
| XMLData (std::vector< AttributeBase * > attributes) | |
| XMLData (std::unordered_map< std::string, AttributeBase * > attributes) | |
| ~XMLData () | |
| void | read (rapidxml::xml_node<> *node) |
| Reads the entire piece of data from a given XML node. More... | |
| void | write (rapidxml::xml_document<> *doc) |
| Writes the entire piece of data to a new node in the XML document. More... | |
| template<typename T > | |
| T | getAttributeByName (std::string name) |
| Finds an attribute by its name (eg. "name", "id") More... | |
| std::unordered_map< std::string, AttributeBase * > | getAttributes () |
Data Fields | |
| std::string | name |
| unsigned int | id |
| std::string | nodeName |
Protected Member Functions | |
| template<typename T > | |
| void | addAttribute (std::string name, AttributeType type, T *data) |
| Constructs and adds an attribute to the data. More... | |
| void | addAttribute (AttributeBase *attr) |
| Adds an attribute to the data. More... | |
| void | addAttributes (std::vector< AttributeBase * > attrs) |
| Bulk adds attributes to the data. More... | |
Protected Attributes | |
| std::unordered_map< std::string, AttributeBase * > | m_attributes |
Holds all the very basic information for XML data. Designed to be a base class from which a user can derive custom data formats. To derive, please overload the default constructor and XMLData(std::string dataType, unsigned int ID)
Definition at line 108 of file XMLDataTypes.hpp.
| BARE2D::XMLData::XMLData | ( | ) |
Just adds attributes, using the protected function addAttribute(AttributeBase* attr) or its vector counterpart, as well as the nodeName variable.
Definition at line 186 of file XMLDataTypes.cpp.
References addAttribute(), name, BARE2D::STRING, and BARE2D::UNSIGNED_INT.
Here is the call graph for this function:| BARE2D::XMLData::XMLData | ( | std::string | dataType, |
| unsigned int | ID | ||
| ) |
Sets all data to a known XMLData's (Uses master map to retrieve this)
| dataType | The name of the type to make this |
| ID | The ID of the data. |
Definition at line 195 of file XMLDataTypes.cpp.
References m_attributes, and name.
| BARE2D::XMLData::XMLData | ( | std::vector< AttributeBase * > | attributes | ) |
Definition at line 204 of file XMLDataTypes.cpp.
References addAttribute(), addAttributes(), name, BARE2D::STRING, and BARE2D::UNSIGNED_INT.
Here is the call graph for this function:| BARE2D::XMLData::XMLData | ( | std::unordered_map< std::string, AttributeBase * > | attributes | ) |
Definition at line 215 of file XMLDataTypes.cpp.
References m_attributes.
|
inline |
Definition at line 124 of file XMLDataTypes.hpp.
|
protected |
Adds an attribute to the data.
| attr | A pointer to the attribute to be added. |
Definition at line 447 of file XMLDataTypes.cpp.
References m_attributes, and BARE2D::AttributeBase::name.
|
protected |
Constructs and adds an attribute to the data.
| name | The name of the attribute. "name" and "id" are already in use, please don't break things like that. |
| type | The type of data. Eg. AttributeType::FLOAT is a float, AttributeType::VECTOR_FLOAT is a vector of floats, etc. |
| data | A pointer to the data that the attribute is linked to. |
Referenced by addAttributes(), and XMLData().
Here is the caller graph for this function:
|
protected |
Bulk adds attributes to the data.
| attrs | A vector of pointers to attributes to add. |
Definition at line 452 of file XMLDataTypes.cpp.
References addAttribute().
Referenced by XMLData().
Here is the call graph for this function:
Here is the caller graph for this function:| T BARE2D::XMLData::getAttributeByName | ( | std::string | name | ) |
Finds an attribute by its name (eg. "name", "id")
| name | The name of the attribute |
| std::unordered_map< std::string, AttributeBase * > BARE2D::XMLData::getAttributes | ( | ) |
Definition at line 442 of file XMLDataTypes.cpp.
References m_attributes.
| void BARE2D::XMLData::read | ( | rapidxml::xml_node<> * | node | ) |
Reads the entire piece of data from a given XML node.
| node | The node to interpret and read from |
Definition at line 222 of file XMLDataTypes.cpp.
References BARE2D::BOOL, BARE2D::FLOAT, BARE2D::Logger::getInstance(), BARE2D::INT, BARE2D::ResourceManager::loadScript(), BARE2D::ResourceManager::loadTexture(), BARE2D::Logger::log(), m_attributes, name, BARE2D::XMLDataManager::readValue(), BARE2D::SCRIPT, BARE2D::AttributeBase::setData(), BARE2D::STRING, BARE2D::TEXTURE, BARE2D::throwError(), BARE2D::AttributeBase::type, BARE2D::UNSIGNED_INT, BARE2D::VEC2, BARE2D::VECTOR_BOOL, BARE2D::VECTOR_FLOAT, BARE2D::VECTOR_UNSIGNED_INT, BARE2D::VECTOR_VEC2, and BARE2D::XML_FAILURE.
Referenced by BARE2D::XMLDataManager::readXMLData().
Here is the call graph for this function:
Here is the caller graph for this function:| void BARE2D::XMLData::write | ( | rapidxml::xml_document<> * | doc | ) |
Writes the entire piece of data to a new node in the XML document.
| doc | The document to write to. |
Definition at line 383 of file XMLDataTypes.cpp.
References BARE2D::AttributeBase::getDataString(), m_attributes, name, and nodeName.
Here is the call graph for this function:| unsigned int BARE2D::XMLData::id |
Definition at line 151 of file XMLDataTypes.hpp.
Referenced by BARE2D::XMLDataManager::addData(), BARE2D::XMLDataManager::readXMLData(), and BARE2D::XMLDataManager::setData().
|
protected |
Definition at line 175 of file XMLDataTypes.hpp.
Referenced by addAttribute(), getAttributes(), read(), write(), and XMLData().
| std::string BARE2D::XMLData::name |
Definition at line 150 of file XMLDataTypes.hpp.
Referenced by BARE2D::XMLDataManager::addData(), read(), BARE2D::XMLDataManager::readXMLData(), write(), and XMLData().
| std::string BARE2D::XMLData::nodeName |
Definition at line 152 of file XMLDataTypes.hpp.
Referenced by BARE2D::XMLDataManager::addData(), BARE2D::XMLDataManager::readXMLData(), BARE2D::XMLDataManager::setData(), and write().