[PVR][Estuary] Timer settings dialog: Show client name in timer type selection dialog...
[xbmc.git] / xbmc / utils / XMLUtils.h
blobfcd23bdb7f4e6d2760d98519c838d338bae7fec2
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "utils/XBMCTinyXML.h"
13 #include <stdint.h>
14 #include <string>
15 #include <vector>
17 class CDateTime;
19 class XMLUtils
21 public:
22 static bool HasChild(const TiXmlNode* pRootNode, const char* strTag);
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);
32 /*! \brief Get a string value from the xml tag
33 If the specified tag isn't found strStringvalue is not modified and will contain whatever
34 value it had before the method call.
36 \param[in] pRootNode the xml node that contains the tag
37 \param[in] strTag the xml tag to read from
38 \param[in,out] strStringValue where to store the read string
39 \return true on success, false if the tag isn't found
41 static bool GetString(const TiXmlNode* pRootNode, const char* strTag, std::string& strStringValue);
43 /*! \brief Get a string value from the xml tag
45 \param[in] pRootNode the xml node that contains the tag
46 \param[in] strTag the tag to read from
48 \return the value in the specified tag or an empty string if the tag isn't found
50 static std::string GetString(const TiXmlNode* pRootNode, const char* strTag);
51 /*! \brief Get multiple tags, concatenating the values together.
52 Transforms
53 <tag>value1</tag>
54 <tag clear="true">value2</tag>
55 ...
56 <tag>valuen</tag>
57 into value2<sep>...<sep>valuen, appending it to the value string. Note that <value1> is overwritten by the clear="true" tag.
59 \param rootNode the parent containing the <tag>'s.
60 \param tag the <tag> in question.
61 \param separator the separator to use when concatenating values.
62 \param value [out] the resulting string. Remains untouched if no <tag> is available, else is appended (or cleared based on the clear parameter).
63 \param clear if true, clears the string prior to adding tags, if tags are available. Defaults to false.
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);
73 /*! \brief Fetch a std::string copy of an attribute, if it exists. Cannot distinguish between empty and non-existent attributes.
74 \param element the element to query.
75 \param tag the name of the attribute.
76 \return the attribute, if it exists, else an empty string
78 static std::string GetAttribute(const TiXmlElement *element, const char *tag);
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);
93 static const int path_version = 1;