4 * Copyright (C) 2005-2013 Team XBMC
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)
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.
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/>.
23 #include "utils/StdString.h"
24 #include "utils/XBMCTinyXML.h"
31 static bool HasUTF8Declaration(const CStdString &strXML);
32 static bool HasChild(const TiXmlNode* pRootNode, const char* strTag);
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.
45 <tag clear="true">value2</tag>
48 into value2<sep>...<sep>valuen, appending it to the value string. Note that <value1> is overwritten by the clear="true" tag.
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.
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);
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);
78 static const int path_version = 1;