diff --git a/AUTHORS b/AUTHORS index 5dc52124c..a769a203b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -33,4 +33,5 @@ With thanks to: Eric Farris Bruce Dillahunty Askme Too + Mike Adonay diff --git a/ChangeLog b/ChangeLog index 7d524cbe1..b28939e8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ ------ 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) + Improved the errors when parsing a corrupt or unrecognized pending.data or completed.data file (thanks to T. Charles Yun). diff --git a/src/T.cpp b/src/T.cpp index 58a280f62..3e98c5ada 100644 --- a/src/T.cpp +++ b/src/T.cpp @@ -32,7 +32,7 @@ //////////////////////////////////////////////////////////////////////////////// // Default -T::T () +Tt::Tt () { mUUID = uuid (); mStatus = pending; @@ -49,13 +49,13 @@ T::T () //////////////////////////////////////////////////////////////////////////////// // Initialize by parsing storage format -T::T (const std::string& line) +Tt::Tt (const std::string& line) { parse (line); } //////////////////////////////////////////////////////////////////////////////// -T::T (const T& other) +Tt::Tt (const Tt& other) { mStatus = other.mStatus; 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) { @@ -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 ::const_iterator it = find (mTags.begin (), mTags.end (), tag); if (it != mTags.end ()) @@ -104,38 +104,38 @@ bool T::hasTag (const std::string& tag) const //////////////////////////////////////////////////////////////////////////////// // SPECIAL METHOD - DO NOT REMOVE -void T::getRemoveTags (std::vector& all) +void Tt::getRemoveTags (std::vector& all) { all = mRemoveTags; } //////////////////////////////////////////////////////////////////////////////// // 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) - throw std::string ("T::addRemoveTag - tags may not contain spaces"); + throw std::string ("Tt::addRemoveTag - tags may not contain spaces"); mRemoveTags.push_back (tag); } //////////////////////////////////////////////////////////////////////////////// -int T::getTagCount () const +int Tt::getTagCount () const { return mTags.size (); } //////////////////////////////////////////////////////////////////////////////// -void T::getTags (std::vector& all) const +void Tt::getTags (std::vector& all) const { all = mTags; } //////////////////////////////////////////////////////////////////////////////// -void T::addTag (const std::string& tag) +void Tt::addTag (const std::string& tag) { 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] == '+') { @@ -150,12 +150,12 @@ void T::addTag (const std::string& tag) } //////////////////////////////////////////////////////////////////////////////// -void T::addTags (const std::vector & tags) +void Tt::addTags (const std::vector & tags) { for (size_t i = 0; i < tags.size (); ++i) { 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] == '+') { @@ -171,7 +171,7 @@ void T::addTags (const std::vector & tags) } //////////////////////////////////////////////////////////////////////////////// -void T::removeTag (const std::string& tag) +void Tt::removeTag (const std::string& tag) { std::vector copy; 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 (); } //////////////////////////////////////////////////////////////////////////////// -void T::getAttributes (std::map& all) +void Tt::getAttributes (std::map& all) { 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 ()) 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) 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 & attributes) +void Tt::setAttributes (const std::map & attributes) { foreach (i, attributes) { @@ -230,13 +230,13 @@ void T::setAttributes (const std::map & attributes) } //////////////////////////////////////////////////////////////////////////////// -void T::removeAttributes () +void Tt::removeAttributes () { mAttributes.clear (); } //////////////////////////////////////////////////////////////////////////////// -void T::removeAttribute (const std::string& name) +void Tt::removeAttribute (const std::string& name) { std::map copy = mAttributes; mAttributes.clear (); @@ -246,7 +246,7 @@ void T::removeAttribute (const std::string& name) } //////////////////////////////////////////////////////////////////////////////// -void T::getSubstitution ( +void Tt::getSubstitution ( std::string& from, std::string& to, bool& global) const @@ -257,7 +257,7 @@ void T::getSubstitution ( } //////////////////////////////////////////////////////////////////////////////// -void T::setSubstitution ( +void Tt::setSubstitution ( const std::string& from, const std::string& to, bool global) @@ -268,19 +268,19 @@ void T::setSubstitution ( } //////////////////////////////////////////////////////////////////////////////// -void T::getAnnotations (std::map & all) const +void Tt::getAnnotations (std::map & all) const { all = mAnnotations; } //////////////////////////////////////////////////////////////////////////////// -void T::setAnnotations (const std::map & all) +void Tt::setAnnotations (const std::map & all) { mAnnotations = all; } //////////////////////////////////////////////////////////////////////////////// -void T::addAnnotation (const std::string& description) +void Tt::addAnnotation (const std::string& description) { std::string sanitized = description; 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) if (*seq == id) @@ -308,7 +308,7 @@ bool T::sequenceContains (int id) const // attributes \w+:\w+ \s ... // description .+ // -const std::string T::compose () const +const std::string Tt::compose () const { // UUID 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 std::string line = "'" + mUUID + "',"; @@ -441,7 +441,7 @@ const std::string T::composeCSV () //////////////////////////////////////////////////////////////////////////////// // 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)) { @@ -659,7 +659,7 @@ void T::parse (const std::string& line) //////////////////////////////////////////////////////////////////////////////// // 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: // @@ -721,7 +721,7 @@ int T::determineVersion (const std::string& line) //////////////////////////////////////////////////////////////////////////////// // 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 entry < until, due, start, end diff --git a/src/T.h b/src/T.h index fac345efa..128bc992b 100644 --- a/src/T.h +++ b/src/T.h @@ -24,8 +24,8 @@ // USA // //////////////////////////////////////////////////////////////////////////////// -#ifndef INCLUDED_T -#define INCLUDED_T +#ifndef INCLUDED_Tt +#define INCLUDED_Tt #include #include @@ -34,16 +34,16 @@ // Length of longest line. #define T_LINE_MAX 32768 -class T +class Tt { public: enum status {pending, completed, deleted, recurring}; - T (); // Default constructor - T (const std::string&); // Initialize by parsing storage format - T (const T&); // Copy constructor - T& operator= (const T&); // Assignment operator - ~T (); // Destructor + Tt (); // Default constructor + Tt (const std::string&); // Initialize by parsing storage format + Tt (const Tt&); // Copy constructor + Tt& operator= (const Tt&); // Assignment operator + ~Tt (); // Destructor std::string getUUID () const { return mUUID; } void setUUID (const std::string& uuid) { mUUID = uuid; } diff --git a/src/TDB.cpp b/src/TDB.cpp index 98c2c8009..87e103bc3 100644 --- a/src/TDB.cpp +++ b/src/TDB.cpp @@ -68,20 +68,20 @@ void TDB::dataDirectory (const std::string& directory) //////////////////////////////////////////////////////////////////////////////// // Combine allPendingT with allCompletedT. // Note: this method is O(N1) + O(N2), where N2 is not bounded. -bool TDB::allT (std::vector & all) +bool TDB::allT (std::vector & all) { all.clear (); // Retrieve all the pending records. - std::vector allp; + std::vector allp; if (allPendingT (allp)) { - std::vector ::iterator i; + std::vector ::iterator i; for (i = allp.begin (); i != allp.end (); ++i) all.push_back (*i); // Retrieve all the completed records. - std::vector allc; + std::vector allc; if (allCompletedT (allc)) { for (i = allc.begin (); i != allc.end (); ++i) @@ -96,7 +96,7 @@ bool TDB::allT (std::vector & all) //////////////////////////////////////////////////////////////////////////////// // Only accesses to the pending file result in Tasks that have assigned ids. -bool TDB::pendingT (std::vector & all) +bool TDB::pendingT (std::vector & all) { all.clear (); @@ -111,9 +111,9 @@ bool TDB::pendingT (std::vector & all) { try { - T t (*it); + Tt t (*it); t.setId (mId++); - if (t.getStatus () == T::pending) + if (t.getStatus () == Tt::pending) all.push_back (t); } @@ -136,7 +136,7 @@ bool TDB::pendingT (std::vector & all) //////////////////////////////////////////////////////////////////////////////// // Only accesses to the pending file result in Tasks that have assigned ids. -bool TDB::allPendingT (std::vector & all) +bool TDB::allPendingT (std::vector & all) { all.clear (); @@ -151,7 +151,7 @@ bool TDB::allPendingT (std::vector & all) { try { - T t (*it); + Tt t (*it); t.setId (mId++); all.push_back (t); } @@ -174,7 +174,7 @@ bool TDB::allPendingT (std::vector & all) } //////////////////////////////////////////////////////////////////////////////// -bool TDB::completedT (std::vector & all) const +bool TDB::completedT (std::vector & all) const { all.clear (); @@ -187,8 +187,8 @@ bool TDB::completedT (std::vector & all) const { try { - T t (*it); - if (t.getStatus () != T::deleted) + Tt t (*it); + if (t.getStatus () != Tt::deleted) all.push_back (t); } @@ -210,7 +210,7 @@ bool TDB::completedT (std::vector & all) const } //////////////////////////////////////////////////////////////////////////////// -bool TDB::allCompletedT (std::vector & all) const +bool TDB::allCompletedT (std::vector & all) const { all.clear (); @@ -223,7 +223,7 @@ bool TDB::allCompletedT (std::vector & all) const { try { - T t (*it); + Tt t (*it); all.push_back (t); } @@ -245,9 +245,9 @@ bool TDB::allCompletedT (std::vector & all) const } //////////////////////////////////////////////////////////////////////////////// -bool TDB::addT (const T& t) +bool TDB::addT (const Tt& t) { - T task (t); + Tt task (t); std::vector tags; task.getTags (tags); @@ -262,8 +262,8 @@ bool TDB::addT (const T& t) } } - if (task.getStatus () == T::pending || - task.getStatus () == T::recurring) + if (task.getStatus () == Tt::pending || + task.getStatus () == Tt::recurring) { 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 all; + std::vector all; allPendingT (all); - std::vector pending; + std::vector pending; - std::vector ::iterator it; + std::vector ::iterator it; for (it = all.begin (); it != all.end (); ++it) { if (it->getId () == t.getId ()) @@ -306,7 +306,7 @@ bool TDB::lock (FILE* file) const } //////////////////////////////////////////////////////////////////////////////// -bool TDB::overwritePending (std::vector & all) +bool TDB::overwritePending (std::vector & all) { // Write a single task to the pending file FILE* out; @@ -317,7 +317,7 @@ bool TDB::overwritePending (std::vector & all) while (flock (fileno (out), LOCK_EX) && ++retry <= 3) delay (0.1); - std::vector ::iterator it; + std::vector ::iterator it; for (it = all.begin (); it != all.end (); ++it) fputs (it->compose ().c_str (), out); @@ -329,7 +329,7 @@ bool TDB::overwritePending (std::vector & all) } //////////////////////////////////////////////////////////////////////////////// -bool TDB::writePending (const T& t) +bool TDB::writePending (const Tt& t) { // Write a single task to the pending file 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 FILE* out; @@ -414,18 +414,18 @@ int TDB::gc () int count = 0; // Read everything from the pending file. - std::vector all; + std::vector all; allPendingT (all); // A list of the truly pending tasks. - std::vector pending; + std::vector pending; - std::vector::iterator it; + std::vector::iterator it; for (it = all.begin (); it != all.end (); ++it) { // Some tasks stay in the pending file. - if (it->getStatus () == T::pending || - it->getStatus () == T::recurring) + if (it->getStatus () == Tt::pending || + it->getStatus () == Tt::recurring) { pending.push_back (*it); } diff --git a/src/TDB.h b/src/TDB.h index e2c0257ec..552e46638 100644 --- a/src/TDB.h +++ b/src/TDB.h @@ -38,13 +38,13 @@ public: ~TDB (); void dataDirectory (const std::string&); - bool allT (std::vector &); - bool pendingT (std::vector &); - bool allPendingT (std::vector &); - bool completedT (std::vector &) const; - bool allCompletedT (std::vector &) const; - bool addT (const T&); - bool modifyT (const T&); + bool allT (std::vector &); + bool pendingT (std::vector &); + bool allPendingT (std::vector &); + bool completedT (std::vector &) const; + bool allCompletedT (std::vector &) const; + bool addT (const Tt&); + bool modifyT (const Tt&); int gc (); int nextId (); @@ -52,9 +52,9 @@ public: private: bool lock (FILE*) const; - bool overwritePending (std::vector &); - bool writePending (const T&); - bool writeCompleted (const T&); + bool overwritePending (std::vector &); + bool writePending (const Tt&); + bool writeCompleted (const Tt&); bool readLockedFile (const std::string&, std::vector &) const; private: diff --git a/src/command.cpp b/src/command.cpp index 4a89427e1..471fc371c 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -41,7 +41,7 @@ #endif //////////////////////////////////////////////////////////////////////////////// -std::string handleAdd (TDB& tdb, T& task, Config& conf) +std::string handleAdd (TDB& tdb, Tt& task, Config& conf) { std::stringstream out; @@ -59,7 +59,7 @@ std::string handleAdd (TDB& tdb, T& task, Config& conf) if (task.getAttribute ("due") != "" && task.getAttribute ("recur") != "") { - task.setStatus (T::recurring); + task.setStatus (Tt::recurring); 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; // Get all the tasks, including deleted ones. - std::vector tasks; + std::vector tasks; tdb.pendingT (tasks); // 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 unique; for (unsigned int i = 0; i < tasks.size (); ++i) { - T task (tasks[i]); + Tt task (tasks[i]); 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; // Get all the tasks. - std::vector tasks; + std::vector tasks; tdb.pendingT (tasks); // 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 unique; for (unsigned int i = 0; i < tasks.size (); ++i) { - T task (tasks[i]); + Tt task (tasks[i]); std::vector 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 // 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::vector all; + std::vector all; tdb.allPendingT (all); filterSequence (all, task); foreach (t, all) { - if (t->getStatus () == T::deleted) + if (t->getStatus () == Tt::deleted) { if (t->getAttribute ("recur") != "") out << "Task does not support 'undo' for recurring tasks.\n"; - t->setStatus (T::pending); + t->setStatus (Tt::pending); t->removeAttribute ("end"); 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 // 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::vector all; + std::vector all; tdb.allPendingT (all); filterSequence (all, task); foreach (t, all) { - if (t->getStatus () == T::completed) + if (t->getStatus () == Tt::completed) { if (t->getAttribute ("recur") != "") out << "Task does not support 'undo' for recurring tasks.\n"; - t->setStatus (T::pending); + t->setStatus (Tt::pending); t->removeAttribute ("end"); 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::vector all; + std::vector all; tdb.allPendingT (all); filterSequence (all, task); @@ -455,7 +455,7 @@ std::string handleDelete (TDB& tdb, T& task, Config& conf) if (sibling->getAttribute ("parent") == parent || sibling->getUUID () == parent) { - sibling->setStatus (T::deleted); + sibling->setStatus (Tt::deleted); sibling->setAttribute ("end", endTime); tdb.modifyT (*sibling); @@ -472,7 +472,7 @@ std::string handleDelete (TDB& tdb, T& task, Config& conf) else { // Update mask in parent. - t->setStatus (T::deleted); + t->setStatus (Tt::deleted); updateRecurrenceMask (tdb, all, *t); t->setAttribute ("end", endTime); @@ -488,7 +488,7 @@ std::string handleDelete (TDB& tdb, T& task, Config& conf) } else { - t->setStatus (T::deleted); + t->setStatus (Tt::deleted); t->setAttribute ("end", endTime); 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::vector all; + std::vector all; tdb.pendingT (all); 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::vector all; + std::vector all; tdb.pendingT (all); 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; std::stringstream out; - std::vector all; + std::vector all; tdb.allPendingT (all); - std::vector filtered = all; + std::vector filtered = all; filterSequence (filtered, task); foreach (seq, filtered) { - if (seq->getStatus () == T::pending) + if (seq->getStatus () == Tt::pending) { // Apply deltas. deltaDescription (*seq, task); @@ -599,7 +599,7 @@ std::string handleDone (TDB& tdb, T& task, Config& conf) seq->setAttribute ("end", entryTime); // Change status. - seq->setStatus (T::completed); + seq->setStatus (Tt::completed); if (!tdb.modifyT (*seq)) 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; @@ -669,13 +669,13 @@ std::string handleExport (TDB& tdb, T& task, Config& conf) << "\n"; int count = 0; - std::vector all; + std::vector all; tdb.allPendingT (all); filter (all, task); foreach (t, all) { - if (t->getStatus () != T::recurring && - t->getStatus () != T::deleted) + if (t->getStatus () != Tt::recurring && + t->getStatus () != Tt::deleted) { out << t->composeCSV ().c_str (); ++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; std::stringstream out; - std::vector all; + std::vector all; tdb.allPendingT (all); - std::vector filtered = all; + std::vector filtered = all; filterSequence (filtered, task); 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; std::stringstream out; - std::vector all; + std::vector all; tdb.allPendingT (all); - std::vector filtered = all; + std::vector filtered = all; filterSequence (filtered, task); 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; std::stringstream out; - std::vector all; + std::vector all; tdb.allPendingT (all); - std::vector filtered = all; + std::vector filtered = all; filterSequence (filtered, task); 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. // 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::vector all; + std::vector all; tdb.pendingT (all); filterSequence (all, task); @@ -967,18 +967,18 @@ std::string handleAnnotate (TDB& tdb, T& task, Config& conf) } //////////////////////////////////////////////////////////////////////////////// -T findT (int id, const std::vector & all) +Tt findT (int id, const std::vector & all) { - std::vector ::const_iterator it; + std::vector ::const_iterator it; for (it = all.begin (); it != all.end (); ++it) if (id == it->getId ()) return *it; - return T (); + return Tt (); } //////////////////////////////////////////////////////////////////////////////// -int deltaAppend (T& task, T& delta) +int deltaAppend (Tt& task, Tt& delta) { 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 () != "") { @@ -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; @@ -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; @@ -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; std::string from; diff --git a/src/edit.cpp b/src/edit.cpp index 445e8a1c6..b52a63224 100644 --- a/src/edit.cpp +++ b/src/edit.cpp @@ -87,14 +87,14 @@ static std::string findDate ( } //////////////////////////////////////////////////////////////////////////////// -static std::string formatStatus (T& task) +static std::string formatStatus (Tt& task) { switch (task.getStatus ()) { - case T::pending: return "Pending"; break; - case T::completed: return "Completed"; break; - case T::deleted: return "Deleted"; break; - case T::recurring: return "Recurring"; break; + case Tt::pending: return "Pending"; break; + case Tt::completed: return "Completed"; break; + case Tt::deleted: return "Deleted"; break; + case Tt::recurring: return "Recurring"; break; } return ""; @@ -103,7 +103,7 @@ static std::string formatStatus (T& task) //////////////////////////////////////////////////////////////////////////////// static std::string formatDate ( Config& conf, - T& task, + Tt& task, const std::string& 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; before << "# The 'task edit ' 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 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); } } - else if (task.getStatus () != T::deleted) + else if (task.getStatus () != Tt::deleted) throw std::string ("Cannot set a done date on a pending task."); } else @@ -308,7 +308,7 @@ static void parseTask (Config& conf, T& task, const std::string& after) if (task.getAttribute ("end") != "") { std::cout << "Done date removed." << std::endl; - task.setStatus (T::pending); + task.setStatus (Tt::pending); task.removeAttribute ("end"); } } @@ -338,7 +338,7 @@ static void parseTask (Config& conf, T& task, const std::string& after) { if (task.getAttribute ("due") != "") { - if (task.getStatus () == T::recurring || + if (task.getStatus () == Tt::recurring || task.getAttribute ("parent") != "") { 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") != "") { task.setAttribute ("recur", value); - task.setStatus (T::recurring); + task.setStatus (Tt::recurring); } else 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 { std::cout << "Recurrence removed." << std::endl; - task.setStatus (T::pending); + task.setStatus (Tt::pending); task.removeAttribute ("recur"); task.removeAttribute ("until"); 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 // various other ills. This is like opening up the hood and going in with a // 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::vector all; + std::vector all; tdb.allPendingT (all); filterSequence (all, task); @@ -513,7 +513,7 @@ std::string handleEdit (TDB& tdb, T& task, Config& conf) mkstemp (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); spit (file, before); diff --git a/src/import.cpp b/src/import.cpp index 163dca30d..759dae96e 100644 --- a/src/import.cpp +++ b/src/import.cpp @@ -155,7 +155,7 @@ static fileType determineFileType (const std::vector & lines) } //////////////////////////////////////////////////////////////////////////////// -static void decorateTask (T& task, Config& conf) +static void decorateTask (Tt& task, Config& conf) { char entryTime[16]; sprintf (entryTime, "%u", (unsigned int) time (NULL)); @@ -227,7 +227,7 @@ static std::string importTask_1_4_3 ( throw "unrecoverable"; // Build up this task ready for insertion. - T task; + Tt task; // Handle the 12 fields. for (unsigned int f = 0; f < fields.size (); ++f) @@ -239,10 +239,10 @@ static std::string importTask_1_4_3 ( break; case 1: // 'status' - if (fields[f] == "'pending'") task.setStatus (T::pending); - else if (fields[f] == "'recurring'") task.setStatus (T::recurring); - else if (fields[f] == "'deleted'") task.setStatus (T::deleted); - else if (fields[f] == "'completed'") task.setStatus (T::completed); + if (fields[f] == "'pending'") task.setStatus (Tt::pending); + else if (fields[f] == "'recurring'") task.setStatus (Tt::recurring); + else if (fields[f] == "'deleted'") task.setStatus (Tt::deleted); + else if (fields[f] == "'completed'") task.setStatus (Tt::completed); break; case 2: // 'tags' @@ -383,7 +383,7 @@ static std::string importTask_1_5_0 ( throw "unrecoverable"; // Build up this task ready for insertion. - T task; + Tt task; // Handle the 13 fields. for (unsigned int f = 0; f < fields.size (); ++f) @@ -395,10 +395,10 @@ static std::string importTask_1_5_0 ( break; case 1: // 'status' - if (fields[f] == "'pending'") task.setStatus (T::pending); - else if (fields[f] == "'recurring'") task.setStatus (T::recurring); - else if (fields[f] == "'deleted'") task.setStatus (T::deleted); - else if (fields[f] == "'completed'") task.setStatus (T::completed); + if (fields[f] == "'pending'") task.setStatus (Tt::pending); + else if (fields[f] == "'recurring'") task.setStatus (Tt::recurring); + else if (fields[f] == "'deleted'") task.setStatus (Tt::deleted); + else if (fields[f] == "'completed'") task.setStatus (Tt::completed); break; case 2: // 'tags' @@ -544,7 +544,7 @@ static std::string importTask_1_6_0 ( throw "unrecoverable"; // Build up this task ready for insertion. - T task; + Tt task; // Handle the 13 fields. for (unsigned int f = 0; f < fields.size (); ++f) @@ -556,10 +556,10 @@ static std::string importTask_1_6_0 ( break; case 1: // 'status' - if (fields[f] == "'pending'") task.setStatus (T::pending); - else if (fields[f] == "'recurring'") task.setStatus (T::recurring); - else if (fields[f] == "'deleted'") task.setStatus (T::deleted); - else if (fields[f] == "'completed'") task.setStatus (T::completed); + if (fields[f] == "'pending'") task.setStatus (Tt::pending); + else if (fields[f] == "'recurring'") task.setStatus (Tt::recurring); + else if (fields[f] == "'deleted'") task.setStatus (Tt::deleted); + else if (fields[f] == "'completed'") task.setStatus (Tt::completed); break; case 2: // 'tags' @@ -670,7 +670,7 @@ static std::string importTaskCmdLine ( std::vector args; split (args, std::string ("add ") + line, ' '); - T task; + Tt task; std::string command; parse (args, command, task, conf); handleAdd (tdb, task, conf); @@ -776,18 +776,18 @@ static std::string importTodoSh_2_0 ( } } - T task; + Tt task; std::string command; parse (args, command, task, conf); decorateTask (task, conf); if (isPending) { - task.setStatus (T::pending); + task.setStatus (Tt::pending); } else { - task.setStatus (T::completed); + task.setStatus (Tt::completed); char end[16]; sprintf (end, "%u", (unsigned int) endDate.toEpoch ()); @@ -850,7 +850,7 @@ static std::string importText ( std::vector args; split (args, std::string ("add ") + line, ' '); - T task; + Tt task; std::string command; parse (args, command, task, conf); decorateTask (task, conf); @@ -1040,7 +1040,7 @@ static std::string importCSV ( std::vector fields; split (fields, *it, ','); - T task; + Tt task; int f; if ((f = mapping["uuid"]) != -1) @@ -1050,10 +1050,10 @@ static std::string importCSV ( { std::string value = lowerCase (unquoteText (trim (fields[f]))); - if (value == "recurring") task.setStatus (T::recurring); - else if (value == "deleted") task.setStatus (T::deleted); - else if (value == "completed") task.setStatus (T::completed); - else task.setStatus (T::pending); + if (value == "recurring") task.setStatus (Tt::recurring); + else if (value == "deleted") task.setStatus (Tt::deleted); + else if (value == "completed") task.setStatus (Tt::completed); + else task.setStatus (Tt::pending); } 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; diff --git a/src/parse.cpp b/src/parse.cpp index ae10e2be5..190f5876f 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -469,7 +469,7 @@ bool validDuration (std::string& input) void parse ( std::vector & args, std::string& command, - T& task, + Tt& task, Config& conf) { command = ""; diff --git a/src/report.cpp b/src/report.cpp index 9e419bfac..d5eb9902a 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -47,12 +47,12 @@ #endif //////////////////////////////////////////////////////////////////////////////// -void filterSequence (std::vector& all, T& task) +void filterSequence (std::vector& all, Tt& task) { std::vector sequence = task.getAllIds (); - std::vector filtered; - std::vector ::iterator t; + std::vector filtered; + std::vector ::iterator t; for (t = all.begin (); t != all.end (); ++t) { std::vector ::iterator s; @@ -64,7 +64,7 @@ void filterSequence (std::vector& all, T& task) if (sequence.size () != filtered.size ()) { std::vector filteredSequence; - std::vector ::iterator fs; + std::vector ::iterator fs; for (fs = filtered.begin (); fs != filtered.end (); ++fs) filteredSequence.push_back (fs->getId ()); @@ -94,9 +94,9 @@ void filterSequence (std::vector& all, T& task) } //////////////////////////////////////////////////////////////////////////////// -void filter (std::vector& all, T& task) +void filter (std::vector& all, Tt& task) { - std::vector filtered; + std::vector filtered; // Split any description specified into words. std::vector descWords; @@ -113,7 +113,7 @@ void filter (std::vector& all, T& task) // Iterate over each task, and apply selection criteria. for (unsigned int i = 0; i < all.size (); ++i) { - T refTask (all[i]); + Tt refTask (all[i]); // Apply description filter. std::string desc = lowerCase (refTask.getDescription ()); @@ -189,7 +189,7 @@ void filter (std::vector& all, T& task) //////////////////////////////////////////////////////////////////////////////// // Successively apply filters based on the task object built from the command // 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; @@ -205,7 +205,7 @@ std::string handleCompleted (TDB& tdb, T& task, Config& conf) #endif // Get the pending tasks. - std::vector tasks; + std::vector tasks; tdb.completedT (tasks); filter (tasks, task); @@ -244,7 +244,7 @@ std::string handleCompleted (TDB& tdb, T& task, Config& conf) // Iterate over each task, and apply selection criteria. for (unsigned int i = 0; i < tasks.size (); ++i) { - T refTask (tasks[i]); + Tt refTask (tasks[i]); // Now format the matching task. 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. -std::string handleInfo (TDB& tdb, T& task, Config& conf) +std::string handleInfo (TDB& tdb, Tt& task, Config& conf) { std::stringstream out; @@ -309,14 +309,14 @@ std::string handleInfo (TDB& tdb, T& task, Config& conf) #endif // Get all the tasks. - std::vector tasks; + std::vector tasks; tdb.allPendingT (tasks); // Find the task. int count = 0; 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 ())) { @@ -348,10 +348,10 @@ std::string handleInfo (TDB& tdb, T& task, Config& conf) table.addCell (row, 0, "ID"); table.addCell (row, 1, refTask.getId ()); - std::string status = refTask.getStatus () == T::pending ? "Pending" - : refTask.getStatus () == T::completed ? "Completed" - : refTask.getStatus () == T::deleted ? "Deleted" - : refTask.getStatus () == T::recurring ? "Recurring" + std::string status = refTask.getStatus () == Tt::pending ? "Pending" + : refTask.getStatus () == Tt::completed ? "Completed" + : refTask.getStatus () == Tt::deleted ? "Deleted" + : refTask.getStatus () == Tt::recurring ? "Recurring" : ""; if (refTask.getAttribute ("parent") != "") status += " (Recurring)"; @@ -389,7 +389,7 @@ std::string handleInfo (TDB& tdb, T& task, Config& conf) table.addCell (row, 1, refTask.getAttribute ("priority")); } - if (refTask.getStatus () == T::recurring || + if (refTask.getStatus () == Tt::recurring || refTask.getAttribute ("parent") != "") { if (refTask.getAttribute ("recur") != "") @@ -540,11 +540,11 @@ std::string handleInfo (TDB& tdb, T& task, Config& conf) // Project Remaining Avg Age Complete 0% 100% // A 12 13d 55% XXXXXXXXXXXXX----------- // 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::vector tasks; + std::vector tasks; tdb.allT (tasks); handleRecurrence (tdb, tasks); 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. std::map allProjects; foreach (t, tasks) - if (t->getStatus () == T::pending) + if (t->getStatus () == Tt::pending) allProjects[t->getAttribute ("project")] = false; // Initialize counts, sum. @@ -577,7 +577,7 @@ std::string handleReportSummary (TDB& tdb, T& task, Config& conf) std::string project = t->getAttribute ("project"); ++counter[project]; - if (t->getStatus () == T::pending) + if (t->getStatus () == Tt::pending) { ++countPending[project]; @@ -586,7 +586,7 @@ std::string handleReportSummary (TDB& tdb, T& task, Config& conf) sumEntry[project] = sumEntry[project] + (double) (now - entry); } - else if (t->getStatus () == T::completed) + else if (t->getStatus () == Tt::completed) { ++countCompleted[project]; @@ -702,12 +702,12 @@ std::string handleReportSummary (TDB& tdb, T& task, Config& conf) // // 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; // Load all pending. - std::vector pending; + std::vector pending; tdb.allPendingT (pending); handleRecurrence (tdb, pending); filter (pending, task); @@ -728,7 +728,7 @@ std::string handleReportNext (TDB& tdb, T& task, Config& conf) #endif // Get the pending tasks. - std::vector tasks; + std::vector tasks; tdb.pendingT (tasks); filter (tasks, task); @@ -778,7 +778,7 @@ std::string handleReportNext (TDB& tdb, T& task, Config& conf) // Iterate over each task, and apply selection criteria. foreach (i, matching) { - T refTask (pending[*i]); + Tt refTask (pending[*i]); Date now; // Now format the matching task. @@ -887,7 +887,7 @@ time_t monthlyEpoch (const std::string& date) return 0; } -std::string handleReportHistory (TDB& tdb, T& task, Config& conf) +std::string handleReportHistory (TDB& tdb, Tt& task, Config& conf) { std::stringstream out; @@ -897,13 +897,13 @@ std::string handleReportHistory (TDB& tdb, T& task, Config& conf) std::map deletedGroup; // Scan the pending tasks. - std::vector pending; + std::vector pending; tdb.allPendingT (pending); handleRecurrence (tdb, pending); filter (pending, task); for (unsigned int i = 0; i < pending.size (); ++i) { - T task (pending[i]); + Tt task (pending[i]); time_t epoch = monthlyEpoch (task.getAttribute ("entry")); if (epoch) { @@ -914,7 +914,7 @@ std::string handleReportHistory (TDB& tdb, T& task, Config& conf) else addedGroup[epoch] = 1; - if (task.getStatus () == T::deleted) + if (task.getStatus () == Tt::deleted) { epoch = monthlyEpoch (task.getAttribute ("end")); groups[epoch] = 0; @@ -924,7 +924,7 @@ std::string handleReportHistory (TDB& tdb, T& task, Config& conf) else deletedGroup[epoch] = 1; } - else if (task.getStatus () == T::completed) + else if (task.getStatus () == Tt::completed) { epoch = monthlyEpoch (task.getAttribute ("end")); groups[epoch] = 0; @@ -938,12 +938,12 @@ std::string handleReportHistory (TDB& tdb, T& task, Config& conf) } // Scan the completed tasks. - std::vector completed; + std::vector completed; tdb.allCompletedT (completed); filter (completed, task); for (unsigned int i = 0; i < completed.size (); ++i) { - T task (completed[i]); + Tt task (completed[i]); time_t epoch = monthlyEpoch (task.getAttribute ("entry")); if (epoch) { @@ -955,7 +955,7 @@ std::string handleReportHistory (TDB& tdb, T& task, Config& conf) addedGroup[epoch] = 1; epoch = monthlyEpoch (task.getAttribute ("end")); - if (task.getStatus () == T::deleted) + if (task.getStatus () == Tt::deleted) { epoch = monthlyEpoch (task.getAttribute ("end")); groups[epoch] = 0; @@ -965,7 +965,7 @@ std::string handleReportHistory (TDB& tdb, T& task, Config& conf) else deletedGroup[epoch] = 1; } - else if (task.getStatus () == T::completed) + else if (task.getStatus () == Tt::completed) { epoch = monthlyEpoch (task.getAttribute ("end")); 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; @@ -1101,13 +1101,13 @@ std::string handleReportGHistory (TDB& tdb, T& task, Config& conf) std::map deletedGroup; // Scan the pending tasks. - std::vector pending; + std::vector pending; tdb.allPendingT (pending); handleRecurrence (tdb, pending); filter (pending, task); for (unsigned int i = 0; i < pending.size (); ++i) { - T task (pending[i]); + Tt task (pending[i]); time_t epoch = monthlyEpoch (task.getAttribute ("entry")); if (epoch) { @@ -1118,7 +1118,7 @@ std::string handleReportGHistory (TDB& tdb, T& task, Config& conf) else addedGroup[epoch] = 1; - if (task.getStatus () == T::deleted) + if (task.getStatus () == Tt::deleted) { epoch = monthlyEpoch (task.getAttribute ("end")); groups[epoch] = 0; @@ -1128,7 +1128,7 @@ std::string handleReportGHistory (TDB& tdb, T& task, Config& conf) else deletedGroup[epoch] = 1; } - else if (task.getStatus () == T::completed) + else if (task.getStatus () == Tt::completed) { epoch = monthlyEpoch (task.getAttribute ("end")); groups[epoch] = 0; @@ -1142,12 +1142,12 @@ std::string handleReportGHistory (TDB& tdb, T& task, Config& conf) } // Scan the completed tasks. - std::vector completed; + std::vector completed; tdb.allCompletedT (completed); filter (completed, task); for (unsigned int i = 0; i < completed.size (); ++i) { - T task (completed[i]); + Tt task (completed[i]); time_t epoch = monthlyEpoch (task.getAttribute ("entry")); if (epoch) { @@ -1159,7 +1159,7 @@ std::string handleReportGHistory (TDB& tdb, T& task, Config& conf) addedGroup[epoch] = 1; epoch = monthlyEpoch (task.getAttribute ("end")); - if (task.getStatus () == T::deleted) + if (task.getStatus () == Tt::deleted) { epoch = monthlyEpoch (task.getAttribute ("end")); groups[epoch] = 0; @@ -1169,7 +1169,7 @@ std::string handleReportGHistory (TDB& tdb, T& task, Config& conf) else deletedGroup[epoch] = 1; } - else if (task.getStatus () == T::completed) + else if (task.getStatus () == Tt::completed) { epoch = monthlyEpoch (task.getAttribute ("end")); 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; @@ -1339,7 +1339,7 @@ std::string handleReportTimesheet (TDB& tdb, T& task, Config& conf) #endif // Get all the tasks. - std::vector tasks; + std::vector tasks; tdb.allT (tasks); filter (tasks, task); @@ -1399,7 +1399,7 @@ std::string handleReportTimesheet (TDB& tdb, T& task, Config& conf) foreach (t, tasks) { // If task completed within range. - if (t->getStatus () == T::completed) + if (t->getStatus () == Tt::completed) { Date compDate (::atoi (t->getAttribute ("end").c_str ())); if (compDate >= start && compDate < end) @@ -1469,7 +1469,7 @@ std::string handleReportTimesheet (TDB& tdb, T& task, Config& conf) foreach (t, tasks) { // If task started within range, but not completed withing range. - if (t->getStatus () == T::pending && + if (t->getStatus () == Tt::pending && t->getAttribute ("start") != "") { Date startDate (::atoi (t->getAttribute ("start").c_str ())); @@ -1530,7 +1530,7 @@ std::string renderMonths ( int firstMonth, int firstYear, const Date& today, - std::vector & all, + std::vector & all, Config& conf, int monthsPerLine) { @@ -1625,7 +1625,7 @@ std::string renderMonths ( today.year () == years.at (c)) table.setCellFg (row, thisCol, Text::cyan); - std::vector ::iterator it; + std::vector ::iterator it; for (it = all.begin (); it != all.end (); ++it) { 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; @@ -1675,7 +1675,7 @@ std::string handleReportCalendar (TDB& tdb, T& task, Config& conf) monthsPerLine = preferredMonthsPerLine; // Load all the pending tasks. - std::vector pending; + std::vector pending; tdb.allPendingT (pending); handleRecurrence (tdb, pending); filter (pending, task); @@ -1683,7 +1683,7 @@ std::string handleReportCalendar (TDB& tdb, T& task, Config& conf) // Find the oldest pending due date. Date oldest; Date newest; - std::vector ::iterator it; + std::vector ::iterator it; for (it = pending.begin (); it != pending.end (); ++it) { 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; @@ -1775,7 +1775,7 @@ std::string handleReportActive (TDB& tdb, T& task, Config& conf) #endif // Get all the tasks. - std::vector tasks; + std::vector tasks; tdb.pendingT (tasks); filter (tasks, task); @@ -1818,7 +1818,7 @@ std::string handleReportActive (TDB& tdb, T& task, Config& conf) // Iterate over each task, and apply selection criteria. for (unsigned int i = 0; i < tasks.size (); ++i) { - T refTask (tasks[i]); + Tt refTask (tasks[i]); if (refTask.getAttribute ("start") != "") { 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; @@ -1908,7 +1908,7 @@ std::string handleReportOverdue (TDB& tdb, T& task, Config& conf) #endif // Get all the tasks. - std::vector tasks; + std::vector tasks; tdb.pendingT (tasks); filter (tasks, task); @@ -1953,7 +1953,7 @@ std::string handleReportOverdue (TDB& tdb, T& task, Config& conf) // Iterate over each task, and apply selection criteria. for (unsigned int i = 0; i < tasks.size (); ++i) { - T refTask (tasks[i]); + Tt refTask (tasks[i]); std::string 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; @@ -2031,7 +2031,7 @@ std::string handleReportStats (TDB& tdb, T& task, Config& conf) #endif // Get all the tasks. - std::vector tasks; + std::vector tasks; tdb.allT (tasks); filter (tasks, task); @@ -2050,26 +2050,26 @@ std::string handleReportStats (TDB& tdb, T& task, Config& conf) std::map allTags; std::map allProjects; - std::vector ::iterator it; + std::vector ::iterator it; for (it = tasks.begin (); it != tasks.end (); ++it) { ++totalT; - if (it->getStatus () == T::deleted) ++deletedT; - if (it->getStatus () == T::pending) ++pendingT; - if (it->getStatus () == T::completed) ++completedT; - if (it->getStatus () == T::recurring) ++recurringT; + if (it->getStatus () == Tt::deleted) ++deletedT; + if (it->getStatus () == Tt::pending) ++pendingT; + if (it->getStatus () == Tt::completed) ++completedT; + if (it->getStatus () == Tt::recurring) ++recurringT; time_t entry = ::atoi (it->getAttribute ("entry").c_str ()); if (entry < earliest) earliest = 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 ()); daysPending += (end - entry) / 86400.0; } - if (it->getStatus () == T::pending) + if (it->getStatus () == Tt::pending) daysPending += (now - entry) / 86400.0; descLength += it->getDescription ().length (); @@ -2215,9 +2215,9 @@ std::string handleReportStats (TDB& tdb, T& task, Config& conf) //////////////////////////////////////////////////////////////////////////////// void gatherNextTasks ( const TDB& tdb, - T& task, + Tt& task, Config& conf, - std::vector & pending, + std::vector & pending, std::vector & all) { // For counting tasks by project. @@ -2232,7 +2232,7 @@ void gatherNextTasks ( // due:< 1wk, pri:* 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"); if (due != "") @@ -2254,7 +2254,7 @@ void gatherNextTasks ( // due:*, pri:H 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"); if (due != "") @@ -2276,7 +2276,7 @@ void gatherNextTasks ( // pri:H 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"); if (priority == "H") @@ -2294,7 +2294,7 @@ void gatherNextTasks ( // due:*, pri:M 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"); if (due != "") @@ -2316,7 +2316,7 @@ void gatherNextTasks ( // pri:M 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"); if (priority == "M") @@ -2334,7 +2334,7 @@ void gatherNextTasks ( // due:*, pri:L 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"); if (due != "") @@ -2356,7 +2356,7 @@ void gatherNextTasks ( // pri:L 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"); if (priority == "L") @@ -2374,7 +2374,7 @@ void gatherNextTasks ( // due:, pri: 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"); if (due == "") @@ -2403,7 +2403,7 @@ void gatherNextTasks ( // via the .taskrc file. std::string handleCustomReport ( TDB& tdb, - T& task, + Tt& task, Config& conf, const std::string& report) { @@ -2447,14 +2447,14 @@ std::string handleCustomReport ( split (filterArgs, filterList, ' '); // Load all pending tasks. - std::vector tasks; + std::vector tasks; tdb.allPendingT (tasks); handleRecurrence (tdb, tasks); // Apply filters. { std::string ignore; - T filterTask; + Tt filterTask; parse (filterArgs, ignore, filterTask, conf); filter (tasks, filterTask); // Filter from custom report diff --git a/src/rules.cpp b/src/rules.cpp index 5744dd3ca..7796c77f7 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -81,7 +81,7 @@ void initializeColorRules (Config& conf) //////////////////////////////////////////////////////////////////////////////// void autoColorize ( - T& task, + Tt& task, Text::color& fg, Text::color& bg, Config& conf) diff --git a/src/task.cpp b/src/task.cpp index 4d2390154..52976e24f 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -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 ("")); if (nagMessage != "") { // Load all pending tasks. - std::vector pending; + std::vector pending; tdb.allPendingT (pending); // Counters. @@ -397,7 +397,7 @@ void nag (TDB& tdb, T& task, Config& conf) if (priority.length ()) pri = priority[0]; } - else if (t->getStatus () == T::pending) + else if (t->getStatus () == Tt::pending) { if (getDueState (t->getAttribute ("due")) == 2) overdue++; @@ -456,14 +456,14 @@ int getDueState (const std::string& due) //////////////////////////////////////////////////////////////////////////////// // Scans all tasks, and for any recurring tasks, determines whether any new // child tasks need to be generated to fill gaps. -void handleRecurrence (TDB& tdb, std::vector & tasks) +void handleRecurrence (TDB& tdb, std::vector & tasks) { - std::vector modified; + std::vector modified; // Look at all tasks and find any recurring ones. 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 // the mask. @@ -480,7 +480,7 @@ void handleRecurrence (TDB& tdb, std::vector & tasks) char endTime[16]; sprintf (endTime, "%u", (unsigned int) time (NULL)); t->setAttribute ("end", endTime); - t->setStatus (T::deleted); + t->setStatus (Tt::deleted); tdb.modifyT (*t); continue; } @@ -498,10 +498,10 @@ void handleRecurrence (TDB& tdb, std::vector & tasks) mask += '-'; changed = true; - T rec (*t); // Clone the parent. + Tt rec (*t); // Clone the parent. rec.setId (tdb.nextId ()); // Assign a unique id. rec.setUUID (uuid ()); // New UUID. - rec.setStatus (T::pending); // Shiny. + rec.setStatus (Tt::pending); // Shiny. rec.setAttribute ("parent", t->getUUID ()); // Remember mom. char dueDate[16]; @@ -541,7 +541,7 @@ void handleRecurrence (TDB& tdb, std::vector & tasks) // period (recur). Then generate a set of corresponding dates. // // Returns false if the parent recurring task is depleted. -bool generateDueDates (T& parent, std::vector & allDue) +bool generateDueDates (Tt& parent, std::vector & allDue) { // Determine due date, recur period and until date. Date due (atoi (parent.getAttribute ("due").c_str ())); @@ -726,13 +726,13 @@ Date getNextRecurrence (Date& current, std::string& period) // update it's mask. void updateRecurrenceMask ( TDB& tdb, - std::vector & all, - T& task) + std::vector & all, + Tt& task) { std::string parent = task.getAttribute ("parent"); if (parent != "") { - std::vector ::iterator it; + std::vector ::iterator it; for (it = all.begin (); it != all.end (); ++it) { if (it->getUUID () == parent) @@ -741,9 +741,9 @@ void updateRecurrenceMask ( std::string mask = it->getAttribute ("mask"); if (mask.length () > index) { - mask[index] = (task.getStatus () == T::pending) ? '-' - : (task.getStatus () == T::completed) ? '+' - : (task.getStatus () == T::deleted) ? 'X' + mask[index] = (task.getStatus () == Tt::pending) ? '-' + : (task.getStatus () == Tt::completed) ? '+' + : (task.getStatus () == Tt::deleted) ? 'X' : '?'; it->setAttribute ("mask", mask); @@ -755,9 +755,9 @@ void updateRecurrenceMask ( for (unsigned int i = 0; i < index; ++i) mask += "?"; - mask += (task.getStatus () == T::pending) ? '-' - : (task.getStatus () == T::completed) ? '+' - : (task.getStatus () == T::deleted) ? 'X' + mask += (task.getStatus () == Tt::pending) ? '-' + : (task.getStatus () == Tt::completed) ? '+' + : (task.getStatus () == Tt::deleted) ? 'X' : '?'; } @@ -858,7 +858,7 @@ std::string runTaskCommand ( loadCustomReports (conf); std::string command; - T task; + Tt task; parse (args, command, task, conf); bool gcMod = false; // Change occurred by way of gc. diff --git a/src/task.h b/src/task.h index 7599007ea..e6f18cad2 100644 --- a/src/task.h +++ b/src/task.h @@ -54,7 +54,7 @@ for (typeof (c) *foreach_p = & (c); \ ++i) // parse.cpp -void parse (std::vector &, std::string&, T&, Config&); +void parse (std::vector &, std::string&, Tt&, Config&); bool validPriority (const std::string&); bool validDate (std::string&, Config&); bool validDuration (std::string&); @@ -63,60 +63,60 @@ bool isCustomReport (const std::string&); void allCustomReports (std::vector &); // task.cpp -void gatherNextTasks (const TDB&, T&, Config&, std::vector &, std::vector &); -void nag (TDB&, T&, Config&); +void gatherNextTasks (const TDB&, Tt&, Config&, std::vector &, std::vector &); +void nag (TDB&, Tt&, Config&); int getDueState (const std::string&); -void handleRecurrence (TDB&, std::vector &); -bool generateDueDates (T&, std::vector &); +void handleRecurrence (TDB&, std::vector &); +bool generateDueDates (Tt&, std::vector &); Date getNextRecurrence (Date&, std::string&); -void updateRecurrenceMask (TDB&, std::vector &, T&); +void updateRecurrenceMask (TDB&, std::vector &, Tt&); void onChangeCallback (); std::string runTaskCommand (int, char**, TDB&, Config&, bool gc = true, bool shadow = true); std::string runTaskCommand (std::vector &, TDB&, Config&, bool gc = false, bool shadow = false); // command.cpp -std::string handleAdd (TDB&, T&, Config&); -std::string handleAppend (TDB&, T&, Config&); -std::string handleExport (TDB&, T&, Config&); -std::string handleDone (TDB&, T&, Config&); -std::string handleModify (TDB&, T&, Config&); -std::string handleProjects (TDB&, T&, Config&); -std::string handleTags (TDB&, T&, Config&); -std::string handleUndelete (TDB&, T&, Config&); +std::string handleAdd (TDB&, Tt&, Config&); +std::string handleAppend (TDB&, Tt&, Config&); +std::string handleExport (TDB&, Tt&, Config&); +std::string handleDone (TDB&, Tt&, Config&); +std::string handleModify (TDB&, Tt&, Config&); +std::string handleProjects (TDB&, Tt&, Config&); +std::string handleTags (TDB&, Tt&, Config&); +std::string handleUndelete (TDB&, Tt&, Config&); std::string handleVersion (Config&); -std::string handleDelete (TDB&, T&, Config&); -std::string handleStart (TDB&, T&, Config&); -std::string handleStop (TDB&, T&, Config&); -std::string handleUndo (TDB&, T&, Config&); +std::string handleDelete (TDB&, Tt&, Config&); +std::string handleStart (TDB&, Tt&, Config&); +std::string handleStop (TDB&, Tt&, Config&); +std::string handleUndo (TDB&, Tt&, Config&); std::string handleColor (Config&); -std::string handleAnnotate (TDB&, T&, Config&); -std::string handleDuplicate (TDB&, T&, Config&); -T findT (int, const std::vector &); -int deltaAppend (T&, T&); -int deltaDescription (T&, T&); -int deltaTags (T&, T&); -int deltaAttributes (T&, T&); -int deltaSubstitutions (T&, T&); +std::string handleAnnotate (TDB&, Tt&, Config&); +std::string handleDuplicate (TDB&, Tt&, Config&); +Tt findT (int, const std::vector &); +int deltaAppend (Tt&, Tt&); +int deltaDescription (Tt&, Tt&); +int deltaTags (Tt&, Tt&); +int deltaAttributes (Tt&, Tt&); +int deltaSubstitutions (Tt&, Tt&); // edit.cpp -std::string handleEdit (TDB&, T&, Config&); +std::string handleEdit (TDB&, Tt&, Config&); // report.cpp -void filterSequence (std::vector&, T&); -void filter (std::vector&, T&); -std::string handleInfo (TDB&, T&, Config&); -std::string handleCompleted (TDB&, T&, Config&); -std::string handleReportSummary (TDB&, T&, Config&); -std::string handleReportNext (TDB&, T&, Config&); -std::string handleReportHistory (TDB&, T&, Config&); -std::string handleReportGHistory (TDB&, T&, Config&); -std::string handleReportCalendar (TDB&, T&, Config&); -std::string handleReportActive (TDB&, T&, Config&); -std::string handleReportOverdue (TDB&, T&, Config&); -std::string handleReportStats (TDB&, T&, Config&); -std::string handleReportTimesheet (TDB&, T&, Config&); +void filterSequence (std::vector&, Tt&); +void filter (std::vector&, Tt&); +std::string handleInfo (TDB&, Tt&, Config&); +std::string handleCompleted (TDB&, Tt&, Config&); +std::string handleReportSummary (TDB&, Tt&, Config&); +std::string handleReportNext (TDB&, Tt&, Config&); +std::string handleReportHistory (TDB&, Tt&, Config&); +std::string handleReportGHistory (TDB&, Tt&, Config&); +std::string handleReportCalendar (TDB&, Tt&, Config&); +std::string handleReportActive (TDB&, Tt&, Config&); +std::string handleReportOverdue (TDB&, Tt&, Config&); +std::string handleReportStats (TDB&, Tt&, 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 &); void validSortColumns (const std::vector &, const std::vector &); @@ -160,10 +160,10 @@ void spit (const std::string&, const std::string&); // rules.cpp void initializeColorRules (Config&); -void autoColorize (T&, Text::color&, Text::color&, Config&); +void autoColorize (Tt&, Text::color&, Text::color&, Config&); // import.cpp -std::string handleImport (TDB&, T&, Config&); +std::string handleImport (TDB&, Tt&, Config&); // list template ///////////////////////////////////////////////////////////////////////////////