tag.cpp
Go to the documentation of this file.
1 #include "tag.h"
2 #include "directives.h"
3 #include "token.h"
4 #include <cassert>
5 #include <stdexcept>
6 
7 namespace YAML_PM
8 {
9  Tag::Tag(const Token& token): type(static_cast<TYPE>(token.data))
10  {
11  switch(type) {
12  case VERBATIM:
13  value = token.value;
14  break;
15  case PRIMARY_HANDLE:
16  value = token.value;
17  break;
18  case SECONDARY_HANDLE:
19  value = token.value;
20  break;
21  case NAMED_HANDLE:
22  handle = token.value;
23  value = token.params[0];
24  break;
25  case NON_SPECIFIC:
26  break;
27  default:
28  assert(false);
29  }
30  }
31 
32  const std::string Tag::Translate(const Directives& directives)
33  {
34  switch(type) {
35  case VERBATIM:
36  return value;
37  case PRIMARY_HANDLE:
38  return directives.TranslateTagHandle("!") + value;
39  case SECONDARY_HANDLE:
40  return directives.TranslateTagHandle("!!") + value;
41  case NAMED_HANDLE:
42  return directives.TranslateTagHandle("!" + handle + "!") + value;
43  case NON_SPECIFIC:
44  // TODO:
45  return "!";
46  default:
47  assert(false);
48  }
49  throw std::runtime_error("yaml-cpp: internal error, bad tag type");
50  }
51 }
52 
TYPE type
Definition: tag.h:23
::std::string string
Definition: gtest.h:1979
data
Definition: icp.py:50
std::string value
Definition: tag.h:24
Tag(const Token &token)
Definition: tag.cpp:9
std::vector< std::string > params
Definition: token.h:80
std::string handle
Definition: tag.h:24
const std::string Translate(const Directives &directives)
Definition: tag.cpp:32
const std::string TranslateTagHandle(const std::string &handle) const
Definition: directives.cpp:13
std::string value
Definition: token.h:79


libpointmatcher
Author(s):
autogenerated on Sat May 27 2023 02:38:03