mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 04:41:16 +00:00
Run clang-format
This commit is contained in:
84
src/tag.cpp
84
src/tag.cpp
@@ -4,49 +4,45 @@
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
Tag::Tag(const Token& token): type(static_cast<TYPE>(token.data))
|
||||
{
|
||||
switch(type) {
|
||||
case VERBATIM:
|
||||
value = token.value;
|
||||
break;
|
||||
case PRIMARY_HANDLE:
|
||||
value = token.value;
|
||||
break;
|
||||
case SECONDARY_HANDLE:
|
||||
value = token.value;
|
||||
break;
|
||||
case NAMED_HANDLE:
|
||||
handle = token.value;
|
||||
value = token.params[0];
|
||||
break;
|
||||
case NON_SPECIFIC:
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
const std::string Tag::Translate(const Directives& directives)
|
||||
{
|
||||
switch(type) {
|
||||
case VERBATIM:
|
||||
return value;
|
||||
case PRIMARY_HANDLE:
|
||||
return directives.TranslateTagHandle("!") + value;
|
||||
case SECONDARY_HANDLE:
|
||||
return directives.TranslateTagHandle("!!") + value;
|
||||
case NAMED_HANDLE:
|
||||
return directives.TranslateTagHandle("!" + handle + "!") + value;
|
||||
case NON_SPECIFIC:
|
||||
// TODO:
|
||||
return "!";
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
throw std::runtime_error("yaml-cpp: internal error, bad tag type");
|
||||
}
|
||||
namespace YAML {
|
||||
Tag::Tag(const Token& token) : type(static_cast<TYPE>(token.data)) {
|
||||
switch (type) {
|
||||
case VERBATIM:
|
||||
value = token.value;
|
||||
break;
|
||||
case PRIMARY_HANDLE:
|
||||
value = token.value;
|
||||
break;
|
||||
case SECONDARY_HANDLE:
|
||||
value = token.value;
|
||||
break;
|
||||
case NAMED_HANDLE:
|
||||
handle = token.value;
|
||||
value = token.params[0];
|
||||
break;
|
||||
case NON_SPECIFIC:
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
const std::string Tag::Translate(const Directives& directives) {
|
||||
switch (type) {
|
||||
case VERBATIM:
|
||||
return value;
|
||||
case PRIMARY_HANDLE:
|
||||
return directives.TranslateTagHandle("!") + value;
|
||||
case SECONDARY_HANDLE:
|
||||
return directives.TranslateTagHandle("!!") + value;
|
||||
case NAMED_HANDLE:
|
||||
return directives.TranslateTagHandle("!" + handle + "!") + value;
|
||||
case NON_SPECIFIC:
|
||||
// TODO:
|
||||
return "!";
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
throw std::runtime_error("yaml-cpp: internal error, bad tag type");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user