[niepce] Add string conversion helpers for property values
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] Add string conversion helpers for property values
- Date: Fri, 28 Jun 2013 03:09:28 +0000 (UTC)
commit 4996afe07145f94fe1bb2263cea36b75ce79ef94
Author: Hubert Figuière <hub figuiere net>
Date: Thu Jun 27 00:26:23 2013 -0400
Add string conversion helpers for property values
src/fwk/base/propertybag.cpp | 10 ++++++++++
src/fwk/base/propertybag.hpp | 3 +++
2 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/src/fwk/base/propertybag.cpp b/src/fwk/base/propertybag.cpp
index 29bb8c5..61eccf4 100644
--- a/src/fwk/base/propertybag.cpp
+++ b/src/fwk/base/propertybag.cpp
@@ -33,11 +33,21 @@ bool is_integer(const PropertyValue & v)
return v.type() == typeid(int);
}
+bool is_string(const PropertyValue & v)
+{
+ return v.type() == typeid(std::string);
+}
+
int get_integer(const PropertyValue & v)
{
return is_empty(v) ? 0 : boost::get<int>(v);
}
+const std::string & get_string(const PropertyValue & v)
+{
+ return boost::get<std::string>(v);
+}
+
bool PropertyBag::set_value_for_property(PropertyIndex idx, const PropertyValue & value)
{
bool removed = (m_bag.erase(idx) == 1);
diff --git a/src/fwk/base/propertybag.hpp b/src/fwk/base/propertybag.hpp
index 9018d96..5f62031 100644
--- a/src/fwk/base/propertybag.hpp
+++ b/src/fwk/base/propertybag.hpp
@@ -45,8 +45,11 @@ typedef std::set<PropertyIndex> PropertySet;
bool is_empty(const PropertyValue & v);
/** Return if it is an integer */
bool is_integer(const PropertyValue & v);
+bool is_string(const PropertyValue & v);
/** Return the integer value (or 0 if empty) */
int get_integer(const PropertyValue & v);
+/** Return the string value */
+const std::string & get_string(const PropertyValue & v);
/** a property bag
* It is important that the values for PropertyIndex be properly name spaced
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]