A singleton class that statically manages all XML data, including read and write operations.
More...
#include <XMLDataManager.hpp>
|
| template<> |
| bool | readValue (rapidxml::xml_node<> *parent, std::string valueName, std::string &variable) |
| |
| template<> |
| bool | readValue (rapidxml::xml_node<> *parent, std::string valueName, unsigned int &variable) |
| |
| template<> |
| bool | readValue (rapidxml::xml_node<> *parent, std::string valueName, std::vector< unsigned int > &variable) |
| |
| template<> |
| bool | readValue (rapidxml::xml_node<> *parent, std::string valueName, int &variable) |
| |
| template<> |
| bool | readValue (rapidxml::xml_node<> *parent, std::string valueName, float &variable) |
| |
| template<> |
| bool | readValue (rapidxml::xml_node<> *parent, std::string valueName, std::vector< float > &variable) |
| |
| template<> |
| bool | readValue (rapidxml::xml_node<> *parent, std::string valueName, bool &variable) |
| |
| template<> |
| bool | readValue (rapidxml::xml_node<> *parent, std::string valueName, std::vector< bool > &variable) |
| |
| template<> |
| bool | readValue (rapidxml::xml_node<> *parent, std::string valueName, glm::vec2 &variable) |
| |
| template<> |
| bool | readValue (rapidxml::xml_node<> *parent, std::string valueName, std::vector< glm::vec2 > &variable) |
| |
|
| static void | loadXML (std::string filepath) |
| | Loads all of the files from the filepath that end in .xml to the caches. Does not clear caches. More...
|
| |
| static void | saveXML (std::string filepath) |
| | Writes all of the currently cached data to the data's respective files in a folder at filepath. Does not clear caches. More...
|
| |
| template<typename T > |
| static void | addDataType () |
| | Adds a type of data that can be read. Make sure that the custom data type's nodeName is set. More...
|
| |
| static void | addData (XMLData *data) |
| | Adds a piece of data to the cache, in the appropriate sub-cache. More...
|
| |
| static void | setData (XMLData *data) |
| | Adds or overwrites data in the cache/sub-cache. More...
|
| |
| template<typename T > |
| static T | getData (std::string dataType, unsigned int key) |
| | Finds some data in the subcache. More...
|
| |
| static unsigned int | getDataCount (std::string dataType) |
| |
| static void | clearCache () |
| | Clears the various caches and subcaches that the class uses. Useful for refreshes. More...
|
| |
| static XMLData | getDataType (std::string dataType) |
| | Provides a copy of some data type added by the addDataType function. More...
|
| |
|
| static void | writeXMLData (std::ofstream &file, Cache< unsigned int, XMLData > *data) |
| | Writes a single subcache of data to a single file. More...
|
| |
| static void | readXMLData (std::ifstream &file, std::string dataType) |
| | Reads a single subcache from a single file. More...
|
| |
| template<typename T > |
| static bool | readValue (rapidxml::xml_node<> *parent, std::string valueName, T &variable) |
| | Reads a value from a node. Templated for almost any primitive. More...
|
| |
| static Cache< unsigned int, XMLData > * | getDataCache (std::string dataType) |
| | Returns a cache for a certain type of data. More...
|
| |
A singleton class that statically manages all XML data, including read and write operations.
Definition at line 16 of file XMLDataManager.hpp.
◆ addData()
| void BARE2D::XMLDataManager::addData |
( |
XMLData * |
data | ) |
|
|
static |
Adds a piece of data to the cache, in the appropriate sub-cache.
- Parameters
-
| data | A pointer to the data to be added. data->nodeName must be set for appropriate sub-caching. |
Definition at line 158 of file XMLDataManager.cpp.
References BARE2D::Cache< S, T >::addItem(), BARE2D::Cache< S, T >::findItem(), getDataCache(), BARE2D::XMLData::id, BARE2D::XMLData::name, BARE2D::XMLData::nodeName, BARE2D::throwError(), and BARE2D::XML_FAILURE.
Referenced by readXMLData().
◆ addDataType()
template<typename T >
| static void BARE2D::XMLDataManager::addDataType |
( |
| ) |
|
|
static |
Adds a type of data that can be read. Make sure that the custom data type's nodeName is set.
◆ clearCache()
| void BARE2D::XMLDataManager::clearCache |
( |
| ) |
|
|
static |
◆ getData()
template<typename T >
| static T BARE2D::XMLDataManager::getData |
( |
std::string |
dataType, |
|
|
unsigned int |
key |
|
) |
| |
|
static |
Finds some data in the subcache.
- Parameters
-
| dataType | The string type of the data to get. |
| key | The ID of the data. |
- Returns
- A copy of the data, as nobody should be modifying the cached data.
◆ getDataCache()
| Cache< unsigned int, XMLData > * BARE2D::XMLDataManager::getDataCache |
( |
std::string |
dataType | ) |
|
|
staticprivate |
◆ getDataCount()
| unsigned int BARE2D::XMLDataManager::getDataCount |
( |
std::string |
dataType | ) |
|
|
static |
- Parameters
-
| dataType | The string type of the data to get info on. |
- Returns
- The number of elements of the type of data.
Definition at line 153 of file XMLDataManager.cpp.
References getDataCache().
◆ getDataType()
| static XMLData BARE2D::XMLDataManager::getDataType |
( |
std::string |
dataType | ) |
|
|
static |
Provides a copy of some data type added by the addDataType function.
- Parameters
-
| dataType | The string identifier for the type of data. In other words, nodeName |
- Returns
- A copy of some type of data, complete with nodeName and attributes set.
◆ loadXML()
| void BARE2D::XMLDataManager::loadXML |
( |
std::string |
filepath | ) |
|
|
static |
◆ readValue() [1/11]
template<>
| bool BARE2D::XMLDataManager::readValue |
( |
rapidxml::xml_node<> * |
parent, |
|
|
std::string |
valueName, |
|
|
bool & |
variable |
|
) |
| |
◆ readValue() [2/11]
template<>
| bool BARE2D::XMLDataManager::readValue |
( |
rapidxml::xml_node<> * |
parent, |
|
|
std::string |
valueName, |
|
|
float & |
variable |
|
) |
| |
◆ readValue() [3/11]
template<>
| bool BARE2D::XMLDataManager::readValue |
( |
rapidxml::xml_node<> * |
parent, |
|
|
std::string |
valueName, |
|
|
glm::vec2 & |
variable |
|
) |
| |
◆ readValue() [4/11]
template<>
| bool BARE2D::XMLDataManager::readValue |
( |
rapidxml::xml_node<> * |
parent, |
|
|
std::string |
valueName, |
|
|
int & |
variable |
|
) |
| |
◆ readValue() [5/11]
template<>
| bool BARE2D::XMLDataManager::readValue |
( |
rapidxml::xml_node<> * |
parent, |
|
|
std::string |
valueName, |
|
|
std::string & |
variable |
|
) |
| |
◆ readValue() [6/11]
template<>
| bool BARE2D::XMLDataManager::readValue |
( |
rapidxml::xml_node<> * |
parent, |
|
|
std::string |
valueName, |
|
|
std::vector< bool > & |
variable |
|
) |
| |
◆ readValue() [7/11]
template<>
| bool BARE2D::XMLDataManager::readValue |
( |
rapidxml::xml_node<> * |
parent, |
|
|
std::string |
valueName, |
|
|
std::vector< float > & |
variable |
|
) |
| |
◆ readValue() [8/11]
template<>
| bool BARE2D::XMLDataManager::readValue |
( |
rapidxml::xml_node<> * |
parent, |
|
|
std::string |
valueName, |
|
|
std::vector< glm::vec2 > & |
variable |
|
) |
| |
◆ readValue() [9/11]
template<>
| bool BARE2D::XMLDataManager::readValue |
( |
rapidxml::xml_node<> * |
parent, |
|
|
std::string |
valueName, |
|
|
std::vector< unsigned int > & |
variable |
|
) |
| |
◆ readValue() [10/11]
template<typename T >
| static bool BARE2D::XMLDataManager::readValue |
( |
rapidxml::xml_node<> * |
parent, |
|
|
std::string |
valueName, |
|
|
T & |
variable |
|
) |
| |
|
staticprivate |
Reads a value from a node. Templated for almost any primitive.
- Parameters
-
| parent | A pointer to the node of the parent data. |
| valueName | The "nodeName" of the value to be read. |
| variable | The return variable. |
- Returns
- True on success, false on failure.
Referenced by BARE2D::XMLData::read().
◆ readValue() [11/11]
template<>
| bool BARE2D::XMLDataManager::readValue |
( |
rapidxml::xml_node<> * |
parent, |
|
|
std::string |
valueName, |
|
|
unsigned int & |
variable |
|
) |
| |
◆ readXMLData()
| void BARE2D::XMLDataManager::readXMLData |
( |
std::ifstream & |
file, |
|
|
std::string |
dataType |
|
) |
| |
|
staticprivate |
◆ saveXML()
| void BARE2D::XMLDataManager::saveXML |
( |
std::string |
filepath | ) |
|
|
static |
◆ setData()
| void BARE2D::XMLDataManager::setData |
( |
XMLData * |
data | ) |
|
|
static |
◆ writeXMLData()
| void BARE2D::XMLDataManager::writeXMLData |
( |
std::ofstream & |
file, |
|
|
Cache< unsigned int, XMLData > * |
data |
|
) |
| |
|
staticprivate |
◆ XMLData
◆ m_dataTypingFunctions
| std::unordered_map< std::string, std::function< XMLData *()> > BARE2D::XMLDataManager::m_dataTypingFunctions |
|
staticprivate |
◆ m_storedData
| Cache< std::string, Cache< unsigned int, XMLData > > BARE2D::XMLDataManager::m_storedData |
|
staticprivate |
The documentation for this class was generated from the following files: