Changeset View
Changeset View
Standalone View
Standalone View
source/tools/atlas/AtlasObject/AtlasObjectText.cpp
Show All 26 Lines | static std::wstring ConvertRecursive(const AtNode::Ptr obj, bool use_brackets = true) | ||||
// resulting in data-loss [because of the key names], and a rather arbitrary | // resulting in data-loss [because of the key names], and a rather arbitrary | ||||
// [alphabetical by key] ordering of children, but at least it's fairly readable | // [alphabetical by key] ordering of children, but at least it's fairly readable | ||||
if (! obj) | if (! obj) | ||||
return L""; | return L""; | ||||
std::wstring result; | std::wstring result; | ||||
bool has_value = (obj->value.length() != 0); | bool has_value = (obj->m_Value.length() != 0); | ||||
bool has_children = (obj->children.size() != 0); | bool has_children = (obj->m_Children.size() != 0); | ||||
vladislavbelov: I suppose `(obj->m_Value.length() != 0)` > `!obj->m_Value.empty()` (without parenthesis too). | |||||
if (has_value && has_children) | if (has_value && has_children) | ||||
result = obj->value + L" "; | result = obj->m_Value + L" "; | ||||
else if (has_value) | else if (has_value) | ||||
result = obj->value; | result = obj->m_Value; | ||||
// else no value; result = L"" | // else no value; result = L"" | ||||
if (has_children) | if (has_children) | ||||
{ | { | ||||
if (use_brackets) | if (use_brackets) | ||||
result += L"("; | result += L"("; | ||||
bool first_child = true; // so we can add ", " in appropriate places | bool first_child = true; // so we can add ", " in appropriate places | ||||
for (AtNode::child_maptype::const_iterator it = obj->children.begin(); | for (AtNode::child_maptype::const_iterator it = obj->m_Children.begin(); | ||||
it != obj->children.end(); | it != obj->m_Children.end(); | ||||
++it) | ++it) | ||||
{ | { | ||||
if (! first_child) | if (! first_child) | ||||
result += L", "; | result += L", "; | ||||
else | else | ||||
first_child = false; | first_child = false; | ||||
result += ConvertRecursive(it->second); | result += ConvertRecursive(it->second); | ||||
} | } | ||||
if (use_brackets) | if (use_brackets) | ||||
result += L")"; | result += L")"; | ||||
} | } | ||||
return result; | return result; | ||||
} | } | ||||
std::wstring AtlasObject::ConvertToString(const AtObj& obj) | std::wstring AtlasObject::ConvertToString(const AtObj& obj) | ||||
{ | { | ||||
return ConvertRecursive(obj.p, false); | return ConvertRecursive(obj.m_P, false); | ||||
} | } |
Wildfire Games · Phabricator
I suppose (obj->m_Value.length() != 0) > !obj->m_Value.empty() (without parenthesis too). The same below.