[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / utils / XMLUtils.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://www.xbmc.org
6  *
7  *  This Program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  This Program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with XBMC; see the file COPYING.  If not, see
19  *  <http://www.gnu.org/licenses/>.
20  *
21  */
22
23 #include "utils/StdString.h"
24 #include "utils/XBMCTinyXML.h"
25
26 class CDateTime;
27
28 class XMLUtils
29 {
30 public:
31   static bool HasUTF8Declaration(const CStdString &strXML);
32   static bool HasChild(const TiXmlNode* pRootNode, const char* strTag);
33
34   static bool GetHex(const TiXmlNode* pRootNode, const char* strTag, uint32_t& dwHexValue);
35   static bool GetUInt(const TiXmlNode* pRootNode, const char* strTag, uint32_t& dwUIntValue);
36   static bool GetLong(const TiXmlNode* pRootNode, const char* strTag, long& lLongValue);
37   static bool GetFloat(const TiXmlNode* pRootNode, const char* strTag, float& value);
38   static bool GetDouble(const TiXmlNode* pRootNode, const char* strTag, double &value);
39   static bool GetInt(const TiXmlNode* pRootNode, const char* strTag, int& iIntValue);
40   static bool GetBoolean(const TiXmlNode* pRootNode, const char* strTag, bool& bBoolValue);
41   static bool GetString(const TiXmlNode* pRootNode, const char* strTag, CStdString& strStringValue);
42   /*! \brief Get multiple tags, concatenating the values together.
43    Transforms
44      <tag>value1</tag>
45      <tag clear="true">value2</tag>
46      ...
47      <tag>valuen</tag>
48    into value2<sep>...<sep>valuen, appending it to the value string. Note that <value1> is overwritten by the clear="true" tag.
49
50    \param rootNode    the parent containing the <tag>'s.
51    \param tag         the <tag> in question.
52    \param separator   the separator to use when concatenating values.
53    \param value [out] the resulting string. Remains untouched if no <tag> is available, else is appended (or cleared based on the clear parameter).
54    \param clear       if true, clears the string prior to adding tags, if tags are available. Defaults to false.
55    */
56   static bool GetAdditiveString(const TiXmlNode* rootNode, const char* tag, const CStdString& separator, CStdString& value, bool clear = false);
57   static bool GetStringArray(const TiXmlNode* rootNode, const char* tag, std::vector<std::string>& arrayValue, bool clear = false, const std::string separator = "");
58   static bool GetEncoding(const CXBMCTinyXML* pDoc, CStdString& strEncoding);
59   static bool GetPath(const TiXmlNode* pRootNode, const char* strTag, CStdString& strStringValue);
60   static bool GetFloat(const TiXmlNode* pRootNode, const char* strTag, float& value, const float min, const float max);
61   static bool GetUInt(const TiXmlNode* pRootNode, const char* strTag, uint32_t& dwUIntValue, const uint32_t min, const uint32_t max);
62   static bool GetInt(const TiXmlNode* pRootNode, const char* strTag, int& iIntValue, const int min, const int max);
63   static bool GetDate(const TiXmlNode* pRootNode, const char* strTag, CDateTime& date);
64   static bool GetDateTime(const TiXmlNode* pRootNode, const char* strTag, CDateTime& dateTime);
65
66   static void SetString(TiXmlNode* pRootNode, const char *strTag, const CStdString& strValue);
67   static void SetAdditiveString(TiXmlNode* pRootNode, const char *strTag, const CStdString& strSeparator, const CStdString& strValue);
68   static void SetStringArray(TiXmlNode* pRootNode, const char *strTag, const std::vector<std::string>& arrayValue);
69   static void SetInt(TiXmlNode* pRootNode, const char *strTag, int value);
70   static void SetFloat(TiXmlNode* pRootNode, const char *strTag, float value);
71   static void SetBoolean(TiXmlNode* pRootNode, const char *strTag, bool value);
72   static void SetHex(TiXmlNode* pRootNode, const char *strTag, uint32_t value);
73   static void SetPath(TiXmlNode* pRootNode, const char *strTag, const CStdString& strValue);
74   static void SetLong(TiXmlNode* pRootNode, const char *strTag, long iValue);
75   static void SetDate(TiXmlNode* pRootNode, const char *strTag, const CDateTime& date);
76   static void SetDateTime(TiXmlNode* pRootNode, const char *strTag, const CDateTime& dateTime);
77
78   static const int path_version = 1;
79 };
80