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 
YAML_PM::Tag::SECONDARY_HANDLE
@ SECONDARY_HANDLE
Definition: tag.h:17
YAML_PM::Tag::type
TYPE type
Definition: tag.h:23
YAML_PM
Definition: aliasmanager.h:11
YAML_PM::Directives
Definition: directives.h:19
YAML_PM::Token::params
std::vector< std::string > params
Definition: token.h:80
YAML_PM::Tag::TYPE
TYPE
Definition: tag.h:16
YAML_PM::Token::value
std::string value
Definition: token.h:79
directives.h
testing::internal::string
::std::string string
Definition: gtest.h:1979
YAML_PM::Tag::value
std::string value
Definition: tag.h:24
YAML_PM::Tag::PRIMARY_HANDLE
@ PRIMARY_HANDLE
Definition: tag.h:17
YAML_PM::Tag::NAMED_HANDLE
@ NAMED_HANDLE
Definition: tag.h:17
YAML_PM::Tag::NON_SPECIFIC
@ NON_SPECIFIC
Definition: tag.h:17
YAML_PM::Tag::VERBATIM
@ VERBATIM
Definition: tag.h:17
YAML_PM::Directives::TranslateTagHandle
const std::string TranslateTagHandle(const std::string &handle) const
Definition: directives.cpp:13
tag.h
YAML_PM::Tag::Translate
const std::string Translate(const Directives &directives)
Definition: tag.cpp:32
YAML_PM::Token
Definition: token.h:39
YAML_PM::Tag::Tag
Tag(const Token &token)
Definition: tag.cpp:9
token.h
YAML_PM::Tag::handle
std::string handle
Definition: tag.h:24


mrpt_local_obstacles
Author(s): Jose-Luis Blanco-Claraco
autogenerated on Mon Aug 14 2023 02:09:04