[windows] Fix MAC Address Discovery
[xbmc.git] / xbmc / filesystem / DAVCommon.cpp
blobed2597c74bd6d5e7524773fe0e4764c5002dabbf
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 #include "DAVCommon.h"
11 #include "utils/StringUtils.h"
12 #include "utils/log.h"
14 #include <tinyxml2.h>
16 using namespace XFILE;
19 * Return true if pElement value is equal value without namespace.
21 * if pElement is <DAV:foo> and value is foo then ValueWithoutNamespace is true
23 bool CDAVCommon::ValueWithoutNamespace(const tinyxml2::XMLNode* node, const std::string& value)
25 if (!node)
27 return false;
30 auto* element = node->ToElement();
32 if (!element)
34 return false;
37 std::vector<std::string> tag = StringUtils::Split(element->Value(), ":", 2);
39 if (tag.size() == 1 && tag[0] == value)
41 return true;
43 else if (tag.size() == 2 && tag[1] == value)
45 return true;
47 else if (tag.size() > 2)
49 CLog::LogF(LOGERROR, "Splitting {} failed, size(): {}, value: {}", element->Value(), tag.size(),
50 value);
53 return false;
57 * Search for <status> and return its content
59 std::string CDAVCommon::GetStatusTag(const tinyxml2::XMLElement* element)
61 for (auto* child = element->FirstChildElement(); child; child = child->NextSiblingElement())
63 if (ValueWithoutNamespace(child, "status"))
65 return child->NoChildren() ? "" : child->FirstChild()->Value();
69 return "";