tag.cpp
Go to the documentation of this file.
00001 #include "tag.h"
00002 #include "directives.h"
00003 #include "token.h"
00004 #include <cassert>
00005 #include <stdexcept>
00006 
00007 namespace YAML_PM
00008 {
00009         Tag::Tag(const Token& token): type(static_cast<TYPE>(token.data))
00010         {
00011                 switch(type) {
00012                         case VERBATIM:
00013                                 value = token.value;
00014                                 break;
00015                         case PRIMARY_HANDLE:
00016                                 value = token.value;
00017                                 break;
00018                         case SECONDARY_HANDLE:
00019                                 value = token.value;
00020                                 break;
00021                         case NAMED_HANDLE:
00022                                 handle = token.value;
00023                                 value = token.params[0];
00024                                 break;
00025                         case NON_SPECIFIC:
00026                                 break;
00027                         default:
00028                                 assert(false);
00029                 }
00030         }
00031 
00032         const std::string Tag::Translate(const Directives& directives)
00033         {
00034                 switch(type) {
00035                         case VERBATIM:
00036                                 return value;
00037                         case PRIMARY_HANDLE:
00038                                 return directives.TranslateTagHandle("!") + value;
00039                         case SECONDARY_HANDLE:
00040                                 return directives.TranslateTagHandle("!!") + value;
00041                         case NAMED_HANDLE:
00042                                 return directives.TranslateTagHandle("!" + handle + "!") + value;
00043                         case NON_SPECIFIC:
00044                                 // TODO:
00045                                 return "!";
00046                         default:
00047                                 assert(false);
00048                 }
00049                 throw std::runtime_error("yaml-cpp: internal error, bad tag type");
00050         }
00051 }
00052 


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