Enhancement - add

- Modified Record::get* methods to be const.
- Implemented TDB2::add.
- Renamed Task::valid to Task::validate.
- Implemented Task::setEntry to default creation time.
- Fixed bug where TDB2 was opening files "rw" instead of "r+".
This commit is contained in:
Paul Beckingham
2009-06-11 00:11:11 -04:00
parent 8728312da6
commit 7b9cb12308
8 changed files with 70 additions and 55 deletions

View File

@@ -62,12 +62,13 @@ std::string Record::composeF4 ()
std::string ff4 = "[";
bool first = true;
foreach (r, (*this))
foreach (att, (*this))
{
if (r->second.value () != "")
ff4 += (first ? "" : " ") + r->second.composeF4 ();
first = false;
if (att->second.value () != "")
{
ff4 += (first ? "" : " ") + att->second.composeF4 ();
first = false;
}
}
ff4 += "]";
@@ -126,19 +127,21 @@ std::vector <Att> Record::all ()
}
////////////////////////////////////////////////////////////////////////////////
const std::string Record::get (const std::string& name)
const std::string Record::get (const std::string& name) const
{
if (this->find (name) != this->end ())
return (*this)[name].value ();
Record::const_iterator i = this->find (name);
if (i != this->end ())
return i->second.value ();
return "";
}
////////////////////////////////////////////////////////////////////////////////
int Record::get_int (const std::string& name)
int Record::get_int (const std::string& name) const
{
if (this->find (name) != this->end ())
return ::atoi ((*this)[name].value ().c_str ());
Record::const_iterator i = this->find (name);
if (i != this->end ())
return ::atoi (i->second.value ().c_str ());
return 0;
}