From e4530c6d0cd180ab18469bf8e32fb978229dedde Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sat, 7 Oct 2006 14:57:15 +0000 Subject: Added support for gzip compressed map layer data. Increased version to 0.0.22. Cleaned up overlay initialization a bit. --- src/properties.h | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src/properties.h') diff --git a/src/properties.h b/src/properties.h index 92690cd3..56e90c0e 100644 --- a/src/properties.h +++ b/src/properties.h @@ -26,6 +26,7 @@ #include #include +#include /** * A class holding a set of properties. @@ -39,16 +40,36 @@ class Properties /** * Get a map property. * - * @return the value of the given property or an empty string when it + * @param def default value, empty string by default + * @return the value of the given property or the given default when it * doesn't exist. */ const std::string& - getProperty(const std::string &name) + getProperty(const std::string &name, const std::string &def = "") { - const static std::string undefined = ""; PropertyMap::const_iterator i = mProperties.find(name); + return (i != mProperties.end()) ? i->second : def; + } - return (i != mProperties.end()) ? i->second : undefined; + /** + * Gets a map property as a float. + * + * @param def default value, 0.0f by default + * @return the value of the given property, or 0.0f when it doesn't + * exist. + */ + const float + getFloatProperty(const std::string &name, float def = 0.0f) + { + PropertyMap::const_iterator i = mProperties.find(name); + float ret = def; + if (i != mProperties.end()) + { + std::stringstream ss; + ss.str(i->second); + ss >> ret; + } + return ret; } /** -- cgit v1.2.3-70-g09d2