token.h
Go to the documentation of this file.
00001 #ifndef TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66
00002 #define TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66
00003 
00004 #if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
00005 #pragma once
00006 #endif
00007 
00008 
00009 #include "yaml-cpp-pm/mark.h"
00010 #include <iostream>
00011 #include <string>
00012 #include <vector>
00013 
00014 namespace YAML_PM
00015 {
00016         const std::string TokenNames[] = {
00017                 "DIRECTIVE",
00018                 "DOC_START",
00019                 "DOC_END",
00020                 "BLOCK_SEQ_START",
00021                 "BLOCK_MAP_START",
00022                 "BLOCK_SEQ_END",
00023                 "BLOCK_MAP_END",
00024                 "BLOCK_ENTRY",
00025                 "FLOW_SEQ_START",
00026                 "FLOW_MAP_START",
00027                 "FLOW_SEQ_END",
00028                 "FLOW_MAP_END",
00029                 "FLOW_MAP_COMPACT",
00030                 "FLOW_ENTRY",
00031                 "KEY",
00032                 "VALUE",
00033                 "ANCHOR",
00034                 "ALIAS",
00035                 "TAG",
00036                 "SCALAR"
00037         };
00038 
00039         struct Token {
00040                 // enums
00041                 enum STATUS { VALID, INVALID, UNVERIFIED };
00042                 enum TYPE {
00043                         DIRECTIVE,
00044                         DOC_START,
00045                         DOC_END,
00046                         BLOCK_SEQ_START,
00047                         BLOCK_MAP_START,
00048                         BLOCK_SEQ_END,
00049                         BLOCK_MAP_END,
00050                         BLOCK_ENTRY,
00051                         FLOW_SEQ_START,
00052                         FLOW_MAP_START,
00053                         FLOW_SEQ_END,
00054                         FLOW_MAP_END,
00055                         FLOW_MAP_COMPACT,
00056                         FLOW_ENTRY,
00057                         KEY,
00058                         VALUE,
00059                         ANCHOR,
00060                         ALIAS,
00061                         TAG,
00062                         PLAIN_SCALAR,
00063                         NON_PLAIN_SCALAR
00064                 };
00065 
00066                 // data
00067                 Token(TYPE type_, const Mark& mark_): status(VALID), type(type_), mark(mark_), data(0) {}
00068 
00069                 friend std::ostream& operator << (std::ostream& out, const Token& token) {
00070                         out << TokenNames[token.type] << std::string(": ") << token.value;
00071                         for(std::size_t i=0;i<token.params.size();i++)
00072                                 out << std::string(" ") << token.params[i];
00073                         return out;
00074                 }
00075 
00076                 STATUS status;
00077                 TYPE type;
00078                 Mark mark;
00079                 std::string value;
00080                 std::vector <std::string> params;
00081                 int data;
00082         };
00083 }
00084 
00085 #endif // TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66


upstream_src
Author(s):
autogenerated on Mon Oct 6 2014 10:27:42