diff --git a/src/Record.cpp b/src/Record.cpp index d53b4bfce..c0fd24d42 100644 --- a/src/Record.cpp +++ b/src/Record.cpp @@ -94,97 +94,3 @@ void Record::parse (const std::string& input) } //////////////////////////////////////////////////////////////////////////////// -bool Record::has (const std::string& name) const -{ - Record::const_iterator i = this->find (name); - if (i != this->end ()) - return true; - - return false; -} - -//////////////////////////////////////////////////////////////////////////////// -std::vector Record::all () -{ - std::vector all; - std::map ::iterator i; - for (i = this->begin (); i != this->end (); ++i) - all.push_back (i->second); - - return all; -} - -//////////////////////////////////////////////////////////////////////////////// -const std::string Record::get (const std::string& name) const -{ - Record::const_iterator i = this->find (name); - if (i != this->end ()) - return i->second.value (); - - return ""; -} - -//////////////////////////////////////////////////////////////////////////////// -int Record::get_int (const std::string& name) const -{ - Record::const_iterator i = this->find (name); - if (i != this->end ()) - return atoi (i->second.value ().c_str ()); - - return 0; -} - -//////////////////////////////////////////////////////////////////////////////// -unsigned long Record::get_ulong (const std::string& name) const -{ - Record::const_iterator i = this->find (name); - if (i != this->end ()) - return strtoul (i->second.value ().c_str (), NULL, 10); - - return 0; -} - -//////////////////////////////////////////////////////////////////////////////// -time_t Record::get_date (const std::string& name) const -{ - Record::const_iterator i = this->find (name); - if (i != this->end ()) - return (time_t) strtoul (i->second.value ().c_str (), NULL, 10); - - return 0; -} - -//////////////////////////////////////////////////////////////////////////////// -time_t Record::get_duration (const std::string& name) const -{ - Record::const_iterator i = this->find (name); - if (i != this->end ()) - return (time_t) strtoul (i->second.value ().c_str (), NULL, 10); - - return 0; -} - -//////////////////////////////////////////////////////////////////////////////// -void Record::set (const std::string& name, const std::string& value) -{ - (*this)[name] = Att (name, value); -} - -//////////////////////////////////////////////////////////////////////////////// -void Record::set (const std::string& name, int value) -{ - std::stringstream svalue; - svalue << value; - - (*this)[name] = Att (name, svalue.str ()); -} - -//////////////////////////////////////////////////////////////////////////////// -void Record::remove (const std::string& name) -{ - Record::iterator it; - if ((it = this->find (name)) != this->end ()) - this->erase (it); -} - -//////////////////////////////////////////////////////////////////////////////// diff --git a/src/Record.h b/src/Record.h index 5e8888542..51ca44e22 100644 --- a/src/Record.h +++ b/src/Record.h @@ -43,16 +43,6 @@ public: void parse (const std::string&); - bool has (const std::string&) const; - std::vector all (); - const std::string get (const std::string&) const; - int get_int (const std::string&) const; - unsigned long get_ulong (const std::string&) const; - time_t get_date (const std::string&) const; - time_t get_duration (const std::string&) const; - void set (const std::string&, const std::string&); - void set (const std::string&, int); - void remove (const std::string&); }; #endif diff --git a/src/Task.cpp b/src/Task.cpp index 91e01011f..b59012c09 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -160,6 +160,100 @@ void Task::setStart () recalc_urgency = true; } +//////////////////////////////////////////////////////////////////////////////// +bool Task::has (const std::string& name) const +{ + Task::const_iterator i = this->find (name); + if (i != this->end ()) + return true; + + return false; +} + +//////////////////////////////////////////////////////////////////////////////// +std::vector Task::all () +{ + std::vector all; + std::map ::iterator i; + for (i = this->begin (); i != this->end (); ++i) + all.push_back (i->second); + + return all; +} + +//////////////////////////////////////////////////////////////////////////////// +const std::string Task::get (const std::string& name) const +{ + Task::const_iterator i = this->find (name); + if (i != this->end ()) + return i->second.value (); + + return ""; +} + +//////////////////////////////////////////////////////////////////////////////// +int Task::get_int (const std::string& name) const +{ + Task::const_iterator i = this->find (name); + if (i != this->end ()) + return atoi (i->second.value ().c_str ()); + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +unsigned long Task::get_ulong (const std::string& name) const +{ + Task::const_iterator i = this->find (name); + if (i != this->end ()) + return strtoul (i->second.value ().c_str (), NULL, 10); + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +time_t Task::get_date (const std::string& name) const +{ + Task::const_iterator i = this->find (name); + if (i != this->end ()) + return (time_t) strtoul (i->second.value ().c_str (), NULL, 10); + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +time_t Task::get_duration (const std::string& name) const +{ + Task::const_iterator i = this->find (name); + if (i != this->end ()) + return (time_t) strtoul (i->second.value ().c_str (), NULL, 10); + + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +void Task::set (const std::string& name, const std::string& value) +{ + (*this)[name] = Att (name, value); +} + +//////////////////////////////////////////////////////////////////////////////// +void Task::set (const std::string& name, int value) +{ + std::stringstream svalue; + svalue << value; + + (*this)[name] = Att (name, svalue.str ()); +} + +//////////////////////////////////////////////////////////////////////////////// +void Task::remove (const std::string& name) +{ + Task::iterator it; + if ((it = this->find (name)) != this->end ()) + this->erase (it); +} + //////////////////////////////////////////////////////////////////////////////// Task::status Task::getStatus () const { diff --git a/src/Task.h b/src/Task.h index 2b36ab2a3..4af7630cd 100644 --- a/src/Task.h +++ b/src/Task.h @@ -63,6 +63,17 @@ public: void setEnd (); void setStart (); + bool has (const std::string&) const; + std::vector all (); + const std::string get (const std::string&) const; + int get_int (const std::string&) const; + unsigned long get_ulong (const std::string&) const; + time_t get_date (const std::string&) const; + time_t get_duration (const std::string&) const; + void set (const std::string&, const std::string&); + void set (const std::string&, int); + void remove (const std::string&); + status getStatus () const; void setStatus (status);