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 {
Directives::Directives() : version{true, 1, 2}, tags{} {}
std::string Directives::TranslateTagHandle(
const std::string Directives::TranslateTagHandle(
const std::string& handle) const {
std::string result;
auto it = tags.find(handle);
if (it == tags.end()) {
if (handle == "!!")
result = "tag:yaml.org,2002:";
else
result = handle;
} else {
result = it->second;
return "tag:yaml.org,2002:";
return handle;
}
return result;
return it->second;
}
} // namespace YAML

View File

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