]>
Commit | Line | Data |
---|---|---|
a05bc41e JB |
1 | --- imageworks-OpenColorIO-8883824/src/core/Config.cpp.orig 2012-12-12 00:21:23.000000000 +0100 |
2 | +++ imageworks-OpenColorIO-8883824/src/core/Config.cpp 2013-05-25 18:28:05.264387301 +0200 | |
3 | @@ -240,35 +240,27 @@ OCIO_NAMESPACE_ENTER | |
4 | if(node.Tag() != "View") | |
5 | return; | |
6 | ||
7 | - std::string key, stringval; | |
8 | - | |
9 | - for (YAML::Iterator iter = node.begin(); | |
10 | + for (YAML::const_iterator iter = node.begin(); | |
11 | iter != node.end(); | |
12 | ++iter) | |
13 | { | |
14 | - iter.first() >> key; | |
15 | + std::string key = iter->first.as<std::string>(); | |
16 | ||
17 | if(key == "name") | |
18 | { | |
19 | - if (iter.second().Type() != YAML::NodeType::Null && | |
20 | - iter.second().Read<std::string>(stringval)) | |
21 | - v.name = stringval; | |
22 | + v.name = iter->second.as<std::string>(); | |
23 | } | |
24 | else if(key == "colorspace") | |
25 | { | |
26 | - if (iter.second().Type() != YAML::NodeType::Null && | |
27 | - iter.second().Read<std::string>(stringval)) | |
28 | - v.colorspace = stringval; | |
29 | + v.colorspace = iter->second.as<std::string>(); | |
30 | } | |
31 | else if(key == "looks" || key == "look") | |
32 | { | |
33 | - if (iter.second().Type() != YAML::NodeType::Null && | |
34 | - iter.second().Read<std::string>(stringval)) | |
35 | - v.looks = stringval; | |
36 | + v.looks = iter->second.as<std::string>(); | |
37 | } | |
38 | else | |
39 | { | |
40 | - LogUnknownKeyWarning(node.Tag(), iter.first()); | |
41 | + LogUnknownKeyWarning(node.Tag(), iter->first); | |
42 | } | |
43 | } | |
44 | ||
45 | @@ -391,7 +383,24 @@ OCIO_NAMESPACE_ENTER | |
46 | ||
47 | ||
48 | } // namespace | |
49 | - | |
50 | + | |
51 | +} | |
52 | + | |
53 | +namespace YAML { | |
54 | + template<> | |
55 | + struct convert<OCIO_NAMESPACE::View> { | |
56 | + static bool decode(const Node &n, View &v) | |
57 | + { | |
58 | + if(node.Tag() != "View") | |
59 | + return false; | |
60 | + n >> v; | |
61 | + return true; | |
62 | + } | |
63 | + }; | |
64 | +} | |
65 | + | |
66 | +OCIO_NAMESPACE_ENTER | |
67 | +{ | |
68 | class Config::Impl | |
69 | { | |
70 | public: | |
71 | @@ -1658,13 +1667,11 @@ OCIO_NAMESPACE_ENTER | |
72 | { | |
73 | try | |
74 | { | |
75 | - YAML::Parser parser(istream); | |
76 | - YAML::Node node; | |
77 | - parser.GetNextDocument(node); | |
78 | + YAML::Node node = YAML::Load(istream); | |
79 | ||
80 | // check profile version | |
81 | int profile_version = 0; | |
82 | - if(node.FindValue("ocio_profile_version") == NULL) | |
83 | + if(!node["ocio_profile_version"]) | |
84 | { | |
85 | std::ostringstream os; | |
86 | os << "The specified file "; | |
87 | @@ -1672,7 +1679,7 @@ OCIO_NAMESPACE_ENTER | |
88 | throw Exception (os.str().c_str()); | |
89 | } | |
90 | ||
91 | - node["ocio_profile_version"] >> profile_version; | |
92 | + profile_version = node["ocio_profile_version"].as<int>(); | |
93 | if(profile_version > 1) | |
94 | { | |
95 | std::ostringstream os; | |
96 | @@ -1690,40 +1697,30 @@ OCIO_NAMESPACE_ENTER | |
97 | } | |
98 | ||
99 | ||
100 | - std::string key, stringval; | |
101 | - bool boolval = false; | |
102 | - | |
103 | - for (YAML::Iterator iter = node.begin(); | |
104 | + for (YAML::iterator iter = node.begin(); | |
105 | iter != node.end(); | |
106 | ++iter) | |
107 | { | |
108 | - iter.first() >> key; | |
109 | + std::string key = iter->first.as<std::string>(); | |
110 | ||
111 | if(key == "ocio_profile_version") { } // Already handled above. | |
112 | else if(key == "search_path" || key == "resource_path") | |
113 | { | |
114 | - if (iter.second().Type() != YAML::NodeType::Null && | |
115 | - iter.second().Read<std::string>(stringval)) | |
116 | - context_->setSearchPath(stringval.c_str()); | |
117 | + context_->setSearchPath(iter->second.as<std::string>().c_str()); | |
118 | } | |
119 | else if(key == "strictparsing") | |
120 | { | |
121 | - if (iter.second().Type() != YAML::NodeType::Null && | |
122 | - iter.second().Read<bool>(boolval)) | |
123 | - strictParsing_ = boolval; | |
124 | + strictParsing_ = iter->second.as<bool>(); | |
125 | } | |
126 | else if(key == "description") | |
127 | { | |
128 | - if (iter.second().Type() != YAML::NodeType::Null && | |
129 | - iter.second().Read<std::string>(stringval)) | |
130 | - description_ = stringval; | |
131 | + description_ = iter->second.as<std::string>(); | |
132 | } | |
133 | else if(key == "luma") | |
134 | { | |
135 | std::vector<float> val; | |
136 | - if (iter.second().Type() != YAML::NodeType::Null) | |
137 | { | |
138 | - iter.second() >> val; | |
139 | + val = iter->second.as< std::vector<float> >(); | |
140 | if(val.size() != 3) | |
141 | { | |
142 | std::ostringstream os; | |
143 | @@ -1736,46 +1733,35 @@ OCIO_NAMESPACE_ENTER | |
144 | } | |
145 | else if(key == "roles") | |
146 | { | |
147 | - const YAML::Node& roles = iter.second(); | |
148 | + const YAML::Node& roles = iter->second; | |
149 | if(roles.Type() != YAML::NodeType::Map) | |
150 | { | |
151 | std::ostringstream os; | |
152 | os << "'roles' field needs to be a (name: key) map."; | |
153 | throw Exception(os.str().c_str()); | |
154 | } | |
155 | - for (YAML::Iterator it = roles.begin(); | |
156 | + for (YAML::const_iterator it = roles.begin(); | |
157 | it != roles.end(); ++it) | |
158 | { | |
159 | - std::string k, v; | |
160 | - it.first() >> k; | |
161 | - it.second() >> v; | |
162 | - roles_[pystring::lower(k)] = v; | |
163 | + roles_[pystring::lower(it->first.as<std::string>())] = it->second.as<std::string>(); | |
164 | } | |
165 | } | |
166 | else if(key == "displays") | |
167 | { | |
168 | - if (iter.second().Type() != YAML::NodeType::Null) | |
169 | - { | |
170 | - iter.second() >> displays_; | |
171 | - } | |
172 | + //displays_ = iter->second.as<DisplayMap>(); | |
173 | + iter->second >> displays_; | |
174 | } | |
175 | else if(key == "active_displays") | |
176 | { | |
177 | - if (iter.second().Type() != YAML::NodeType::Null) | |
178 | - { | |
179 | - iter.second() >> activeDisplays_; | |
180 | - } | |
181 | + activeDisplays_ = iter->second.as<StringVec>(); | |
182 | } | |
183 | else if(key == "active_views") | |
184 | { | |
185 | - if (iter.second().Type() != YAML::NodeType::Null) | |
186 | - { | |
187 | - iter.second() >> activeViews_; | |
188 | - } | |
189 | + activeViews_ = iter->second.as<StringVec>(); | |
190 | } | |
191 | else if(key == "colorspaces") | |
192 | { | |
193 | - const YAML::Node& colorspaces = iter.second(); | |
194 | + const YAML::Node& colorspaces = iter->second; | |
195 | ||
196 | if(colorspaces.Type() != YAML::NodeType::Sequence) | |
197 | { | |
198 | @@ -1804,7 +1790,7 @@ OCIO_NAMESPACE_ENTER | |
199 | } | |
200 | else if(key == "looks") | |
201 | { | |
202 | - const YAML::Node& looks = iter.second(); | |
203 | + const YAML::Node& looks = iter->second; | |
204 | ||
205 | if(looks.Type() != YAML::NodeType::Sequence) | |
206 | { | |
207 | @@ -1833,7 +1819,7 @@ OCIO_NAMESPACE_ENTER | |
208 | } | |
209 | else | |
210 | { | |
211 | - LogUnknownKeyWarning("profile", iter.first()); | |
212 | + LogUnknownKeyWarning("profile", iter->first); | |
213 | } | |
214 | } | |
215 |