token.h
Go to the documentation of this file.
1 #ifndef TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
2 #define TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
3 
4 #if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
5 #pragma once
6 #endif
7 
8 
9 #include "yaml-cpp-pm/mark.h"
10 #include <iostream>
11 #include <string>
12 #include <vector>
13 
14 namespace YAML_PM
15 {
16  const std::string TokenNames[] = {
17  "DIRECTIVE",
18  "DOC_START",
19  "DOC_END",
20  "BLOCK_SEQ_START",
21  "BLOCK_MAP_START",
22  "BLOCK_SEQ_END",
23  "BLOCK_MAP_END",
24  "BLOCK_ENTRY",
25  "FLOW_SEQ_START",
26  "FLOW_MAP_START",
27  "FLOW_SEQ_END",
28  "FLOW_MAP_END",
29  "FLOW_MAP_COMPACT",
30  "FLOW_ENTRY",
31  "KEY",
32  "VALUE",
33  "ANCHOR",
34  "ALIAS",
35  "TAG",
36  "SCALAR"
37  };
38 
39  struct Token {
40  // enums
42  enum TYPE {
57  KEY,
61  TAG,
64  };
65 
66  // data
67  Token(TYPE type_, const Mark& mark_): status(VALID), type(type_), mark(mark_), data(0) {}
68 
69  friend std::ostream& operator << (std::ostream& out, const Token& token) {
70  out << TokenNames[token.type] << std::string(": ") << token.value;
71  for(std::size_t i=0;i<token.params.size();i++)
72  out << std::string(" ") << token.params[i];
73  return out;
74  }
75 
80  std::vector <std::string> params;
81  int data;
82  };
83 }
84 
85 #endif // TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
friend std::ostream & operator<<(std::ostream &out, const Token &token)
Definition: token.h:69
const std::string TokenNames[]
Definition: token.h:16
::std::string string
Definition: gtest.h:1979
Mark mark
Definition: token.h:78
Token(TYPE type_, const Mark &mark_)
Definition: token.h:67
std::vector< std::string > params
Definition: token.h:80
int data
Definition: token.h:81
std::string value
Definition: token.h:79
TYPE type
Definition: token.h:77
STATUS status
Definition: token.h:76


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