xbmc
XMLUtils.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "utils/XBMCTinyXML.h"
12 
13 #include <stdint.h>
14 #include <string>
15 #include <vector>
16 
17 class CDateTime;
18 
19 class XMLUtils
20 {
21 public:
22  static bool HasChild(const TiXmlNode* pRootNode, const char* strTag);
23 
24  static bool GetHex(const TiXmlNode* pRootNode, const char* strTag, uint32_t& dwHexValue);
25  static bool GetUInt(const TiXmlNode* pRootNode, const char* strTag, uint32_t& dwUIntValue);
26  static bool GetLong(const TiXmlNode* pRootNode, const char* strTag, long& lLongValue);
27  static bool GetFloat(const TiXmlNode* pRootNode, const char* strTag, float& value);
28  static bool GetDouble(const TiXmlNode* pRootNode, const char* strTag, double& value);
29  static bool GetInt(const TiXmlNode* pRootNode, const char* strTag, int& iIntValue);
30  static bool GetBoolean(const TiXmlNode* pRootNode, const char* strTag, bool& bBoolValue);
31 
41  static bool GetString(const TiXmlNode* pRootNode, const char* strTag, std::string& strStringValue);
42 
50  static std::string GetString(const TiXmlNode* pRootNode, const char* strTag);
65  static bool GetAdditiveString(const TiXmlNode* rootNode, const char* tag, const std::string& separator, std::string& value, bool clear = false);
66  static bool GetStringArray(const TiXmlNode* rootNode, const char* tag, std::vector<std::string>& arrayValue, bool clear = false, const std::string& separator = "");
67  static bool GetPath(const TiXmlNode* pRootNode, const char* strTag, std::string& strStringValue);
68  static bool GetFloat(const TiXmlNode* pRootNode, const char* strTag, float& value, const float min, const float max);
69  static bool GetUInt(const TiXmlNode* pRootNode, const char* strTag, uint32_t& dwUIntValue, const uint32_t min, const uint32_t max);
70  static bool GetInt(const TiXmlNode* pRootNode, const char* strTag, int& iIntValue, const int min, const int max);
71  static bool GetDate(const TiXmlNode* pRootNode, const char* strTag, CDateTime& date);
72  static bool GetDateTime(const TiXmlNode* pRootNode, const char* strTag, CDateTime& dateTime);
78  static std::string GetAttribute(const TiXmlElement *element, const char *tag);
79 
80  static TiXmlNode* SetString(TiXmlNode* pRootNode, const char *strTag, const std::string& strValue);
81  static void SetAdditiveString(TiXmlNode* pRootNode, const char *strTag, const std::string& strSeparator, const std::string& strValue);
82  static void SetStringArray(TiXmlNode* pRootNode, const char *strTag, const std::vector<std::string>& arrayValue);
83  static TiXmlNode* SetInt(TiXmlNode* pRootNode, const char *strTag, int value);
84  static TiXmlNode* SetFloat(TiXmlNode* pRootNode, const char *strTag, float value);
85  static TiXmlNode* SetDouble(TiXmlNode* pRootNode, const char* strTag, double value);
86  static void SetBoolean(TiXmlNode* pRootNode, const char *strTag, bool value);
87  static void SetHex(TiXmlNode* pRootNode, const char *strTag, uint32_t value);
88  static void SetPath(TiXmlNode* pRootNode, const char *strTag, const std::string& strValue);
89  static void SetLong(TiXmlNode* pRootNode, const char *strTag, long iValue);
90  static void SetDate(TiXmlNode* pRootNode, const char *strTag, const CDateTime& date);
91  static void SetDateTime(TiXmlNode* pRootNode, const char *strTag, const CDateTime& dateTime);
92 
93  static const int path_version = 1;
94 };
95 
static bool GetString(const TiXmlNode *pRootNode, const char *strTag, std::string &strStringValue)
Get a string value from the xml tag If the specified tag isn&#39;t found strStringvalue is not modified a...
Definition: XMLUtils.cpp:113
Definition: XMLUtils.h:19
static bool GetStringArray(const TiXmlNode *rootNode, const char *tag, std::vector< std::string > &arrayValue, bool clear=false, const std::string &separator="")
Definition: XMLUtils.cpp:177
static std::string GetAttribute(const TiXmlElement *element, const char *tag)
Fetch a std::string copy of an attribute, if it exists. Cannot distinguish between empty and non-exis...
Definition: XMLUtils.cpp:254
static bool GetAdditiveString(const TiXmlNode *rootNode, const char *tag, const std::string &separator, std::string &value, bool clear=false)
Get multiple tags, concatenating the values together. Transforms <tag>value1</tag> <tag clear="true">...
Definition: XMLUtils.cpp:146
DateTime class, which uses FileTime as it&#39;s base.
Definition: XBDateTime.h:63