mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Added templated Read() function that creates the output variable itself (so you don't need to have a temp variable)
This commit is contained in:
@@ -49,6 +49,9 @@ namespace YAML
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
bool Read(T& value) const;
|
bool Read(T& value) const;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
const T Read() const;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
friend void operator >> (const Node& node, T& value);
|
friend void operator >> (const Node& node, T& value);
|
||||||
|
|
||||||
|
@@ -16,6 +16,13 @@ namespace YAML
|
|||||||
return Convert(scalar, value);
|
return Convert(scalar, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline const T Node::Read() const {
|
||||||
|
T value;
|
||||||
|
*this >> value;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void operator >> (const Node& node, T& value) {
|
inline void operator >> (const Node& node, T& value) {
|
||||||
if(!node.Read(value))
|
if(!node.Read(value))
|
||||||
|
Reference in New Issue
Block a user