From d1c888f57a06eb2ab9491613b7e5f25225aaeda3 Mon Sep 17 00:00:00 2001 From: jbeder Date: Wed, 19 Aug 2009 03:37:19 +0000 Subject: [PATCH] Added templated Read() function that creates the output variable itself (so you don't need to have a temp variable) --- include/node.h | 3 +++ include/nodeimpl.h | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/include/node.h b/include/node.h index 587c707..5ee1273 100644 --- a/include/node.h +++ b/include/node.h @@ -49,6 +49,9 @@ namespace YAML template bool Read(T& value) const; + template + const T Read() const; + template friend void operator >> (const Node& node, T& value); diff --git a/include/nodeimpl.h b/include/nodeimpl.h index 31ebbf7..606a5be 100644 --- a/include/nodeimpl.h +++ b/include/nodeimpl.h @@ -16,6 +16,13 @@ namespace YAML return Convert(scalar, value); } + template + inline const T Node::Read() const { + T value; + *this >> value; + return value; + } + template inline void operator >> (const Node& node, T& value) { if(!node.Read(value))