Bug Fix - Build failure on OpenBSD

- Fixed build failure on OpenBSD (thanks to Mike Adonay).
This commit is contained in:
Paul Beckingham 2009-06-08 23:03:30 -04:00
parent f6b8b39d8b
commit 7538b43c68
14 changed files with 335 additions and 329 deletions

View file

@ -33,4 +33,5 @@ With thanks to:
Eric Farris Eric Farris
Bruce Dillahunty Bruce Dillahunty
Askme Too Askme Too
Mike Adonay

View file

@ -1,6 +1,11 @@
------ current release --------------------------- ------ current release ---------------------------
1.7.1 (6/8/2009)
+ Fixed build failure on OpenBSD (thanks to Mike Adonay).
+ Took the opportunity of a patch release to update the various email
addresses and URLs in the various documents.
1.7.0 (5/14/2009) 1.7.0 (5/14/2009)
+ Improved the errors when parsing a corrupt or unrecognized pending.data + Improved the errors when parsing a corrupt or unrecognized pending.data
or completed.data file (thanks to T. Charles Yun). or completed.data file (thanks to T. Charles Yun).

View file

@ -32,7 +32,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Default // Default
T::T () Tt::Tt ()
{ {
mUUID = uuid (); mUUID = uuid ();
mStatus = pending; mStatus = pending;
@ -49,13 +49,13 @@ T::T ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Initialize by parsing storage format // Initialize by parsing storage format
T::T (const std::string& line) Tt::Tt (const std::string& line)
{ {
parse (line); parse (line);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
T::T (const T& other) Tt::Tt (const Tt& other)
{ {
mStatus = other.mStatus; mStatus = other.mStatus;
mUUID = other.mUUID; mUUID = other.mUUID;
@ -69,7 +69,7 @@ T::T (const T& other)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
T& T::operator= (const T& other) Tt& Tt::operator= (const Tt& other)
{ {
if (this != &other) if (this != &other)
{ {
@ -88,12 +88,12 @@ T& T::operator= (const T& other)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
T::~T () Tt::~Tt ()
{ {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool T::hasTag (const std::string& tag) const bool Tt::hasTag (const std::string& tag) const
{ {
std::vector <std::string>::const_iterator it = find (mTags.begin (), mTags.end (), tag); std::vector <std::string>::const_iterator it = find (mTags.begin (), mTags.end (), tag);
if (it != mTags.end ()) if (it != mTags.end ())
@ -104,38 +104,38 @@ bool T::hasTag (const std::string& tag) const
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// SPECIAL METHOD - DO NOT REMOVE // SPECIAL METHOD - DO NOT REMOVE
void T::getRemoveTags (std::vector<std::string>& all) void Tt::getRemoveTags (std::vector<std::string>& all)
{ {
all = mRemoveTags; all = mRemoveTags;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// SPECIAL METHOD - DO NOT REMOVE // SPECIAL METHOD - DO NOT REMOVE
void T::addRemoveTag (const std::string& tag) void Tt::addRemoveTag (const std::string& tag)
{ {
if (tag.find (' ') != std::string::npos) if (tag.find (' ') != std::string::npos)
throw std::string ("T::addRemoveTag - tags may not contain spaces"); throw std::string ("Tt::addRemoveTag - tags may not contain spaces");
mRemoveTags.push_back (tag); mRemoveTags.push_back (tag);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int T::getTagCount () const int Tt::getTagCount () const
{ {
return mTags.size (); return mTags.size ();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void T::getTags (std::vector<std::string>& all) const void Tt::getTags (std::vector<std::string>& all) const
{ {
all = mTags; all = mTags;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void T::addTag (const std::string& tag) void Tt::addTag (const std::string& tag)
{ {
if (tag.find (' ') != std::string::npos) if (tag.find (' ') != std::string::npos)
throw std::string ("T::addTag - tags may not contain spaces"); throw std::string ("Tt::addTag - tags may not contain spaces");
if (tag[0] == '+') if (tag[0] == '+')
{ {
@ -150,12 +150,12 @@ void T::addTag (const std::string& tag)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void T::addTags (const std::vector <std::string>& tags) void Tt::addTags (const std::vector <std::string>& tags)
{ {
for (size_t i = 0; i < tags.size (); ++i) for (size_t i = 0; i < tags.size (); ++i)
{ {
if (tags[i].find (' ') != std::string::npos) if (tags[i].find (' ') != std::string::npos)
throw std::string ("T::addTags - tags may not contain spaces"); throw std::string ("Tt::addTags - tags may not contain spaces");
if (tags[i][0] == '+') if (tags[i][0] == '+')
{ {
@ -171,7 +171,7 @@ void T::addTags (const std::vector <std::string>& tags)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void T::removeTag (const std::string& tag) void Tt::removeTag (const std::string& tag)
{ {
std::vector <std::string> copy; std::vector <std::string> copy;
for (size_t i = 0; i < mTags.size (); ++i) for (size_t i = 0; i < mTags.size (); ++i)
@ -182,19 +182,19 @@ void T::removeTag (const std::string& tag)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void T::removeTags () void Tt::removeTags ()
{ {
mTags.clear (); mTags.clear ();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void T::getAttributes (std::map<std::string, std::string>& all) void Tt::getAttributes (std::map<std::string, std::string>& all)
{ {
all = mAttributes; all = mAttributes;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const std::string T::getAttribute (const std::string& name) const std::string Tt::getAttribute (const std::string& name)
{ {
if (mAttributes.find (name) != mAttributes.end ()) if (mAttributes.find (name) != mAttributes.end ())
return mAttributes[name]; return mAttributes[name];
@ -203,7 +203,7 @@ const std::string T::getAttribute (const std::string& name)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void T::setAttribute (const std::string& name, const std::string& value) void Tt::setAttribute (const std::string& name, const std::string& value)
{ {
if (name.find (' ') != std::string::npos) if (name.find (' ') != std::string::npos)
throw std::string ("An attribute name may not contain spaces"); throw std::string ("An attribute name may not contain spaces");
@ -215,7 +215,7 @@ void T::setAttribute (const std::string& name, const std::string& value)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void T::setAttributes (const std::map <std::string, std::string>& attributes) void Tt::setAttributes (const std::map <std::string, std::string>& attributes)
{ {
foreach (i, attributes) foreach (i, attributes)
{ {
@ -230,13 +230,13 @@ void T::setAttributes (const std::map <std::string, std::string>& attributes)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void T::removeAttributes () void Tt::removeAttributes ()
{ {
mAttributes.clear (); mAttributes.clear ();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void T::removeAttribute (const std::string& name) void Tt::removeAttribute (const std::string& name)
{ {
std::map <std::string, std::string> copy = mAttributes; std::map <std::string, std::string> copy = mAttributes;
mAttributes.clear (); mAttributes.clear ();
@ -246,7 +246,7 @@ void T::removeAttribute (const std::string& name)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void T::getSubstitution ( void Tt::getSubstitution (
std::string& from, std::string& from,
std::string& to, std::string& to,
bool& global) const bool& global) const
@ -257,7 +257,7 @@ void T::getSubstitution (
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void T::setSubstitution ( void Tt::setSubstitution (
const std::string& from, const std::string& from,
const std::string& to, const std::string& to,
bool global) bool global)
@ -268,19 +268,19 @@ void T::setSubstitution (
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void T::getAnnotations (std::map <time_t, std::string>& all) const void Tt::getAnnotations (std::map <time_t, std::string>& all) const
{ {
all = mAnnotations; all = mAnnotations;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void T::setAnnotations (const std::map <time_t, std::string>& all) void Tt::setAnnotations (const std::map <time_t, std::string>& all)
{ {
mAnnotations = all; mAnnotations = all;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void T::addAnnotation (const std::string& description) void Tt::addAnnotation (const std::string& description)
{ {
std::string sanitized = description; std::string sanitized = description;
std::replace (sanitized.begin (), sanitized.end (), '"', '\''); std::replace (sanitized.begin (), sanitized.end (), '"', '\'');
@ -290,7 +290,7 @@ void T::addAnnotation (const std::string& description)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool T::sequenceContains (int id) const bool Tt::sequenceContains (int id) const
{ {
foreach (seq, mSequence) foreach (seq, mSequence)
if (*seq == id) if (*seq == id)
@ -308,7 +308,7 @@ bool T::sequenceContains (int id) const
// attributes \w+:\w+ \s ... // attributes \w+:\w+ \s ...
// description .+ // description .+
// //
const std::string T::compose () const const std::string Tt::compose () const
{ {
// UUID // UUID
std::string line = mUUID + ' '; std::string line = mUUID + ' ';
@ -367,7 +367,7 @@ const std::string T::compose () const
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const std::string T::composeCSV () const std::string Tt::composeCSV ()
{ {
// UUID // UUID
std::string line = "'" + mUUID + "',"; std::string line = "'" + mUUID + "',";
@ -441,7 +441,7 @@ const std::string T::composeCSV ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Read all file formats, write only the latest. // Read all file formats, write only the latest.
void T::parse (const std::string& line) void Tt::parse (const std::string& line)
{ {
switch (determineVersion (line)) switch (determineVersion (line))
{ {
@ -659,7 +659,7 @@ void T::parse (const std::string& line)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// If this code is inaccurate, data corruption ensues. // If this code is inaccurate, data corruption ensues.
int T::determineVersion (const std::string& line) int Tt::determineVersion (const std::string& line)
{ {
// Version 1 looks like: // Version 1 looks like:
// //
@ -721,7 +721,7 @@ int T::determineVersion (const std::string& line)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// TODO Expand this method into a full-blown task validation check. // TODO Expand this method into a full-blown task validation check.
bool T::validate () const bool Tt::validate () const
{ {
// TODO Verify until > due // TODO Verify until > due
// TODO Verify entry < until, due, start, end // TODO Verify entry < until, due, start, end

16
src/T.h
View file

@ -24,8 +24,8 @@
// USA // USA
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_T #ifndef INCLUDED_Tt
#define INCLUDED_T #define INCLUDED_Tt
#include <string> #include <string>
#include <vector> #include <vector>
@ -34,16 +34,16 @@
// Length of longest line. // Length of longest line.
#define T_LINE_MAX 32768 #define T_LINE_MAX 32768
class T class Tt
{ {
public: public:
enum status {pending, completed, deleted, recurring}; enum status {pending, completed, deleted, recurring};
T (); // Default constructor Tt (); // Default constructor
T (const std::string&); // Initialize by parsing storage format Tt (const std::string&); // Initialize by parsing storage format
T (const T&); // Copy constructor Tt (const Tt&); // Copy constructor
T& operator= (const T&); // Assignment operator Tt& operator= (const Tt&); // Assignment operator
~T (); // Destructor ~Tt (); // Destructor
std::string getUUID () const { return mUUID; } std::string getUUID () const { return mUUID; }
void setUUID (const std::string& uuid) { mUUID = uuid; } void setUUID (const std::string& uuid) { mUUID = uuid; }

View file

@ -68,20 +68,20 @@ void TDB::dataDirectory (const std::string& directory)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Combine allPendingT with allCompletedT. // Combine allPendingT with allCompletedT.
// Note: this method is O(N1) + O(N2), where N2 is not bounded. // Note: this method is O(N1) + O(N2), where N2 is not bounded.
bool TDB::allT (std::vector <T>& all) bool TDB::allT (std::vector <Tt>& all)
{ {
all.clear (); all.clear ();
// Retrieve all the pending records. // Retrieve all the pending records.
std::vector <T> allp; std::vector <Tt> allp;
if (allPendingT (allp)) if (allPendingT (allp))
{ {
std::vector <T>::iterator i; std::vector <Tt>::iterator i;
for (i = allp.begin (); i != allp.end (); ++i) for (i = allp.begin (); i != allp.end (); ++i)
all.push_back (*i); all.push_back (*i);
// Retrieve all the completed records. // Retrieve all the completed records.
std::vector <T> allc; std::vector <Tt> allc;
if (allCompletedT (allc)) if (allCompletedT (allc))
{ {
for (i = allc.begin (); i != allc.end (); ++i) for (i = allc.begin (); i != allc.end (); ++i)
@ -96,7 +96,7 @@ bool TDB::allT (std::vector <T>& all)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Only accesses to the pending file result in Tasks that have assigned ids. // Only accesses to the pending file result in Tasks that have assigned ids.
bool TDB::pendingT (std::vector <T>& all) bool TDB::pendingT (std::vector <Tt>& all)
{ {
all.clear (); all.clear ();
@ -111,9 +111,9 @@ bool TDB::pendingT (std::vector <T>& all)
{ {
try try
{ {
T t (*it); Tt t (*it);
t.setId (mId++); t.setId (mId++);
if (t.getStatus () == T::pending) if (t.getStatus () == Tt::pending)
all.push_back (t); all.push_back (t);
} }
@ -136,7 +136,7 @@ bool TDB::pendingT (std::vector <T>& all)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Only accesses to the pending file result in Tasks that have assigned ids. // Only accesses to the pending file result in Tasks that have assigned ids.
bool TDB::allPendingT (std::vector <T>& all) bool TDB::allPendingT (std::vector <Tt>& all)
{ {
all.clear (); all.clear ();
@ -151,7 +151,7 @@ bool TDB::allPendingT (std::vector <T>& all)
{ {
try try
{ {
T t (*it); Tt t (*it);
t.setId (mId++); t.setId (mId++);
all.push_back (t); all.push_back (t);
} }
@ -174,7 +174,7 @@ bool TDB::allPendingT (std::vector <T>& all)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool TDB::completedT (std::vector <T>& all) const bool TDB::completedT (std::vector <Tt>& all) const
{ {
all.clear (); all.clear ();
@ -187,8 +187,8 @@ bool TDB::completedT (std::vector <T>& all) const
{ {
try try
{ {
T t (*it); Tt t (*it);
if (t.getStatus () != T::deleted) if (t.getStatus () != Tt::deleted)
all.push_back (t); all.push_back (t);
} }
@ -210,7 +210,7 @@ bool TDB::completedT (std::vector <T>& all) const
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool TDB::allCompletedT (std::vector <T>& all) const bool TDB::allCompletedT (std::vector <Tt>& all) const
{ {
all.clear (); all.clear ();
@ -223,7 +223,7 @@ bool TDB::allCompletedT (std::vector <T>& all) const
{ {
try try
{ {
T t (*it); Tt t (*it);
all.push_back (t); all.push_back (t);
} }
@ -245,9 +245,9 @@ bool TDB::allCompletedT (std::vector <T>& all) const
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool TDB::addT (const T& t) bool TDB::addT (const Tt& t)
{ {
T task (t); Tt task (t);
std::vector <std::string> tags; std::vector <std::string> tags;
task.getTags (tags); task.getTags (tags);
@ -262,8 +262,8 @@ bool TDB::addT (const T& t)
} }
} }
if (task.getStatus () == T::pending || if (task.getStatus () == Tt::pending ||
task.getStatus () == T::recurring) task.getStatus () == Tt::recurring)
{ {
return writePending (task); return writePending (task);
} }
@ -272,16 +272,16 @@ bool TDB::addT (const T& t)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool TDB::modifyT (const T& t) bool TDB::modifyT (const Tt& t)
{ {
T modified (t); Tt modified (t);
std::vector <T> all; std::vector <Tt> all;
allPendingT (all); allPendingT (all);
std::vector <T> pending; std::vector <Tt> pending;
std::vector <T>::iterator it; std::vector <Tt>::iterator it;
for (it = all.begin (); it != all.end (); ++it) for (it = all.begin (); it != all.end (); ++it)
{ {
if (it->getId () == t.getId ()) if (it->getId () == t.getId ())
@ -306,7 +306,7 @@ bool TDB::lock (FILE* file) const
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool TDB::overwritePending (std::vector <T>& all) bool TDB::overwritePending (std::vector <Tt>& all)
{ {
// Write a single task to the pending file // Write a single task to the pending file
FILE* out; FILE* out;
@ -317,7 +317,7 @@ bool TDB::overwritePending (std::vector <T>& all)
while (flock (fileno (out), LOCK_EX) && ++retry <= 3) while (flock (fileno (out), LOCK_EX) && ++retry <= 3)
delay (0.1); delay (0.1);
std::vector <T>::iterator it; std::vector <Tt>::iterator it;
for (it = all.begin (); it != all.end (); ++it) for (it = all.begin (); it != all.end (); ++it)
fputs (it->compose ().c_str (), out); fputs (it->compose ().c_str (), out);
@ -329,7 +329,7 @@ bool TDB::overwritePending (std::vector <T>& all)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool TDB::writePending (const T& t) bool TDB::writePending (const Tt& t)
{ {
// Write a single task to the pending file // Write a single task to the pending file
FILE* out; FILE* out;
@ -350,7 +350,7 @@ bool TDB::writePending (const T& t)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool TDB::writeCompleted (const T& t) bool TDB::writeCompleted (const Tt& t)
{ {
// Write a single task to the pending file // Write a single task to the pending file
FILE* out; FILE* out;
@ -414,18 +414,18 @@ int TDB::gc ()
int count = 0; int count = 0;
// Read everything from the pending file. // Read everything from the pending file.
std::vector <T> all; std::vector <Tt> all;
allPendingT (all); allPendingT (all);
// A list of the truly pending tasks. // A list of the truly pending tasks.
std::vector <T> pending; std::vector <Tt> pending;
std::vector<T>::iterator it; std::vector<Tt>::iterator it;
for (it = all.begin (); it != all.end (); ++it) for (it = all.begin (); it != all.end (); ++it)
{ {
// Some tasks stay in the pending file. // Some tasks stay in the pending file.
if (it->getStatus () == T::pending || if (it->getStatus () == Tt::pending ||
it->getStatus () == T::recurring) it->getStatus () == Tt::recurring)
{ {
pending.push_back (*it); pending.push_back (*it);
} }

View file

@ -38,13 +38,13 @@ public:
~TDB (); ~TDB ();
void dataDirectory (const std::string&); void dataDirectory (const std::string&);
bool allT (std::vector <T>&); bool allT (std::vector <Tt>&);
bool pendingT (std::vector <T>&); bool pendingT (std::vector <Tt>&);
bool allPendingT (std::vector <T>&); bool allPendingT (std::vector <Tt>&);
bool completedT (std::vector <T>&) const; bool completedT (std::vector <Tt>&) const;
bool allCompletedT (std::vector <T>&) const; bool allCompletedT (std::vector <Tt>&) const;
bool addT (const T&); bool addT (const Tt&);
bool modifyT (const T&); bool modifyT (const Tt&);
int gc (); int gc ();
int nextId (); int nextId ();
@ -52,9 +52,9 @@ public:
private: private:
bool lock (FILE*) const; bool lock (FILE*) const;
bool overwritePending (std::vector <T>&); bool overwritePending (std::vector <Tt>&);
bool writePending (const T&); bool writePending (const Tt&);
bool writeCompleted (const T&); bool writeCompleted (const Tt&);
bool readLockedFile (const std::string&, std::vector <std::string>&) const; bool readLockedFile (const std::string&, std::vector <std::string>&) const;
private: private:

View file

@ -41,7 +41,7 @@
#endif #endif
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleAdd (TDB& tdb, T& task, Config& conf) std::string handleAdd (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
@ -59,7 +59,7 @@ std::string handleAdd (TDB& tdb, T& task, Config& conf)
if (task.getAttribute ("due") != "" && if (task.getAttribute ("due") != "" &&
task.getAttribute ("recur") != "") task.getAttribute ("recur") != "")
{ {
task.setStatus (T::recurring); task.setStatus (Tt::recurring);
task.setAttribute ("mask", ""); task.setAttribute ("mask", "");
} }
@ -86,12 +86,12 @@ std::string handleAdd (TDB& tdb, T& task, Config& conf)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleProjects (TDB& tdb, T& task, Config& conf) std::string handleProjects (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
// Get all the tasks, including deleted ones. // Get all the tasks, including deleted ones.
std::vector <T> tasks; std::vector <Tt> tasks;
tdb.pendingT (tasks); tdb.pendingT (tasks);
// Scan all the tasks for their project name, building a map using project // Scan all the tasks for their project name, building a map using project
@ -99,7 +99,7 @@ std::string handleProjects (TDB& tdb, T& task, Config& conf)
std::map <std::string, int> unique; std::map <std::string, int> unique;
for (unsigned int i = 0; i < tasks.size (); ++i) for (unsigned int i = 0; i < tasks.size (); ++i)
{ {
T task (tasks[i]); Tt task (tasks[i]);
unique[task.getAttribute ("project")] += 1; unique[task.getAttribute ("project")] += 1;
} }
@ -141,12 +141,12 @@ std::string handleProjects (TDB& tdb, T& task, Config& conf)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleTags (TDB& tdb, T& task, Config& conf) std::string handleTags (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
// Get all the tasks. // Get all the tasks.
std::vector <T> tasks; std::vector <Tt> tasks;
tdb.pendingT (tasks); tdb.pendingT (tasks);
// Scan all the tasks for their project name, building a map using project // Scan all the tasks for their project name, building a map using project
@ -154,7 +154,7 @@ std::string handleTags (TDB& tdb, T& task, Config& conf)
std::map <std::string, std::string> unique; std::map <std::string, std::string> unique;
for (unsigned int i = 0; i < tasks.size (); ++i) for (unsigned int i = 0; i < tasks.size (); ++i)
{ {
T task (tasks[i]); Tt task (tasks[i]);
std::vector <std::string> tags; std::vector <std::string> tags;
task.getTags (tags); task.getTags (tags);
@ -183,22 +183,22 @@ std::string handleTags (TDB& tdb, T& task, Config& conf)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// If a task is deleted, but is still in the pending file, then it may be // If a task is deleted, but is still in the pending file, then it may be
// undeleted simply by changing it's status. // undeleted simply by changing it's status.
std::string handleUndelete (TDB& tdb, T& task, Config& conf) std::string handleUndelete (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
std::vector <T> all; std::vector <Tt> all;
tdb.allPendingT (all); tdb.allPendingT (all);
filterSequence (all, task); filterSequence (all, task);
foreach (t, all) foreach (t, all)
{ {
if (t->getStatus () == T::deleted) if (t->getStatus () == Tt::deleted)
{ {
if (t->getAttribute ("recur") != "") if (t->getAttribute ("recur") != "")
out << "Task does not support 'undo' for recurring tasks.\n"; out << "Task does not support 'undo' for recurring tasks.\n";
t->setStatus (T::pending); t->setStatus (Tt::pending);
t->removeAttribute ("end"); t->removeAttribute ("end");
tdb.modifyT (*t); tdb.modifyT (*t);
@ -221,22 +221,22 @@ std::string handleUndelete (TDB& tdb, T& task, Config& conf)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// If a task is done, but is still in the pending file, then it may be undone // If a task is done, but is still in the pending file, then it may be undone
// simply by changing it's status. // simply by changing it's status.
std::string handleUndo (TDB& tdb, T& task, Config& conf) std::string handleUndo (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
std::vector <T> all; std::vector <Tt> all;
tdb.allPendingT (all); tdb.allPendingT (all);
filterSequence (all, task); filterSequence (all, task);
foreach (t, all) foreach (t, all)
{ {
if (t->getStatus () == T::completed) if (t->getStatus () == Tt::completed)
{ {
if (t->getAttribute ("recur") != "") if (t->getAttribute ("recur") != "")
out << "Task does not support 'undo' for recurring tasks.\n"; out << "Task does not support 'undo' for recurring tasks.\n";
t->setStatus (T::pending); t->setStatus (Tt::pending);
t->removeAttribute ("end"); t->removeAttribute ("end");
tdb.modifyT (*t); tdb.modifyT (*t);
@ -418,11 +418,11 @@ std::string handleVersion (Config& conf)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleDelete (TDB& tdb, T& task, Config& conf) std::string handleDelete (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
std::vector <T> all; std::vector <Tt> all;
tdb.allPendingT (all); tdb.allPendingT (all);
filterSequence (all, task); filterSequence (all, task);
@ -455,7 +455,7 @@ std::string handleDelete (TDB& tdb, T& task, Config& conf)
if (sibling->getAttribute ("parent") == parent || if (sibling->getAttribute ("parent") == parent ||
sibling->getUUID () == parent) sibling->getUUID () == parent)
{ {
sibling->setStatus (T::deleted); sibling->setStatus (Tt::deleted);
sibling->setAttribute ("end", endTime); sibling->setAttribute ("end", endTime);
tdb.modifyT (*sibling); tdb.modifyT (*sibling);
@ -472,7 +472,7 @@ std::string handleDelete (TDB& tdb, T& task, Config& conf)
else else
{ {
// Update mask in parent. // Update mask in parent.
t->setStatus (T::deleted); t->setStatus (Tt::deleted);
updateRecurrenceMask (tdb, all, *t); updateRecurrenceMask (tdb, all, *t);
t->setAttribute ("end", endTime); t->setAttribute ("end", endTime);
@ -488,7 +488,7 @@ std::string handleDelete (TDB& tdb, T& task, Config& conf)
} }
else else
{ {
t->setStatus (T::deleted); t->setStatus (Tt::deleted);
t->setAttribute ("end", endTime); t->setAttribute ("end", endTime);
tdb.modifyT (*t); tdb.modifyT (*t);
@ -509,11 +509,11 @@ std::string handleDelete (TDB& tdb, T& task, Config& conf)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleStart (TDB& tdb, T& task, Config& conf) std::string handleStart (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
std::vector <T> all; std::vector <Tt> all;
tdb.pendingT (all); tdb.pendingT (all);
filterSequence (all, task); filterSequence (all, task);
@ -546,11 +546,11 @@ std::string handleStart (TDB& tdb, T& task, Config& conf)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleStop (TDB& tdb, T& task, Config& conf) std::string handleStop (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
std::vector <T> all; std::vector <Tt> all;
tdb.pendingT (all); tdb.pendingT (all);
filterSequence (all, task); filterSequence (all, task);
@ -574,18 +574,18 @@ std::string handleStop (TDB& tdb, T& task, Config& conf)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleDone (TDB& tdb, T& task, Config& conf) std::string handleDone (TDB& tdb, Tt& task, Config& conf)
{ {
int count = 0; int count = 0;
std::stringstream out; std::stringstream out;
std::vector <T> all; std::vector <Tt> all;
tdb.allPendingT (all); tdb.allPendingT (all);
std::vector <T> filtered = all; std::vector <Tt> filtered = all;
filterSequence (filtered, task); filterSequence (filtered, task);
foreach (seq, filtered) foreach (seq, filtered)
{ {
if (seq->getStatus () == T::pending) if (seq->getStatus () == Tt::pending)
{ {
// Apply deltas. // Apply deltas.
deltaDescription (*seq, task); deltaDescription (*seq, task);
@ -599,7 +599,7 @@ std::string handleDone (TDB& tdb, T& task, Config& conf)
seq->setAttribute ("end", entryTime); seq->setAttribute ("end", entryTime);
// Change status. // Change status.
seq->setStatus (T::completed); seq->setStatus (Tt::completed);
if (!tdb.modifyT (*seq)) if (!tdb.modifyT (*seq))
throw std::string ("Could not mark task as completed."); throw std::string ("Could not mark task as completed.");
@ -638,7 +638,7 @@ std::string handleDone (TDB& tdb, T& task, Config& conf)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleExport (TDB& tdb, T& task, Config& conf) std::string handleExport (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream output; std::stringstream output;
@ -669,13 +669,13 @@ std::string handleExport (TDB& tdb, T& task, Config& conf)
<< "\n"; << "\n";
int count = 0; int count = 0;
std::vector <T> all; std::vector <Tt> all;
tdb.allPendingT (all); tdb.allPendingT (all);
filter (all, task); filter (all, task);
foreach (t, all) foreach (t, all)
{ {
if (t->getStatus () != T::recurring && if (t->getStatus () != Tt::recurring &&
t->getStatus () != T::deleted) t->getStatus () != Tt::deleted)
{ {
out << t->composeCSV ().c_str (); out << t->composeCSV ().c_str ();
++count; ++count;
@ -695,14 +695,14 @@ std::string handleExport (TDB& tdb, T& task, Config& conf)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleModify (TDB& tdb, T& task, Config& conf) std::string handleModify (TDB& tdb, Tt& task, Config& conf)
{ {
int count = 0; int count = 0;
std::stringstream out; std::stringstream out;
std::vector <T> all; std::vector <Tt> all;
tdb.allPendingT (all); tdb.allPendingT (all);
std::vector <T> filtered = all; std::vector <Tt> filtered = all;
filterSequence (filtered, task); filterSequence (filtered, task);
foreach (seq, filtered) foreach (seq, filtered)
{ {
@ -749,14 +749,14 @@ std::string handleModify (TDB& tdb, T& task, Config& conf)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleAppend (TDB& tdb, T& task, Config& conf) std::string handleAppend (TDB& tdb, Tt& task, Config& conf)
{ {
int count = 0; int count = 0;
std::stringstream out; std::stringstream out;
std::vector <T> all; std::vector <Tt> all;
tdb.allPendingT (all); tdb.allPendingT (all);
std::vector <T> filtered = all; std::vector <Tt> filtered = all;
filterSequence (filtered, task); filterSequence (filtered, task);
foreach (seq, filtered) foreach (seq, filtered)
{ {
@ -799,20 +799,20 @@ std::string handleAppend (TDB& tdb, T& task, Config& conf)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleDuplicate (TDB& tdb, T& task, Config& conf) std::string handleDuplicate (TDB& tdb, Tt& task, Config& conf)
{ {
int count = 0; int count = 0;
std::stringstream out; std::stringstream out;
std::vector <T> all; std::vector <Tt> all;
tdb.allPendingT (all); tdb.allPendingT (all);
std::vector <T> filtered = all; std::vector <Tt> filtered = all;
filterSequence (filtered, task); filterSequence (filtered, task);
foreach (seq, filtered) foreach (seq, filtered)
{ {
if (seq->getStatus () != T::recurring && seq->getAttribute ("parent") == "") if (seq->getStatus () != Tt::recurring && seq->getAttribute ("parent") == "")
{ {
T dup (*seq); Tt dup (*seq);
dup.setUUID (uuid ()); // Needs a new UUID. dup.setUUID (uuid ()); // Needs a new UUID.
// Apply deltas. // Apply deltas.
@ -942,10 +942,10 @@ std::string handleColor (Config& conf)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleAnnotate (TDB& tdb, T& task, Config& conf) std::string handleAnnotate (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
std::vector <T> all; std::vector <Tt> all;
tdb.pendingT (all); tdb.pendingT (all);
filterSequence (all, task); filterSequence (all, task);
@ -967,18 +967,18 @@ std::string handleAnnotate (TDB& tdb, T& task, Config& conf)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
T findT (int id, const std::vector <T>& all) Tt findT (int id, const std::vector <Tt>& all)
{ {
std::vector <T>::const_iterator it; std::vector <Tt>::const_iterator it;
for (it = all.begin (); it != all.end (); ++it) for (it = all.begin (); it != all.end (); ++it)
if (id == it->getId ()) if (id == it->getId ())
return *it; return *it;
return T (); return Tt ();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int deltaAppend (T& task, T& delta) int deltaAppend (Tt& task, Tt& delta)
{ {
if (delta.getDescription () != "") if (delta.getDescription () != "")
{ {
@ -994,7 +994,7 @@ int deltaAppend (T& task, T& delta)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int deltaDescription (T& task, T& delta) int deltaDescription (Tt& task, Tt& delta)
{ {
if (delta.getDescription () != "") if (delta.getDescription () != "")
{ {
@ -1006,7 +1006,7 @@ int deltaDescription (T& task, T& delta)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int deltaTags (T& task, T& delta) int deltaTags (Tt& task, Tt& delta)
{ {
int changes = 0; int changes = 0;
@ -1038,7 +1038,7 @@ int deltaTags (T& task, T& delta)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int deltaAttributes (T& task, T& delta) int deltaAttributes (Tt& task, Tt& delta)
{ {
int changes = 0; int changes = 0;
@ -1058,7 +1058,7 @@ int deltaAttributes (T& task, T& delta)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int deltaSubstitutions (T& task, T& delta) int deltaSubstitutions (Tt& task, Tt& delta)
{ {
int changes = 0; int changes = 0;
std::string from; std::string from;

View file

@ -87,14 +87,14 @@ static std::string findDate (
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static std::string formatStatus (T& task) static std::string formatStatus (Tt& task)
{ {
switch (task.getStatus ()) switch (task.getStatus ())
{ {
case T::pending: return "Pending"; break; case Tt::pending: return "Pending"; break;
case T::completed: return "Completed"; break; case Tt::completed: return "Completed"; break;
case T::deleted: return "Deleted"; break; case Tt::deleted: return "Deleted"; break;
case T::recurring: return "Recurring"; break; case Tt::recurring: return "Recurring"; break;
} }
return ""; return "";
@ -103,7 +103,7 @@ static std::string formatStatus (T& task)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static std::string formatDate ( static std::string formatDate (
Config& conf, Config& conf,
T& task, Tt& task,
const std::string& attribute) const std::string& attribute)
{ {
std::string value = task.getAttribute (attribute); std::string value = task.getAttribute (attribute);
@ -117,7 +117,7 @@ static std::string formatDate (
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static std::string formatTask (Config& conf, T task) static std::string formatTask (Config& conf, Tt task)
{ {
std::stringstream before; std::stringstream before;
before << "# The 'task edit <id>' command allows you to modify all aspects of a task" << std::endl before << "# The 'task edit <id>' command allows you to modify all aspects of a task" << std::endl
@ -182,7 +182,7 @@ static std::string formatTask (Config& conf, T task)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static void parseTask (Config& conf, T& task, const std::string& after) static void parseTask (Config& conf, Tt& task, const std::string& after)
{ {
// project // project
std::string value = findValue (after, "Project:"); std::string value = findValue (after, "Project:");
@ -300,7 +300,7 @@ static void parseTask (Config& conf, T& task, const std::string& after)
task.setAttribute ("end", value); task.setAttribute ("end", value);
} }
} }
else if (task.getStatus () != T::deleted) else if (task.getStatus () != Tt::deleted)
throw std::string ("Cannot set a done date on a pending task."); throw std::string ("Cannot set a done date on a pending task.");
} }
else else
@ -308,7 +308,7 @@ static void parseTask (Config& conf, T& task, const std::string& after)
if (task.getAttribute ("end") != "") if (task.getAttribute ("end") != "")
{ {
std::cout << "Done date removed." << std::endl; std::cout << "Done date removed." << std::endl;
task.setStatus (T::pending); task.setStatus (Tt::pending);
task.removeAttribute ("end"); task.removeAttribute ("end");
} }
} }
@ -338,7 +338,7 @@ static void parseTask (Config& conf, T& task, const std::string& after)
{ {
if (task.getAttribute ("due") != "") if (task.getAttribute ("due") != "")
{ {
if (task.getStatus () == T::recurring || if (task.getStatus () == Tt::recurring ||
task.getAttribute ("parent") != "") task.getAttribute ("parent") != "")
{ {
std::cout << "Cannot remove a due date from a recurring task." << std::endl; std::cout << "Cannot remove a due date from a recurring task." << std::endl;
@ -393,7 +393,7 @@ static void parseTask (Config& conf, T& task, const std::string& after)
if (task.getAttribute ("due") != "") if (task.getAttribute ("due") != "")
{ {
task.setAttribute ("recur", value); task.setAttribute ("recur", value);
task.setStatus (T::recurring); task.setStatus (Tt::recurring);
} }
else else
throw std::string ("A recurring task must have a due date."); throw std::string ("A recurring task must have a due date.");
@ -404,7 +404,7 @@ static void parseTask (Config& conf, T& task, const std::string& after)
else else
{ {
std::cout << "Recurrence removed." << std::endl; std::cout << "Recurrence removed." << std::endl;
task.setStatus (T::pending); task.setStatus (Tt::pending);
task.removeAttribute ("recur"); task.removeAttribute ("recur");
task.removeAttribute ("until"); task.removeAttribute ("until");
task.removeAttribute ("mask"); task.removeAttribute ("mask");
@ -491,10 +491,10 @@ static void parseTask (Config& conf, T& task, const std::string& after)
// Introducing the Silver Bullet. This feature is the catch-all fixative for // Introducing the Silver Bullet. This feature is the catch-all fixative for
// various other ills. This is like opening up the hood and going in with a // various other ills. This is like opening up the hood and going in with a
// wrench. To be used sparingly. // wrench. To be used sparingly.
std::string handleEdit (TDB& tdb, T& task, Config& conf) std::string handleEdit (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
std::vector <T> all; std::vector <Tt> all;
tdb.allPendingT (all); tdb.allPendingT (all);
filterSequence (all, task); filterSequence (all, task);
@ -513,7 +513,7 @@ std::string handleEdit (TDB& tdb, T& task, Config& conf)
mkstemp (cpattern); mkstemp (cpattern);
char* file = cpattern; char* file = cpattern;
// Format the contents, T -> text, write to a file. // Format the contents, Tt -> text, write to a file.
std::string before = formatTask (conf, *seq); std::string before = formatTask (conf, *seq);
spit (file, before); spit (file, before);

View file

@ -155,7 +155,7 @@ static fileType determineFileType (const std::vector <std::string>& lines)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static void decorateTask (T& task, Config& conf) static void decorateTask (Tt& task, Config& conf)
{ {
char entryTime[16]; char entryTime[16];
sprintf (entryTime, "%u", (unsigned int) time (NULL)); sprintf (entryTime, "%u", (unsigned int) time (NULL));
@ -227,7 +227,7 @@ static std::string importTask_1_4_3 (
throw "unrecoverable"; throw "unrecoverable";
// Build up this task ready for insertion. // Build up this task ready for insertion.
T task; Tt task;
// Handle the 12 fields. // Handle the 12 fields.
for (unsigned int f = 0; f < fields.size (); ++f) for (unsigned int f = 0; f < fields.size (); ++f)
@ -239,10 +239,10 @@ static std::string importTask_1_4_3 (
break; break;
case 1: // 'status' case 1: // 'status'
if (fields[f] == "'pending'") task.setStatus (T::pending); if (fields[f] == "'pending'") task.setStatus (Tt::pending);
else if (fields[f] == "'recurring'") task.setStatus (T::recurring); else if (fields[f] == "'recurring'") task.setStatus (Tt::recurring);
else if (fields[f] == "'deleted'") task.setStatus (T::deleted); else if (fields[f] == "'deleted'") task.setStatus (Tt::deleted);
else if (fields[f] == "'completed'") task.setStatus (T::completed); else if (fields[f] == "'completed'") task.setStatus (Tt::completed);
break; break;
case 2: // 'tags' case 2: // 'tags'
@ -383,7 +383,7 @@ static std::string importTask_1_5_0 (
throw "unrecoverable"; throw "unrecoverable";
// Build up this task ready for insertion. // Build up this task ready for insertion.
T task; Tt task;
// Handle the 13 fields. // Handle the 13 fields.
for (unsigned int f = 0; f < fields.size (); ++f) for (unsigned int f = 0; f < fields.size (); ++f)
@ -395,10 +395,10 @@ static std::string importTask_1_5_0 (
break; break;
case 1: // 'status' case 1: // 'status'
if (fields[f] == "'pending'") task.setStatus (T::pending); if (fields[f] == "'pending'") task.setStatus (Tt::pending);
else if (fields[f] == "'recurring'") task.setStatus (T::recurring); else if (fields[f] == "'recurring'") task.setStatus (Tt::recurring);
else if (fields[f] == "'deleted'") task.setStatus (T::deleted); else if (fields[f] == "'deleted'") task.setStatus (Tt::deleted);
else if (fields[f] == "'completed'") task.setStatus (T::completed); else if (fields[f] == "'completed'") task.setStatus (Tt::completed);
break; break;
case 2: // 'tags' case 2: // 'tags'
@ -544,7 +544,7 @@ static std::string importTask_1_6_0 (
throw "unrecoverable"; throw "unrecoverable";
// Build up this task ready for insertion. // Build up this task ready for insertion.
T task; Tt task;
// Handle the 13 fields. // Handle the 13 fields.
for (unsigned int f = 0; f < fields.size (); ++f) for (unsigned int f = 0; f < fields.size (); ++f)
@ -556,10 +556,10 @@ static std::string importTask_1_6_0 (
break; break;
case 1: // 'status' case 1: // 'status'
if (fields[f] == "'pending'") task.setStatus (T::pending); if (fields[f] == "'pending'") task.setStatus (Tt::pending);
else if (fields[f] == "'recurring'") task.setStatus (T::recurring); else if (fields[f] == "'recurring'") task.setStatus (Tt::recurring);
else if (fields[f] == "'deleted'") task.setStatus (T::deleted); else if (fields[f] == "'deleted'") task.setStatus (Tt::deleted);
else if (fields[f] == "'completed'") task.setStatus (T::completed); else if (fields[f] == "'completed'") task.setStatus (Tt::completed);
break; break;
case 2: // 'tags' case 2: // 'tags'
@ -670,7 +670,7 @@ static std::string importTaskCmdLine (
std::vector <std::string> args; std::vector <std::string> args;
split (args, std::string ("add ") + line, ' '); split (args, std::string ("add ") + line, ' ');
T task; Tt task;
std::string command; std::string command;
parse (args, command, task, conf); parse (args, command, task, conf);
handleAdd (tdb, task, conf); handleAdd (tdb, task, conf);
@ -776,18 +776,18 @@ static std::string importTodoSh_2_0 (
} }
} }
T task; Tt task;
std::string command; std::string command;
parse (args, command, task, conf); parse (args, command, task, conf);
decorateTask (task, conf); decorateTask (task, conf);
if (isPending) if (isPending)
{ {
task.setStatus (T::pending); task.setStatus (Tt::pending);
} }
else else
{ {
task.setStatus (T::completed); task.setStatus (Tt::completed);
char end[16]; char end[16];
sprintf (end, "%u", (unsigned int) endDate.toEpoch ()); sprintf (end, "%u", (unsigned int) endDate.toEpoch ());
@ -850,7 +850,7 @@ static std::string importText (
std::vector <std::string> args; std::vector <std::string> args;
split (args, std::string ("add ") + line, ' '); split (args, std::string ("add ") + line, ' ');
T task; Tt task;
std::string command; std::string command;
parse (args, command, task, conf); parse (args, command, task, conf);
decorateTask (task, conf); decorateTask (task, conf);
@ -1040,7 +1040,7 @@ static std::string importCSV (
std::vector <std::string> fields; std::vector <std::string> fields;
split (fields, *it, ','); split (fields, *it, ',');
T task; Tt task;
int f; int f;
if ((f = mapping["uuid"]) != -1) if ((f = mapping["uuid"]) != -1)
@ -1050,10 +1050,10 @@ static std::string importCSV (
{ {
std::string value = lowerCase (unquoteText (trim (fields[f]))); std::string value = lowerCase (unquoteText (trim (fields[f])));
if (value == "recurring") task.setStatus (T::recurring); if (value == "recurring") task.setStatus (Tt::recurring);
else if (value == "deleted") task.setStatus (T::deleted); else if (value == "deleted") task.setStatus (Tt::deleted);
else if (value == "completed") task.setStatus (T::completed); else if (value == "completed") task.setStatus (Tt::completed);
else task.setStatus (T::pending); else task.setStatus (Tt::pending);
} }
if ((f = mapping["tags"]) != -1) if ((f = mapping["tags"]) != -1)
@ -1128,7 +1128,7 @@ static std::string importCSV (
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleImport (TDB& tdb, T& task, Config& conf) std::string handleImport (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;

View file

@ -469,7 +469,7 @@ bool validDuration (std::string& input)
void parse ( void parse (
std::vector <std::string>& args, std::vector <std::string>& args,
std::string& command, std::string& command,
T& task, Tt& task,
Config& conf) Config& conf)
{ {
command = ""; command = "";

View file

@ -47,12 +47,12 @@
#endif #endif
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void filterSequence (std::vector<T>& all, T& task) void filterSequence (std::vector<Tt>& all, Tt& task)
{ {
std::vector <int> sequence = task.getAllIds (); std::vector <int> sequence = task.getAllIds ();
std::vector <T> filtered; std::vector <Tt> filtered;
std::vector <T>::iterator t; std::vector <Tt>::iterator t;
for (t = all.begin (); t != all.end (); ++t) for (t = all.begin (); t != all.end (); ++t)
{ {
std::vector <int>::iterator s; std::vector <int>::iterator s;
@ -64,7 +64,7 @@ void filterSequence (std::vector<T>& all, T& task)
if (sequence.size () != filtered.size ()) if (sequence.size () != filtered.size ())
{ {
std::vector <int> filteredSequence; std::vector <int> filteredSequence;
std::vector <T>::iterator fs; std::vector <Tt>::iterator fs;
for (fs = filtered.begin (); fs != filtered.end (); ++fs) for (fs = filtered.begin (); fs != filtered.end (); ++fs)
filteredSequence.push_back (fs->getId ()); filteredSequence.push_back (fs->getId ());
@ -94,9 +94,9 @@ void filterSequence (std::vector<T>& all, T& task)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void filter (std::vector<T>& all, T& task) void filter (std::vector<Tt>& all, Tt& task)
{ {
std::vector <T> filtered; std::vector <Tt> filtered;
// Split any description specified into words. // Split any description specified into words.
std::vector <std::string> descWords; std::vector <std::string> descWords;
@ -113,7 +113,7 @@ void filter (std::vector<T>& all, T& task)
// Iterate over each task, and apply selection criteria. // Iterate over each task, and apply selection criteria.
for (unsigned int i = 0; i < all.size (); ++i) for (unsigned int i = 0; i < all.size (); ++i)
{ {
T refTask (all[i]); Tt refTask (all[i]);
// Apply description filter. // Apply description filter.
std::string desc = lowerCase (refTask.getDescription ()); std::string desc = lowerCase (refTask.getDescription ());
@ -189,7 +189,7 @@ void filter (std::vector<T>& all, T& task)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Successively apply filters based on the task object built from the command // Successively apply filters based on the task object built from the command
// line. Tasks that match all the specified criteria are listed. // line. Tasks that match all the specified criteria are listed.
std::string handleCompleted (TDB& tdb, T& task, Config& conf) std::string handleCompleted (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
@ -205,7 +205,7 @@ std::string handleCompleted (TDB& tdb, T& task, Config& conf)
#endif #endif
// Get the pending tasks. // Get the pending tasks.
std::vector <T> tasks; std::vector <Tt> tasks;
tdb.completedT (tasks); tdb.completedT (tasks);
filter (tasks, task); filter (tasks, task);
@ -244,7 +244,7 @@ std::string handleCompleted (TDB& tdb, T& task, Config& conf)
// Iterate over each task, and apply selection criteria. // Iterate over each task, and apply selection criteria.
for (unsigned int i = 0; i < tasks.size (); ++i) for (unsigned int i = 0; i < tasks.size (); ++i)
{ {
T refTask (tasks[i]); Tt refTask (tasks[i]);
// Now format the matching task. // Now format the matching task.
Date end (::atoi (refTask.getAttribute ("end").c_str ())); Date end (::atoi (refTask.getAttribute ("end").c_str ()));
@ -293,7 +293,7 @@ std::string handleCompleted (TDB& tdb, T& task, Config& conf)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Display all information for the given task. // Display all information for the given task.
std::string handleInfo (TDB& tdb, T& task, Config& conf) std::string handleInfo (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
@ -309,14 +309,14 @@ std::string handleInfo (TDB& tdb, T& task, Config& conf)
#endif #endif
// Get all the tasks. // Get all the tasks.
std::vector <T> tasks; std::vector <Tt> tasks;
tdb.allPendingT (tasks); tdb.allPendingT (tasks);
// Find the task. // Find the task.
int count = 0; int count = 0;
for (unsigned int i = 0; i < tasks.size (); ++i) for (unsigned int i = 0; i < tasks.size (); ++i)
{ {
T refTask (tasks[i]); Tt refTask (tasks[i]);
if (refTask.getId () == task.getId () || task.sequenceContains (refTask.getId ())) if (refTask.getId () == task.getId () || task.sequenceContains (refTask.getId ()))
{ {
@ -348,10 +348,10 @@ std::string handleInfo (TDB& tdb, T& task, Config& conf)
table.addCell (row, 0, "ID"); table.addCell (row, 0, "ID");
table.addCell (row, 1, refTask.getId ()); table.addCell (row, 1, refTask.getId ());
std::string status = refTask.getStatus () == T::pending ? "Pending" std::string status = refTask.getStatus () == Tt::pending ? "Pending"
: refTask.getStatus () == T::completed ? "Completed" : refTask.getStatus () == Tt::completed ? "Completed"
: refTask.getStatus () == T::deleted ? "Deleted" : refTask.getStatus () == Tt::deleted ? "Deleted"
: refTask.getStatus () == T::recurring ? "Recurring" : refTask.getStatus () == Tt::recurring ? "Recurring"
: ""; : "";
if (refTask.getAttribute ("parent") != "") if (refTask.getAttribute ("parent") != "")
status += " (Recurring)"; status += " (Recurring)";
@ -389,7 +389,7 @@ std::string handleInfo (TDB& tdb, T& task, Config& conf)
table.addCell (row, 1, refTask.getAttribute ("priority")); table.addCell (row, 1, refTask.getAttribute ("priority"));
} }
if (refTask.getStatus () == T::recurring || if (refTask.getStatus () == Tt::recurring ||
refTask.getAttribute ("parent") != "") refTask.getAttribute ("parent") != "")
{ {
if (refTask.getAttribute ("recur") != "") if (refTask.getAttribute ("recur") != "")
@ -540,11 +540,11 @@ std::string handleInfo (TDB& tdb, T& task, Config& conf)
// Project Remaining Avg Age Complete 0% 100% // Project Remaining Avg Age Complete 0% 100%
// A 12 13d 55% XXXXXXXXXXXXX----------- // A 12 13d 55% XXXXXXXXXXXXX-----------
// B 109 3d 12h 10% XXX--------------------- // B 109 3d 12h 10% XXX---------------------
std::string handleReportSummary (TDB& tdb, T& task, Config& conf) std::string handleReportSummary (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
std::vector <T> tasks; std::vector <Tt> tasks;
tdb.allT (tasks); tdb.allT (tasks);
handleRecurrence (tdb, tasks); handleRecurrence (tdb, tasks);
filter (tasks, task); filter (tasks, task);
@ -552,7 +552,7 @@ std::string handleReportSummary (TDB& tdb, T& task, Config& conf)
// Generate unique list of project names from all pending tasks. // Generate unique list of project names from all pending tasks.
std::map <std::string, bool> allProjects; std::map <std::string, bool> allProjects;
foreach (t, tasks) foreach (t, tasks)
if (t->getStatus () == T::pending) if (t->getStatus () == Tt::pending)
allProjects[t->getAttribute ("project")] = false; allProjects[t->getAttribute ("project")] = false;
// Initialize counts, sum. // Initialize counts, sum.
@ -577,7 +577,7 @@ std::string handleReportSummary (TDB& tdb, T& task, Config& conf)
std::string project = t->getAttribute ("project"); std::string project = t->getAttribute ("project");
++counter[project]; ++counter[project];
if (t->getStatus () == T::pending) if (t->getStatus () == Tt::pending)
{ {
++countPending[project]; ++countPending[project];
@ -586,7 +586,7 @@ std::string handleReportSummary (TDB& tdb, T& task, Config& conf)
sumEntry[project] = sumEntry[project] + (double) (now - entry); sumEntry[project] = sumEntry[project] + (double) (now - entry);
} }
else if (t->getStatus () == T::completed) else if (t->getStatus () == Tt::completed)
{ {
++countCompleted[project]; ++countCompleted[project];
@ -702,12 +702,12 @@ std::string handleReportSummary (TDB& tdb, T& task, Config& conf)
// //
// Make the "three" tasks a configurable number // Make the "three" tasks a configurable number
// //
std::string handleReportNext (TDB& tdb, T& task, Config& conf) std::string handleReportNext (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
// Load all pending. // Load all pending.
std::vector <T> pending; std::vector <Tt> pending;
tdb.allPendingT (pending); tdb.allPendingT (pending);
handleRecurrence (tdb, pending); handleRecurrence (tdb, pending);
filter (pending, task); filter (pending, task);
@ -728,7 +728,7 @@ std::string handleReportNext (TDB& tdb, T& task, Config& conf)
#endif #endif
// Get the pending tasks. // Get the pending tasks.
std::vector <T> tasks; std::vector <Tt> tasks;
tdb.pendingT (tasks); tdb.pendingT (tasks);
filter (tasks, task); filter (tasks, task);
@ -778,7 +778,7 @@ std::string handleReportNext (TDB& tdb, T& task, Config& conf)
// Iterate over each task, and apply selection criteria. // Iterate over each task, and apply selection criteria.
foreach (i, matching) foreach (i, matching)
{ {
T refTask (pending[*i]); Tt refTask (pending[*i]);
Date now; Date now;
// Now format the matching task. // Now format the matching task.
@ -887,7 +887,7 @@ time_t monthlyEpoch (const std::string& date)
return 0; return 0;
} }
std::string handleReportHistory (TDB& tdb, T& task, Config& conf) std::string handleReportHistory (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
@ -897,13 +897,13 @@ std::string handleReportHistory (TDB& tdb, T& task, Config& conf)
std::map <time_t, int> deletedGroup; std::map <time_t, int> deletedGroup;
// Scan the pending tasks. // Scan the pending tasks.
std::vector <T> pending; std::vector <Tt> pending;
tdb.allPendingT (pending); tdb.allPendingT (pending);
handleRecurrence (tdb, pending); handleRecurrence (tdb, pending);
filter (pending, task); filter (pending, task);
for (unsigned int i = 0; i < pending.size (); ++i) for (unsigned int i = 0; i < pending.size (); ++i)
{ {
T task (pending[i]); Tt task (pending[i]);
time_t epoch = monthlyEpoch (task.getAttribute ("entry")); time_t epoch = monthlyEpoch (task.getAttribute ("entry"));
if (epoch) if (epoch)
{ {
@ -914,7 +914,7 @@ std::string handleReportHistory (TDB& tdb, T& task, Config& conf)
else else
addedGroup[epoch] = 1; addedGroup[epoch] = 1;
if (task.getStatus () == T::deleted) if (task.getStatus () == Tt::deleted)
{ {
epoch = monthlyEpoch (task.getAttribute ("end")); epoch = monthlyEpoch (task.getAttribute ("end"));
groups[epoch] = 0; groups[epoch] = 0;
@ -924,7 +924,7 @@ std::string handleReportHistory (TDB& tdb, T& task, Config& conf)
else else
deletedGroup[epoch] = 1; deletedGroup[epoch] = 1;
} }
else if (task.getStatus () == T::completed) else if (task.getStatus () == Tt::completed)
{ {
epoch = monthlyEpoch (task.getAttribute ("end")); epoch = monthlyEpoch (task.getAttribute ("end"));
groups[epoch] = 0; groups[epoch] = 0;
@ -938,12 +938,12 @@ std::string handleReportHistory (TDB& tdb, T& task, Config& conf)
} }
// Scan the completed tasks. // Scan the completed tasks.
std::vector <T> completed; std::vector <Tt> completed;
tdb.allCompletedT (completed); tdb.allCompletedT (completed);
filter (completed, task); filter (completed, task);
for (unsigned int i = 0; i < completed.size (); ++i) for (unsigned int i = 0; i < completed.size (); ++i)
{ {
T task (completed[i]); Tt task (completed[i]);
time_t epoch = monthlyEpoch (task.getAttribute ("entry")); time_t epoch = monthlyEpoch (task.getAttribute ("entry"));
if (epoch) if (epoch)
{ {
@ -955,7 +955,7 @@ std::string handleReportHistory (TDB& tdb, T& task, Config& conf)
addedGroup[epoch] = 1; addedGroup[epoch] = 1;
epoch = monthlyEpoch (task.getAttribute ("end")); epoch = monthlyEpoch (task.getAttribute ("end"));
if (task.getStatus () == T::deleted) if (task.getStatus () == Tt::deleted)
{ {
epoch = monthlyEpoch (task.getAttribute ("end")); epoch = monthlyEpoch (task.getAttribute ("end"));
groups[epoch] = 0; groups[epoch] = 0;
@ -965,7 +965,7 @@ std::string handleReportHistory (TDB& tdb, T& task, Config& conf)
else else
deletedGroup[epoch] = 1; deletedGroup[epoch] = 1;
} }
else if (task.getStatus () == T::completed) else if (task.getStatus () == Tt::completed)
{ {
epoch = monthlyEpoch (task.getAttribute ("end")); epoch = monthlyEpoch (task.getAttribute ("end"));
groups[epoch] = 0; groups[epoch] = 0;
@ -1079,7 +1079,7 @@ std::string handleReportHistory (TDB& tdb, T& task, Config& conf)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleReportGHistory (TDB& tdb, T& task, Config& conf) std::string handleReportGHistory (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
@ -1101,13 +1101,13 @@ std::string handleReportGHistory (TDB& tdb, T& task, Config& conf)
std::map <time_t, int> deletedGroup; std::map <time_t, int> deletedGroup;
// Scan the pending tasks. // Scan the pending tasks.
std::vector <T> pending; std::vector <Tt> pending;
tdb.allPendingT (pending); tdb.allPendingT (pending);
handleRecurrence (tdb, pending); handleRecurrence (tdb, pending);
filter (pending, task); filter (pending, task);
for (unsigned int i = 0; i < pending.size (); ++i) for (unsigned int i = 0; i < pending.size (); ++i)
{ {
T task (pending[i]); Tt task (pending[i]);
time_t epoch = monthlyEpoch (task.getAttribute ("entry")); time_t epoch = monthlyEpoch (task.getAttribute ("entry"));
if (epoch) if (epoch)
{ {
@ -1118,7 +1118,7 @@ std::string handleReportGHistory (TDB& tdb, T& task, Config& conf)
else else
addedGroup[epoch] = 1; addedGroup[epoch] = 1;
if (task.getStatus () == T::deleted) if (task.getStatus () == Tt::deleted)
{ {
epoch = monthlyEpoch (task.getAttribute ("end")); epoch = monthlyEpoch (task.getAttribute ("end"));
groups[epoch] = 0; groups[epoch] = 0;
@ -1128,7 +1128,7 @@ std::string handleReportGHistory (TDB& tdb, T& task, Config& conf)
else else
deletedGroup[epoch] = 1; deletedGroup[epoch] = 1;
} }
else if (task.getStatus () == T::completed) else if (task.getStatus () == Tt::completed)
{ {
epoch = monthlyEpoch (task.getAttribute ("end")); epoch = monthlyEpoch (task.getAttribute ("end"));
groups[epoch] = 0; groups[epoch] = 0;
@ -1142,12 +1142,12 @@ std::string handleReportGHistory (TDB& tdb, T& task, Config& conf)
} }
// Scan the completed tasks. // Scan the completed tasks.
std::vector <T> completed; std::vector <Tt> completed;
tdb.allCompletedT (completed); tdb.allCompletedT (completed);
filter (completed, task); filter (completed, task);
for (unsigned int i = 0; i < completed.size (); ++i) for (unsigned int i = 0; i < completed.size (); ++i)
{ {
T task (completed[i]); Tt task (completed[i]);
time_t epoch = monthlyEpoch (task.getAttribute ("entry")); time_t epoch = monthlyEpoch (task.getAttribute ("entry"));
if (epoch) if (epoch)
{ {
@ -1159,7 +1159,7 @@ std::string handleReportGHistory (TDB& tdb, T& task, Config& conf)
addedGroup[epoch] = 1; addedGroup[epoch] = 1;
epoch = monthlyEpoch (task.getAttribute ("end")); epoch = monthlyEpoch (task.getAttribute ("end"));
if (task.getStatus () == T::deleted) if (task.getStatus () == Tt::deleted)
{ {
epoch = monthlyEpoch (task.getAttribute ("end")); epoch = monthlyEpoch (task.getAttribute ("end"));
groups[epoch] = 0; groups[epoch] = 0;
@ -1169,7 +1169,7 @@ std::string handleReportGHistory (TDB& tdb, T& task, Config& conf)
else else
deletedGroup[epoch] = 1; deletedGroup[epoch] = 1;
} }
else if (task.getStatus () == T::completed) else if (task.getStatus () == Tt::completed)
{ {
epoch = monthlyEpoch (task.getAttribute ("end")); epoch = monthlyEpoch (task.getAttribute ("end"));
groups[epoch] = 0; groups[epoch] = 0;
@ -1323,7 +1323,7 @@ std::string handleReportGHistory (TDB& tdb, T& task, Config& conf)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleReportTimesheet (TDB& tdb, T& task, Config& conf) std::string handleReportTimesheet (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
@ -1339,7 +1339,7 @@ std::string handleReportTimesheet (TDB& tdb, T& task, Config& conf)
#endif #endif
// Get all the tasks. // Get all the tasks.
std::vector <T> tasks; std::vector <Tt> tasks;
tdb.allT (tasks); tdb.allT (tasks);
filter (tasks, task); filter (tasks, task);
@ -1399,7 +1399,7 @@ std::string handleReportTimesheet (TDB& tdb, T& task, Config& conf)
foreach (t, tasks) foreach (t, tasks)
{ {
// If task completed within range. // If task completed within range.
if (t->getStatus () == T::completed) if (t->getStatus () == Tt::completed)
{ {
Date compDate (::atoi (t->getAttribute ("end").c_str ())); Date compDate (::atoi (t->getAttribute ("end").c_str ()));
if (compDate >= start && compDate < end) if (compDate >= start && compDate < end)
@ -1469,7 +1469,7 @@ std::string handleReportTimesheet (TDB& tdb, T& task, Config& conf)
foreach (t, tasks) foreach (t, tasks)
{ {
// If task started within range, but not completed withing range. // If task started within range, but not completed withing range.
if (t->getStatus () == T::pending && if (t->getStatus () == Tt::pending &&
t->getAttribute ("start") != "") t->getAttribute ("start") != "")
{ {
Date startDate (::atoi (t->getAttribute ("start").c_str ())); Date startDate (::atoi (t->getAttribute ("start").c_str ()));
@ -1530,7 +1530,7 @@ std::string renderMonths (
int firstMonth, int firstMonth,
int firstYear, int firstYear,
const Date& today, const Date& today,
std::vector <T>& all, std::vector <Tt>& all,
Config& conf, Config& conf,
int monthsPerLine) int monthsPerLine)
{ {
@ -1625,7 +1625,7 @@ std::string renderMonths (
today.year () == years.at (c)) today.year () == years.at (c))
table.setCellFg (row, thisCol, Text::cyan); table.setCellFg (row, thisCol, Text::cyan);
std::vector <T>::iterator it; std::vector <Tt>::iterator it;
for (it = all.begin (); it != all.end (); ++it) for (it = all.begin (); it != all.end (); ++it)
{ {
Date due (::atoi (it->getAttribute ("due").c_str ())); Date due (::atoi (it->getAttribute ("due").c_str ()));
@ -1650,7 +1650,7 @@ std::string renderMonths (
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleReportCalendar (TDB& tdb, T& task, Config& conf) std::string handleReportCalendar (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
@ -1675,7 +1675,7 @@ std::string handleReportCalendar (TDB& tdb, T& task, Config& conf)
monthsPerLine = preferredMonthsPerLine; monthsPerLine = preferredMonthsPerLine;
// Load all the pending tasks. // Load all the pending tasks.
std::vector <T> pending; std::vector <Tt> pending;
tdb.allPendingT (pending); tdb.allPendingT (pending);
handleRecurrence (tdb, pending); handleRecurrence (tdb, pending);
filter (pending, task); filter (pending, task);
@ -1683,7 +1683,7 @@ std::string handleReportCalendar (TDB& tdb, T& task, Config& conf)
// Find the oldest pending due date. // Find the oldest pending due date.
Date oldest; Date oldest;
Date newest; Date newest;
std::vector <T>::iterator it; std::vector <Tt>::iterator it;
for (it = pending.begin (); it != pending.end (); ++it) for (it = pending.begin (); it != pending.end (); ++it)
{ {
if (it->getAttribute ("due") != "") if (it->getAttribute ("due") != "")
@ -1759,7 +1759,7 @@ std::string handleReportCalendar (TDB& tdb, T& task, Config& conf)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleReportActive (TDB& tdb, T& task, Config& conf) std::string handleReportActive (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
@ -1775,7 +1775,7 @@ std::string handleReportActive (TDB& tdb, T& task, Config& conf)
#endif #endif
// Get all the tasks. // Get all the tasks.
std::vector <T> tasks; std::vector <Tt> tasks;
tdb.pendingT (tasks); tdb.pendingT (tasks);
filter (tasks, task); filter (tasks, task);
@ -1818,7 +1818,7 @@ std::string handleReportActive (TDB& tdb, T& task, Config& conf)
// Iterate over each task, and apply selection criteria. // Iterate over each task, and apply selection criteria.
for (unsigned int i = 0; i < tasks.size (); ++i) for (unsigned int i = 0; i < tasks.size (); ++i)
{ {
T refTask (tasks[i]); Tt refTask (tasks[i]);
if (refTask.getAttribute ("start") != "") if (refTask.getAttribute ("start") != "")
{ {
Date now; Date now;
@ -1892,7 +1892,7 @@ std::string handleReportActive (TDB& tdb, T& task, Config& conf)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleReportOverdue (TDB& tdb, T& task, Config& conf) std::string handleReportOverdue (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
@ -1908,7 +1908,7 @@ std::string handleReportOverdue (TDB& tdb, T& task, Config& conf)
#endif #endif
// Get all the tasks. // Get all the tasks.
std::vector <T> tasks; std::vector <Tt> tasks;
tdb.pendingT (tasks); tdb.pendingT (tasks);
filter (tasks, task); filter (tasks, task);
@ -1953,7 +1953,7 @@ std::string handleReportOverdue (TDB& tdb, T& task, Config& conf)
// Iterate over each task, and apply selection criteria. // Iterate over each task, and apply selection criteria.
for (unsigned int i = 0; i < tasks.size (); ++i) for (unsigned int i = 0; i < tasks.size (); ++i)
{ {
T refTask (tasks[i]); Tt refTask (tasks[i]);
std::string due; std::string due;
if ((due = refTask.getAttribute ("due")) != "") if ((due = refTask.getAttribute ("due")) != "")
{ {
@ -2015,7 +2015,7 @@ std::string handleReportOverdue (TDB& tdb, T& task, Config& conf)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleReportStats (TDB& tdb, T& task, Config& conf) std::string handleReportStats (TDB& tdb, Tt& task, Config& conf)
{ {
std::stringstream out; std::stringstream out;
@ -2031,7 +2031,7 @@ std::string handleReportStats (TDB& tdb, T& task, Config& conf)
#endif #endif
// Get all the tasks. // Get all the tasks.
std::vector <T> tasks; std::vector <Tt> tasks;
tdb.allT (tasks); tdb.allT (tasks);
filter (tasks, task); filter (tasks, task);
@ -2050,26 +2050,26 @@ std::string handleReportStats (TDB& tdb, T& task, Config& conf)
std::map <std::string, int> allTags; std::map <std::string, int> allTags;
std::map <std::string, int> allProjects; std::map <std::string, int> allProjects;
std::vector <T>::iterator it; std::vector <Tt>::iterator it;
for (it = tasks.begin (); it != tasks.end (); ++it) for (it = tasks.begin (); it != tasks.end (); ++it)
{ {
++totalT; ++totalT;
if (it->getStatus () == T::deleted) ++deletedT; if (it->getStatus () == Tt::deleted) ++deletedT;
if (it->getStatus () == T::pending) ++pendingT; if (it->getStatus () == Tt::pending) ++pendingT;
if (it->getStatus () == T::completed) ++completedT; if (it->getStatus () == Tt::completed) ++completedT;
if (it->getStatus () == T::recurring) ++recurringT; if (it->getStatus () == Tt::recurring) ++recurringT;
time_t entry = ::atoi (it->getAttribute ("entry").c_str ()); time_t entry = ::atoi (it->getAttribute ("entry").c_str ());
if (entry < earliest) earliest = entry; if (entry < earliest) earliest = entry;
if (entry > latest) latest = entry; if (entry > latest) latest = entry;
if (it->getStatus () == T::completed) if (it->getStatus () == Tt::completed)
{ {
time_t end = ::atoi (it->getAttribute ("end").c_str ()); time_t end = ::atoi (it->getAttribute ("end").c_str ());
daysPending += (end - entry) / 86400.0; daysPending += (end - entry) / 86400.0;
} }
if (it->getStatus () == T::pending) if (it->getStatus () == Tt::pending)
daysPending += (now - entry) / 86400.0; daysPending += (now - entry) / 86400.0;
descLength += it->getDescription ().length (); descLength += it->getDescription ().length ();
@ -2215,9 +2215,9 @@ std::string handleReportStats (TDB& tdb, T& task, Config& conf)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void gatherNextTasks ( void gatherNextTasks (
const TDB& tdb, const TDB& tdb,
T& task, Tt& task,
Config& conf, Config& conf,
std::vector <T>& pending, std::vector <Tt>& pending,
std::vector <int>& all) std::vector <int>& all)
{ {
// For counting tasks by project. // For counting tasks by project.
@ -2232,7 +2232,7 @@ void gatherNextTasks (
// due:< 1wk, pri:* // due:< 1wk, pri:*
for (unsigned int i = 0; i < pending.size (); ++i) for (unsigned int i = 0; i < pending.size (); ++i)
{ {
if (pending[i].getStatus () == T::pending) if (pending[i].getStatus () == Tt::pending)
{ {
std::string due = pending[i].getAttribute ("due"); std::string due = pending[i].getAttribute ("due");
if (due != "") if (due != "")
@ -2254,7 +2254,7 @@ void gatherNextTasks (
// due:*, pri:H // due:*, pri:H
for (unsigned int i = 0; i < pending.size (); ++i) for (unsigned int i = 0; i < pending.size (); ++i)
{ {
if (pending[i].getStatus () == T::pending) if (pending[i].getStatus () == Tt::pending)
{ {
std::string due = pending[i].getAttribute ("due"); std::string due = pending[i].getAttribute ("due");
if (due != "") if (due != "")
@ -2276,7 +2276,7 @@ void gatherNextTasks (
// pri:H // pri:H
for (unsigned int i = 0; i < pending.size (); ++i) for (unsigned int i = 0; i < pending.size (); ++i)
{ {
if (pending[i].getStatus () == T::pending) if (pending[i].getStatus () == Tt::pending)
{ {
std::string priority = pending[i].getAttribute ("priority"); std::string priority = pending[i].getAttribute ("priority");
if (priority == "H") if (priority == "H")
@ -2294,7 +2294,7 @@ void gatherNextTasks (
// due:*, pri:M // due:*, pri:M
for (unsigned int i = 0; i < pending.size (); ++i) for (unsigned int i = 0; i < pending.size (); ++i)
{ {
if (pending[i].getStatus () == T::pending) if (pending[i].getStatus () == Tt::pending)
{ {
std::string due = pending[i].getAttribute ("due"); std::string due = pending[i].getAttribute ("due");
if (due != "") if (due != "")
@ -2316,7 +2316,7 @@ void gatherNextTasks (
// pri:M // pri:M
for (unsigned int i = 0; i < pending.size (); ++i) for (unsigned int i = 0; i < pending.size (); ++i)
{ {
if (pending[i].getStatus () == T::pending) if (pending[i].getStatus () == Tt::pending)
{ {
std::string priority = pending[i].getAttribute ("priority"); std::string priority = pending[i].getAttribute ("priority");
if (priority == "M") if (priority == "M")
@ -2334,7 +2334,7 @@ void gatherNextTasks (
// due:*, pri:L // due:*, pri:L
for (unsigned int i = 0; i < pending.size (); ++i) for (unsigned int i = 0; i < pending.size (); ++i)
{ {
if (pending[i].getStatus () == T::pending) if (pending[i].getStatus () == Tt::pending)
{ {
std::string due = pending[i].getAttribute ("due"); std::string due = pending[i].getAttribute ("due");
if (due != "") if (due != "")
@ -2356,7 +2356,7 @@ void gatherNextTasks (
// pri:L // pri:L
for (unsigned int i = 0; i < pending.size (); ++i) for (unsigned int i = 0; i < pending.size (); ++i)
{ {
if (pending[i].getStatus () == T::pending) if (pending[i].getStatus () == Tt::pending)
{ {
std::string priority = pending[i].getAttribute ("priority"); std::string priority = pending[i].getAttribute ("priority");
if (priority == "L") if (priority == "L")
@ -2374,7 +2374,7 @@ void gatherNextTasks (
// due:, pri: // due:, pri:
for (unsigned int i = 0; i < pending.size (); ++i) for (unsigned int i = 0; i < pending.size (); ++i)
{ {
if (pending[i].getStatus () == T::pending) if (pending[i].getStatus () == Tt::pending)
{ {
std::string due = pending[i].getAttribute ("due"); std::string due = pending[i].getAttribute ("due");
if (due == "") if (due == "")
@ -2403,7 +2403,7 @@ void gatherNextTasks (
// via the .taskrc file. // via the .taskrc file.
std::string handleCustomReport ( std::string handleCustomReport (
TDB& tdb, TDB& tdb,
T& task, Tt& task,
Config& conf, Config& conf,
const std::string& report) const std::string& report)
{ {
@ -2447,14 +2447,14 @@ std::string handleCustomReport (
split (filterArgs, filterList, ' '); split (filterArgs, filterList, ' ');
// Load all pending tasks. // Load all pending tasks.
std::vector <T> tasks; std::vector <Tt> tasks;
tdb.allPendingT (tasks); tdb.allPendingT (tasks);
handleRecurrence (tdb, tasks); handleRecurrence (tdb, tasks);
// Apply filters. // Apply filters.
{ {
std::string ignore; std::string ignore;
T filterTask; Tt filterTask;
parse (filterArgs, ignore, filterTask, conf); parse (filterArgs, ignore, filterTask, conf);
filter (tasks, filterTask); // Filter from custom report filter (tasks, filterTask); // Filter from custom report

View file

@ -81,7 +81,7 @@ void initializeColorRules (Config& conf)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void autoColorize ( void autoColorize (
T& task, Tt& task,
Text::color& fg, Text::color& fg,
Text::color& bg, Text::color& bg,
Config& conf) Config& conf)

View file

@ -368,13 +368,13 @@ int main (int argc, char** argv)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void nag (TDB& tdb, T& task, Config& conf) void nag (TDB& tdb, Tt& task, Config& conf)
{ {
std::string nagMessage = conf.get ("nag", std::string ("")); std::string nagMessage = conf.get ("nag", std::string (""));
if (nagMessage != "") if (nagMessage != "")
{ {
// Load all pending tasks. // Load all pending tasks.
std::vector <T> pending; std::vector <Tt> pending;
tdb.allPendingT (pending); tdb.allPendingT (pending);
// Counters. // Counters.
@ -397,7 +397,7 @@ void nag (TDB& tdb, T& task, Config& conf)
if (priority.length ()) if (priority.length ())
pri = priority[0]; pri = priority[0];
} }
else if (t->getStatus () == T::pending) else if (t->getStatus () == Tt::pending)
{ {
if (getDueState (t->getAttribute ("due")) == 2) if (getDueState (t->getAttribute ("due")) == 2)
overdue++; overdue++;
@ -456,14 +456,14 @@ int getDueState (const std::string& due)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Scans all tasks, and for any recurring tasks, determines whether any new // Scans all tasks, and for any recurring tasks, determines whether any new
// child tasks need to be generated to fill gaps. // child tasks need to be generated to fill gaps.
void handleRecurrence (TDB& tdb, std::vector <T>& tasks) void handleRecurrence (TDB& tdb, std::vector <Tt>& tasks)
{ {
std::vector <T> modified; std::vector <Tt> modified;
// Look at all tasks and find any recurring ones. // Look at all tasks and find any recurring ones.
foreach (t, tasks) foreach (t, tasks)
{ {
if (t->getStatus () == T::recurring) if (t->getStatus () == Tt::recurring)
{ {
// Generate a list of due dates for this recurring task, regardless of // Generate a list of due dates for this recurring task, regardless of
// the mask. // the mask.
@ -480,7 +480,7 @@ void handleRecurrence (TDB& tdb, std::vector <T>& tasks)
char endTime[16]; char endTime[16];
sprintf (endTime, "%u", (unsigned int) time (NULL)); sprintf (endTime, "%u", (unsigned int) time (NULL));
t->setAttribute ("end", endTime); t->setAttribute ("end", endTime);
t->setStatus (T::deleted); t->setStatus (Tt::deleted);
tdb.modifyT (*t); tdb.modifyT (*t);
continue; continue;
} }
@ -498,10 +498,10 @@ void handleRecurrence (TDB& tdb, std::vector <T>& tasks)
mask += '-'; mask += '-';
changed = true; changed = true;
T rec (*t); // Clone the parent. Tt rec (*t); // Clone the parent.
rec.setId (tdb.nextId ()); // Assign a unique id. rec.setId (tdb.nextId ()); // Assign a unique id.
rec.setUUID (uuid ()); // New UUID. rec.setUUID (uuid ()); // New UUID.
rec.setStatus (T::pending); // Shiny. rec.setStatus (Tt::pending); // Shiny.
rec.setAttribute ("parent", t->getUUID ()); // Remember mom. rec.setAttribute ("parent", t->getUUID ()); // Remember mom.
char dueDate[16]; char dueDate[16];
@ -541,7 +541,7 @@ void handleRecurrence (TDB& tdb, std::vector <T>& tasks)
// period (recur). Then generate a set of corresponding dates. // period (recur). Then generate a set of corresponding dates.
// //
// Returns false if the parent recurring task is depleted. // Returns false if the parent recurring task is depleted.
bool generateDueDates (T& parent, std::vector <Date>& allDue) bool generateDueDates (Tt& parent, std::vector <Date>& allDue)
{ {
// Determine due date, recur period and until date. // Determine due date, recur period and until date.
Date due (atoi (parent.getAttribute ("due").c_str ())); Date due (atoi (parent.getAttribute ("due").c_str ()));
@ -726,13 +726,13 @@ Date getNextRecurrence (Date& current, std::string& period)
// update it's mask. // update it's mask.
void updateRecurrenceMask ( void updateRecurrenceMask (
TDB& tdb, TDB& tdb,
std::vector <T>& all, std::vector <Tt>& all,
T& task) Tt& task)
{ {
std::string parent = task.getAttribute ("parent"); std::string parent = task.getAttribute ("parent");
if (parent != "") if (parent != "")
{ {
std::vector <T>::iterator it; std::vector <Tt>::iterator it;
for (it = all.begin (); it != all.end (); ++it) for (it = all.begin (); it != all.end (); ++it)
{ {
if (it->getUUID () == parent) if (it->getUUID () == parent)
@ -741,9 +741,9 @@ void updateRecurrenceMask (
std::string mask = it->getAttribute ("mask"); std::string mask = it->getAttribute ("mask");
if (mask.length () > index) if (mask.length () > index)
{ {
mask[index] = (task.getStatus () == T::pending) ? '-' mask[index] = (task.getStatus () == Tt::pending) ? '-'
: (task.getStatus () == T::completed) ? '+' : (task.getStatus () == Tt::completed) ? '+'
: (task.getStatus () == T::deleted) ? 'X' : (task.getStatus () == Tt::deleted) ? 'X'
: '?'; : '?';
it->setAttribute ("mask", mask); it->setAttribute ("mask", mask);
@ -755,9 +755,9 @@ void updateRecurrenceMask (
for (unsigned int i = 0; i < index; ++i) for (unsigned int i = 0; i < index; ++i)
mask += "?"; mask += "?";
mask += (task.getStatus () == T::pending) ? '-' mask += (task.getStatus () == Tt::pending) ? '-'
: (task.getStatus () == T::completed) ? '+' : (task.getStatus () == Tt::completed) ? '+'
: (task.getStatus () == T::deleted) ? 'X' : (task.getStatus () == Tt::deleted) ? 'X'
: '?'; : '?';
} }
@ -858,7 +858,7 @@ std::string runTaskCommand (
loadCustomReports (conf); loadCustomReports (conf);
std::string command; std::string command;
T task; Tt task;
parse (args, command, task, conf); parse (args, command, task, conf);
bool gcMod = false; // Change occurred by way of gc. bool gcMod = false; // Change occurred by way of gc.

View file

@ -54,7 +54,7 @@ for (typeof (c) *foreach_p = & (c); \
++i) ++i)
// parse.cpp // parse.cpp
void parse (std::vector <std::string>&, std::string&, T&, Config&); void parse (std::vector <std::string>&, std::string&, Tt&, Config&);
bool validPriority (const std::string&); bool validPriority (const std::string&);
bool validDate (std::string&, Config&); bool validDate (std::string&, Config&);
bool validDuration (std::string&); bool validDuration (std::string&);
@ -63,60 +63,60 @@ bool isCustomReport (const std::string&);
void allCustomReports (std::vector <std::string>&); void allCustomReports (std::vector <std::string>&);
// task.cpp // task.cpp
void gatherNextTasks (const TDB&, T&, Config&, std::vector <T>&, std::vector <int>&); void gatherNextTasks (const TDB&, Tt&, Config&, std::vector <Tt>&, std::vector <int>&);
void nag (TDB&, T&, Config&); void nag (TDB&, Tt&, Config&);
int getDueState (const std::string&); int getDueState (const std::string&);
void handleRecurrence (TDB&, std::vector <T>&); void handleRecurrence (TDB&, std::vector <Tt>&);
bool generateDueDates (T&, std::vector <Date>&); bool generateDueDates (Tt&, std::vector <Date>&);
Date getNextRecurrence (Date&, std::string&); Date getNextRecurrence (Date&, std::string&);
void updateRecurrenceMask (TDB&, std::vector <T>&, T&); void updateRecurrenceMask (TDB&, std::vector <Tt>&, Tt&);
void onChangeCallback (); void onChangeCallback ();
std::string runTaskCommand (int, char**, TDB&, Config&, bool gc = true, bool shadow = true); std::string runTaskCommand (int, char**, TDB&, Config&, bool gc = true, bool shadow = true);
std::string runTaskCommand (std::vector <std::string>&, TDB&, Config&, bool gc = false, bool shadow = false); std::string runTaskCommand (std::vector <std::string>&, TDB&, Config&, bool gc = false, bool shadow = false);
// command.cpp // command.cpp
std::string handleAdd (TDB&, T&, Config&); std::string handleAdd (TDB&, Tt&, Config&);
std::string handleAppend (TDB&, T&, Config&); std::string handleAppend (TDB&, Tt&, Config&);
std::string handleExport (TDB&, T&, Config&); std::string handleExport (TDB&, Tt&, Config&);
std::string handleDone (TDB&, T&, Config&); std::string handleDone (TDB&, Tt&, Config&);
std::string handleModify (TDB&, T&, Config&); std::string handleModify (TDB&, Tt&, Config&);
std::string handleProjects (TDB&, T&, Config&); std::string handleProjects (TDB&, Tt&, Config&);
std::string handleTags (TDB&, T&, Config&); std::string handleTags (TDB&, Tt&, Config&);
std::string handleUndelete (TDB&, T&, Config&); std::string handleUndelete (TDB&, Tt&, Config&);
std::string handleVersion (Config&); std::string handleVersion (Config&);
std::string handleDelete (TDB&, T&, Config&); std::string handleDelete (TDB&, Tt&, Config&);
std::string handleStart (TDB&, T&, Config&); std::string handleStart (TDB&, Tt&, Config&);
std::string handleStop (TDB&, T&, Config&); std::string handleStop (TDB&, Tt&, Config&);
std::string handleUndo (TDB&, T&, Config&); std::string handleUndo (TDB&, Tt&, Config&);
std::string handleColor (Config&); std::string handleColor (Config&);
std::string handleAnnotate (TDB&, T&, Config&); std::string handleAnnotate (TDB&, Tt&, Config&);
std::string handleDuplicate (TDB&, T&, Config&); std::string handleDuplicate (TDB&, Tt&, Config&);
T findT (int, const std::vector <T>&); Tt findT (int, const std::vector <Tt>&);
int deltaAppend (T&, T&); int deltaAppend (Tt&, Tt&);
int deltaDescription (T&, T&); int deltaDescription (Tt&, Tt&);
int deltaTags (T&, T&); int deltaTags (Tt&, Tt&);
int deltaAttributes (T&, T&); int deltaAttributes (Tt&, Tt&);
int deltaSubstitutions (T&, T&); int deltaSubstitutions (Tt&, Tt&);
// edit.cpp // edit.cpp
std::string handleEdit (TDB&, T&, Config&); std::string handleEdit (TDB&, Tt&, Config&);
// report.cpp // report.cpp
void filterSequence (std::vector<T>&, T&); void filterSequence (std::vector<Tt>&, Tt&);
void filter (std::vector<T>&, T&); void filter (std::vector<Tt>&, Tt&);
std::string handleInfo (TDB&, T&, Config&); std::string handleInfo (TDB&, Tt&, Config&);
std::string handleCompleted (TDB&, T&, Config&); std::string handleCompleted (TDB&, Tt&, Config&);
std::string handleReportSummary (TDB&, T&, Config&); std::string handleReportSummary (TDB&, Tt&, Config&);
std::string handleReportNext (TDB&, T&, Config&); std::string handleReportNext (TDB&, Tt&, Config&);
std::string handleReportHistory (TDB&, T&, Config&); std::string handleReportHistory (TDB&, Tt&, Config&);
std::string handleReportGHistory (TDB&, T&, Config&); std::string handleReportGHistory (TDB&, Tt&, Config&);
std::string handleReportCalendar (TDB&, T&, Config&); std::string handleReportCalendar (TDB&, Tt&, Config&);
std::string handleReportActive (TDB&, T&, Config&); std::string handleReportActive (TDB&, Tt&, Config&);
std::string handleReportOverdue (TDB&, T&, Config&); std::string handleReportOverdue (TDB&, Tt&, Config&);
std::string handleReportStats (TDB&, T&, Config&); std::string handleReportStats (TDB&, Tt&, Config&);
std::string handleReportTimesheet (TDB&, T&, Config&); std::string handleReportTimesheet (TDB&, Tt&, Config&);
std::string handleCustomReport (TDB&, T&, Config&, const std::string&); std::string handleCustomReport (TDB&, Tt&, Config&, const std::string&);
void validReportColumns (const std::vector <std::string>&); void validReportColumns (const std::vector <std::string>&);
void validSortColumns (const std::vector <std::string>&, const std::vector <std::string>&); void validSortColumns (const std::vector <std::string>&, const std::vector <std::string>&);
@ -160,10 +160,10 @@ void spit (const std::string&, const std::string&);
// rules.cpp // rules.cpp
void initializeColorRules (Config&); void initializeColorRules (Config&);
void autoColorize (T&, Text::color&, Text::color&, Config&); void autoColorize (Tt&, Text::color&, Text::color&, Config&);
// import.cpp // import.cpp
std::string handleImport (TDB&, T&, Config&); std::string handleImport (TDB&, Tt&, Config&);
// list template // list template
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////