From 1ccbb3b43a9fc6ac677516b88fd7489e3b401791 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 24 Jun 2014 22:14:29 -0400 Subject: [PATCH] Task - Added ::get_float method for accessing numeric attributes. --- src/Task.cpp | 10 ++++++++++ src/Task.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/Task.cpp b/src/Task.cpp index b27908587..166efd7c3 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -279,6 +279,16 @@ unsigned long Task::get_ulong (const std::string& name) const return 0; } +//////////////////////////////////////////////////////////////////////////////// +float Task::get_float (const std::string& name) const +{ + Task::const_iterator i = this->find (name); + if (i != this->end ()) + return strtof (i->second.c_str (), NULL); + + return 0.0; +} + //////////////////////////////////////////////////////////////////////////////// time_t Task::get_date (const std::string& name) const { diff --git a/src/Task.h b/src/Task.h index 044d86554..9a946bcfe 100644 --- a/src/Task.h +++ b/src/Task.h @@ -100,6 +100,7 @@ public: const std::string& get_ref (const std::string&) const; int get_int (const std::string&) const; unsigned long get_ulong (const std::string&) const; + float get_float (const std::string&) const; time_t get_date (const std::string&) const; void set (const std::string&, const std::string&); void set (const std::string&, int);