scide: implement selectionLength for openDocument
[supercollider.git] / external_libraries / yaml-cpp-0.3.0 / src / tag.cpp
blob82a47047768b281bc7bd81bed66d80908c6ee988
1 #include "tag.h"
2 #include "directives.h"
3 #include "token.h"
4 #include <cassert>
5 #include <stdexcept>
7 namespace YAML
9 Tag::Tag(const Token& token): type(static_cast<TYPE>(token.data))
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);
32 const std::string Tag::Translate(const Directives& directives)
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);
49 throw std::runtime_error("yaml-cpp: internal error, bad tag type");