revert changes in methods bodies

This commit is contained in:
hyperxor 2022-06-01 01:14:59 +03:00
parent 56f39208a5
commit 7d1c3763d0
2 changed files with 11 additions and 24 deletions

View File

@ -3,19 +3,15 @@
namespace YAML { namespace YAML {
Directives::Directives() : version{true, 1, 2}, tags{} {} Directives::Directives() : version{true, 1, 2}, tags{} {}
std::string Directives::TranslateTagHandle( const std::string Directives::TranslateTagHandle(
const std::string& handle) const { const std::string& handle) const {
std::string result;
auto it = tags.find(handle); auto it = tags.find(handle);
if (it == tags.end()) { if (it == tags.end()) {
if (handle == "!!") if (handle == "!!")
result = "tag:yaml.org,2002:"; return "tag:yaml.org,2002:";
else return handle;
result = handle;
} else {
result = it->second;
} }
return result; return it->second;
} }
} // namespace YAML } // namespace YAML

View File

@ -29,31 +29,22 @@ Tag::Tag(const Token& token)
} }
} }
std::string Tag::Translate(const Directives& directives) { const std::string Tag::Translate(const Directives& directives) {
std::string result;
switch (type) { switch (type) {
case VERBATIM: case VERBATIM:
result = value; return value;
break;
case PRIMARY_HANDLE: case PRIMARY_HANDLE:
result = directives.TranslateTagHandle("!") + value; return directives.TranslateTagHandle("!") + value;
break;
case SECONDARY_HANDLE: case SECONDARY_HANDLE:
result = directives.TranslateTagHandle("!!") + value; return directives.TranslateTagHandle("!!") + value;
break;
case NAMED_HANDLE: case NAMED_HANDLE:
result = directives.TranslateTagHandle("!" + handle + "!") + value; return directives.TranslateTagHandle("!" + handle + "!") + value;
break;
case NON_SPECIFIC: case NON_SPECIFIC:
// TODO: // TODO:
result = "!"; return "!";
break;
default: default:
assert(false); assert(false);
throw std::runtime_error("yaml-cpp: internal error, bad tag type");
} }
throw std::runtime_error("yaml-cpp: internal error, bad tag type");
return result;
} }
} // namespace YAML } // namespace YAML