From: timoore Date: Tue, 18 Nov 2008 22:16:58 +0000 (+0000) Subject: Template functions and overloaded functions for accessing property values. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2e65538fb5b9eb9a26d254a67d883f81eea1f73e;p=simgear.git Template functions and overloaded functions for accessing property values. These are useful for writing templates that manipulate properties. --- diff --git a/simgear/props/props.hxx b/simgear/props/props.hxx index f9b469fe..d25637e0 100644 --- a/simgear/props/props.hxx +++ b/simgear/props/props.hxx @@ -1508,6 +1508,72 @@ private: }; +// Convenice functions for use in templates +template +T getValue(const SGPropertyNode*); + +template<> +inline bool getValue(const SGPropertyNode* node) { return node->getBoolValue(); } + +template<> +inline int getValue(const SGPropertyNode* node) { return node->getIntValue(); } + +template<> +inline long getValue(const SGPropertyNode* node) { return node->getLongValue(); } + +template<> +inline float getValue(const SGPropertyNode* node) +{ + return node->getFloatValue(); +} + +template<> +inline double getValue(const SGPropertyNode* node) +{ + return node->getDoubleValue(); +} + +template<> +inline const char * getValue(const SGPropertyNode* node) +{ + return node->getStringValue (); +} + +inline bool setValue(SGPropertyNode* node, bool value) +{ + return node->setBoolValue(value); +} + +inline bool setValue(SGPropertyNode* node, int value) +{ + return node->setIntValue(value); +} + +inline bool setValue(SGPropertyNode* node, long value) +{ + return node->setLongValue(value); +} + +inline bool setValue(SGPropertyNode* node, float value) +{ + return node->setFloatValue(value); +} + +inline bool setValue(SGPropertyNode* node, double value) +{ + return node->setDoubleValue(value); +} + +inline bool setValue(SGPropertyNode* node, const char* value) +{ + return node->setStringValue(value); +} + +inline bool setValue (SGPropertyNode* node, const std::string& value) +{ + return node->setStringValue(value.c_str()); +} + #endif // __PROPS_HXX // end of props.hxx