return bResult;
}
-/*!
- Returns true if the encoding of the document is other then UTF-8.
- /param strEncoding Returns the encoding of the document. Empty if UTF-8
-*/
-bool XMLUtils::GetEncoding(const CXBMCTinyXML* pDoc, CStdString& strEncoding)
-{
- const TiXmlNode* pNode=NULL;
- while ((pNode=pDoc->IterateChildren(pNode)) && pNode->Type()!=TiXmlNode::TINYXML_DECLARATION) {}
- if (!pNode) return false;
- const TiXmlDeclaration* pDecl=pNode->ToDeclaration();
- if (!pDecl) return false;
- strEncoding=pDecl->Encoding();
- if (strEncoding.Equals("UTF-8") || strEncoding.Equals("UTF8")) strEncoding.Empty();
- strEncoding.MakeUpper();
- return !strEncoding.IsEmpty(); // Other encoding then UTF8?
-}
-
-/*!
- Returns true if the encoding of the document is specified as as UTF-8
- /param strXML The XML file (embedded in a string) to check.
-*/
-bool XMLUtils::HasUTF8Declaration(const CStdString &strXML)
-{
- CStdString test = strXML;
- test.ToLower();
- // test for the encoding="utf-8" string
- if (test.Find("encoding=\"utf-8\"") >= 0)
- return true;
- // TODO: test for plain UTF8 here?
- return false;
-}
-
bool XMLUtils::GetPath(const TiXmlNode* pRootNode, const char* strTag, CStdString& strStringValue)
{
const TiXmlElement* pElement = pRootNode->FirstChildElement(strTag);
class XMLUtils
{
public:
- static bool HasUTF8Declaration(const CStdString &strXML);
static bool HasChild(const TiXmlNode* pRootNode, const char* strTag);
static bool GetHex(const TiXmlNode* pRootNode, const char* strTag, uint32_t& dwHexValue);
*/
static bool GetAdditiveString(const TiXmlNode* rootNode, const char* tag, const CStdString& separator, CStdString& value, bool clear = false);
static bool GetStringArray(const TiXmlNode* rootNode, const char* tag, std::vector<std::string>& arrayValue, bool clear = false, const std::string& separator = "");
- static bool GetEncoding(const CXBMCTinyXML* pDoc, CStdString& strEncoding);
static bool GetPath(const TiXmlNode* pRootNode, const char* strTag, CStdString& strStringValue);
static bool GetFloat(const TiXmlNode* pRootNode, const char* strTag, float& value, const float min, const float max);
static bool GetUInt(const TiXmlNode* pRootNode, const char* strTag, uint32_t& dwUIntValue, const uint32_t min, const uint32_t max);