remove button colors from quarks gui (cocoa + swing)
[supercollider.git] / external_libraries / yaml-cpp-0.2.6 / include / yaml-cpp / nodeimpl.h
blobd26968ac6613903cbe9169bd65d14d1f4030c3ef
1 #ifndef NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
2 #define NODEIMPL_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/nodeutil.h"
10 #include <cassert>
12 namespace YAML
14 // implementation of templated things
15 template <typename T>
16 inline const T Node::to() const {
17 T value;
18 *this >> value;
19 return value;
22 template <typename T>
23 inline void operator >> (const Node& node, T& value) {
24 if(!ConvertScalar(node, value))
25 throw InvalidScalar(node.m_mark);
28 template <typename T>
29 inline const Node *Node::FindValue(const T& key) const {
30 switch(m_type) {
31 case NodeType::Null:
32 case NodeType::Scalar:
33 throw BadDereference();
34 case NodeType::Sequence:
35 return FindFromNodeAtIndex(*this, key);
36 case NodeType::Map:
37 return FindValueForKey(key);
39 assert(false);
40 throw BadDereference();
43 template <typename T>
44 inline const Node *Node::FindValueForKey(const T& key) const {
45 for(Iterator it=begin();it!=end();++it) {
46 T t;
47 if(it.first().Read(t)) {
48 if(key == t)
49 return &it.second();
53 return 0;
56 template <typename T>
57 inline const Node& Node::GetValue(const T& key) const {
58 if(const Node *pValue = FindValue(key))
59 return *pValue;
60 throw MakeTypedKeyNotFound(m_mark, key);
63 template <typename T>
64 inline const Node& Node::operator [] (const T& key) const {
65 return GetValue(key);
68 inline const Node *Node::FindValue(const char *key) const {
69 return FindValue(std::string(key));
72 inline const Node& Node::operator [] (const char *key) const {
73 return GetValue(std::string(key));
77 #endif // NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66