MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / optValue

Function optValue

base/poco/JSON/include/Poco/JSON/Object.h:191–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189
190 template <typename T>
191 T optValue(const std::string & key, const T & def) const
192 /// Returns the value of a property when the property exists
193 /// and can be converted to the given type. Otherwise
194 /// def will be returned.
195 {
196 T value = def;
197 ValueMap::const_iterator it = _values.find(key);
198 if (it != _values.end() && !it->second.isEmpty())
199 {
200 try
201 {
202 value = it->second.convert<T>();
203 }
204 catch (...)
205 {
206 // The default value will be returned
207 }
208 }
209 return value;
210 }
211
212 std::size_t size() const;
213 /// Returns the number of properties.

Callers

nothing calls this directly

Calls 3

findMethod · 0.45
endMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected