remove button colors from quarks gui (cocoa + swing)
[supercollider.git] / external_libraries / yaml-cpp-0.2.6 / include / yaml-cpp / exceptions.h
blobe9404997309e926cfcd61ba3d314ca3d6856f7f5
1 #ifndef EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
2 #define EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
4 #if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4
5 #pragma once
6 #endif
9 #include "yaml-cpp/mark.h"
10 #include "yaml-cpp/traits.h"
11 #include <stdexcept>
12 #include <string>
13 #include <sstream>
15 namespace YAML
17 // error messages
18 namespace ErrorMsg
20 const char * const YAML_DIRECTIVE_ARGS = "YAML directives must have exactly one argument";
21 const char * const YAML_VERSION = "bad YAML version: ";
22 const char * const YAML_MAJOR_VERSION = "YAML major version too large";
23 const char * const REPEATED_YAML_DIRECTIVE= "repeated YAML directive";
24 const char * const TAG_DIRECTIVE_ARGS = "TAG directives must have exactly two arguments";
25 const char * const REPEATED_TAG_DIRECTIVE = "repeated TAG directive";
26 const char * const CHAR_IN_TAG_HANDLE = "illegal character found while scanning tag handle";
27 const char * const TAG_WITH_NO_SUFFIX = "tag handle with no suffix";
28 const char * const END_OF_VERBATIM_TAG = "end of verbatim tag not found";
29 const char * const END_OF_MAP = "end of map not found";
30 const char * const END_OF_MAP_FLOW = "end of map flow not found";
31 const char * const END_OF_SEQ = "end of sequence not found";
32 const char * const END_OF_SEQ_FLOW = "end of sequence flow not found";
33 const char * const MULTIPLE_TAGS = "cannot assign multiple tags to the same node";
34 const char * const MULTIPLE_ANCHORS = "cannot assign multiple anchors to the same node";
35 const char * const MULTIPLE_ALIASES = "cannot assign multiple aliases to the same node";
36 const char * const ALIAS_CONTENT = "aliases can't have any content, *including* tags";
37 const char * const INVALID_HEX = "bad character found while scanning hex number";
38 const char * const INVALID_UNICODE = "invalid unicode: ";
39 const char * const INVALID_ESCAPE = "unknown escape character: ";
40 const char * const UNKNOWN_TOKEN = "unknown token";
41 const char * const DOC_IN_SCALAR = "illegal document indicator in scalar";
42 const char * const EOF_IN_SCALAR = "illegal EOF in scalar";
43 const char * const CHAR_IN_SCALAR = "illegal character in scalar";
44 const char * const TAB_IN_INDENTATION = "illegal tab when looking for indentation";
45 const char * const FLOW_END = "illegal flow end";
46 const char * const BLOCK_ENTRY = "illegal block entry";
47 const char * const MAP_KEY = "illegal map key";
48 const char * const MAP_VALUE = "illegal map value";
49 const char * const ALIAS_NOT_FOUND = "alias not found after *";
50 const char * const ANCHOR_NOT_FOUND = "anchor not found after &";
51 const char * const CHAR_IN_ALIAS = "illegal character found while scanning alias";
52 const char * const CHAR_IN_ANCHOR = "illegal character found while scanning anchor";
53 const char * const ZERO_INDENT_IN_BLOCK = "cannot set zero indentation for a block scalar";
54 const char * const CHAR_IN_BLOCK = "unexpected character in block scalar";
55 const char * const AMBIGUOUS_ANCHOR = "cannot assign the same alias to multiple nodes";
56 const char * const UNKNOWN_ANCHOR = "the referenced anchor is not defined";
58 const char * const INVALID_SCALAR = "invalid scalar";
59 const char * const KEY_NOT_FOUND = "key not found";
60 const char * const BAD_DEREFERENCE = "bad dereference";
62 const char * const UNMATCHED_GROUP_TAG = "unmatched group tag";
63 const char * const UNEXPECTED_END_SEQ = "unexpected end sequence token";
64 const char * const UNEXPECTED_END_MAP = "unexpected end map token";
65 const char * const SINGLE_QUOTED_CHAR = "invalid character in single-quoted string";
66 const char * const INVALID_ANCHOR = "invalid anchor";
67 const char * const INVALID_ALIAS = "invalid alias";
68 const char * const INVALID_TAG = "invalid tag";
69 const char * const EXPECTED_KEY_TOKEN = "expected key token";
70 const char * const EXPECTED_VALUE_TOKEN = "expected value token";
71 const char * const UNEXPECTED_KEY_TOKEN = "unexpected key token";
72 const char * const UNEXPECTED_VALUE_TOKEN = "unexpected value token";
74 template <typename T>
75 inline const std::string KEY_NOT_FOUND_WITH_KEY(const T&, typename disable_if<is_numeric<T> >::type * = 0) {
76 return KEY_NOT_FOUND;
79 inline const std::string KEY_NOT_FOUND_WITH_KEY(const std::string& key) {
80 std::stringstream stream;
81 stream << KEY_NOT_FOUND << ": " << key;
82 return stream.str();
85 template <typename T>
86 inline const std::string KEY_NOT_FOUND_WITH_KEY(const T& key, typename enable_if<is_numeric<T> >::type * = 0) {
87 std::stringstream stream;
88 stream << KEY_NOT_FOUND << ": " << key;
89 return stream.str();
93 class Exception: public std::runtime_error {
94 public:
95 Exception(const Mark& mark_, const std::string& msg_)
96 : std::runtime_error(build_what(mark_, msg_)), mark(mark_), msg(msg_) {}
97 virtual ~Exception() throw() {}
99 Mark mark;
100 std::string msg;
102 private:
103 static const std::string build_what(const Mark& mark, const std::string& msg) {
104 std::stringstream output;
105 output << "yaml-cpp: error at line " << mark.line+1 << ", column " << mark.column+1 << ": " << msg;
106 return output.str();
110 class ParserException: public Exception {
111 public:
112 ParserException(const Mark& mark_, const std::string& msg_)
113 : Exception(mark_, msg_) {}
116 class RepresentationException: public Exception {
117 public:
118 RepresentationException(const Mark& mark_, const std::string& msg_)
119 : Exception(mark_, msg_) {}
122 // representation exceptions
123 class InvalidScalar: public RepresentationException {
124 public:
125 InvalidScalar(const Mark& mark_)
126 : RepresentationException(mark_, ErrorMsg::INVALID_SCALAR) {}
129 class KeyNotFound: public RepresentationException {
130 public:
131 template <typename T>
132 KeyNotFound(const Mark& mark_, const T& key_)
133 : RepresentationException(mark_, ErrorMsg::KEY_NOT_FOUND_WITH_KEY(key_)) {}
136 template <typename T>
137 class TypedKeyNotFound: public KeyNotFound {
138 public:
139 TypedKeyNotFound(const Mark& mark_, const T& key_)
140 : KeyNotFound(mark_, key_), key(key_) {}
141 virtual ~TypedKeyNotFound() throw() {}
143 T key;
146 template <typename T>
147 inline TypedKeyNotFound <T> MakeTypedKeyNotFound(const Mark& mark, const T& key) {
148 return TypedKeyNotFound <T> (mark, key);
151 class BadDereference: public RepresentationException {
152 public:
153 BadDereference()
154 : RepresentationException(Mark::null(), ErrorMsg::BAD_DEREFERENCE) {}
157 class EmitterException: public Exception {
158 public:
159 EmitterException(const std::string& msg_)
160 : Exception(Mark::null(), msg_) {}
164 #endif // EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66