MCPcopy Create free account
hub / github.com/MyGUI/mygui / convert_from_xml

Function convert_from_xml

MyGUIEngine/src/MyGUI_XmlDocument.cpp:16–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14 namespace utility
15 {
16 static std::string convert_from_xml(std::string_view _string, bool& _ok)
17 {
18 std::string ret;
19 _ok = true;
20
21 size_t pos = _string.find('&');
22 if (pos == std::string::npos)
23 return std::string{_string};
24
25 ret.reserve(_string.size());
26 size_t old = 0;
27 while (pos != std::string::npos)
28 {
29 ret += _string.substr(old, pos - old);
30
31 size_t end = _string.find(';', pos + 1);
32 if (end == std::string::npos)
33 {
34 _ok = false;
35 return ret;
36 }
37
38 std::string_view tag = _string.substr(pos, end - pos + 1);
39 if (tag == "&")
40 ret += '&';
41 else if (tag == "<")
42 ret += '<';
43 else if (tag == "&gt;")
44 ret += '>';
45 else if (tag == "&apos;")
46 ret += '\'';
47 else if (tag == "&quot;")
48 ret += '\"';
49 else
50 {
51 _ok = false;
52 return ret;
53 }
54
55 old = end + 1;
56 pos = _string.find('&', old);
57 }
58 ret += _string.substr(old, std::string::npos);
59
60 return ret;
61 }
62
63 static std::string convert_to_xml(std::string_view _string)
64 {

Callers 2

checkPairMethod · 0.85
parseLineMethod · 0.85

Calls 4

substrMethod · 0.80
findMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected