From 9776495286a13c4a38cccab9dc2711c877dea5d6 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 10 Jun 2009 22:54:56 -0400 Subject: [PATCH] Code Cleanup - TDB removal - TDB removed from all code, but source kept for further reference. --- src/Makefile.am | 2 +- src/TDB2.h | 4 +-- src/command.cpp | 4 +-- src/edit.cpp | 6 +++-- src/import.cpp | 46 ++++++++++++++++++++++++++--------- src/main.cpp | 59 +++++++-------------------------------------- src/main.h | 9 ++++--- src/recur.cpp | 10 +++++--- src/report.cpp | 3 +-- src/tests/Makefile | 9 +++---- src/tests/t.t.cpp | 1 - src/tests/tdb.t.cpp | 3 ++- src/util.cpp | 4 +-- 13 files changed, 71 insertions(+), 89 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index c25530018..203f55eee 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,4 +9,4 @@ task_SOURCES = Att.cpp Cmd.cpp Config.cpp Context.cpp Date.cpp Duration.cpp \ Grid.h Keymap.h Location.h Nibbler.h Record.h Sequence.h \ StringTable.h Subst.h Task.h TDB2.h Table.h Timer.h color.h \ i18n.h main.h text.h util.h \ - T.cpp T.h TDB.cpp TDB.h + T.cpp T.h diff --git a/src/TDB2.h b/src/TDB2.h index 95406e388..b8010e56f 100644 --- a/src/TDB2.h +++ b/src/TDB2.h @@ -40,10 +40,10 @@ class TDB2 { public: - TDB2 (); // Default constructor + TDB2 (); // Default constructor TDB2 (const TDB2&); // Copy constructor TDB2& operator= (const TDB2&); // Assignment operator - ~TDB2 (); // Destructor + ~TDB2 (); // Destructor void location (const std::string&); diff --git a/src/command.cpp b/src/command.cpp index d20f52714..4f8585a03 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -34,8 +34,6 @@ #include #include -#include "T.h" -#include "TDB.h" #include "text.h" #include "util.h" #include "main.h" @@ -546,7 +544,7 @@ std::string handleStart () } //////////////////////////////////////////////////////////////////////////////// -std::string handleStop (TDB& tdb, T& task) +std::string handleStop () { std::stringstream out; /* diff --git a/src/edit.cpp b/src/edit.cpp index fd2c22fb0..eea92cfc8 100644 --- a/src/edit.cpp +++ b/src/edit.cpp @@ -34,7 +34,6 @@ #include #include #include "T.h" -#include "TDB.h" #include "Date.h" #include "text.h" #include "util.h" @@ -93,6 +92,7 @@ static std::string findDate ( } //////////////////////////////////////////////////////////////////////////////// +// Obsolete - use Task::statusToText static std::string formatStatus (T& task) { switch (task.getStatus ()) @@ -496,9 +496,10 @@ static void parseTask (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) +std::string handleEdit () { std::stringstream out; +/* std::vector all; tdb.allPendingT (all); @@ -587,6 +588,7 @@ ARE_THESE_REALLY_HARMFUL: unlink (file); } +*/ return out.str (); } diff --git a/src/import.cpp b/src/import.cpp index 9c541fb14..d3675ec84 100644 --- a/src/import.cpp +++ b/src/import.cpp @@ -30,7 +30,6 @@ #include #include "Date.h" #include "T.h" -#include "TDB.h" #include "text.h" #include "util.h" #include "main.h" @@ -182,9 +181,10 @@ static void decorateTask (T& task) //////////////////////////////////////////////////////////////////////////////// static std::string importTask_1_4_3 ( - TDB& tdb, +// TDB& tdb, const std::vector & lines) { +/* std::vector failed; std::vector ::const_iterator it; @@ -316,8 +316,10 @@ static std::string importTask_1_4_3 ( failed.push_back (*it); } } +*/ std::stringstream out; +/* out << "Imported " << (lines.size () - failed.size () - 1) << " tasks successfully, with " @@ -331,15 +333,16 @@ static std::string importTask_1_4_3 ( join (bad, "\n", failed); return out.str () + "\nCould not import:\n\n" + bad; } - +*/ return out.str (); } //////////////////////////////////////////////////////////////////////////////// static std::string importTask_1_5_0 ( - TDB& tdb, +// TDB& tdb, const std::vector & lines) { +/* std::vector failed; std::vector ::const_iterator it; @@ -477,7 +480,9 @@ static std::string importTask_1_5_0 ( } } +*/ std::stringstream out; +/* out << "Imported " << (lines.size () - failed.size () - 1) << " tasks successfully, with " @@ -491,15 +496,17 @@ static std::string importTask_1_5_0 ( join (bad, "\n", failed); return out.str () + "\nCould not import:\n\n" + bad; } +*/ return out.str (); } //////////////////////////////////////////////////////////////////////////////// static std::string importTask_1_6_0 ( - TDB& tdb, +// TDB& tdb, const std::vector & lines) { +/* std::vector failed; std::vector ::const_iterator it; @@ -636,8 +643,10 @@ static std::string importTask_1_6_0 ( failed.push_back (*it); } } +*/ std::stringstream out; +/* out << "Imported " << (lines.size () - failed.size () - 1) << " tasks successfully, with " @@ -651,15 +660,16 @@ static std::string importTask_1_6_0 ( join (bad, "\n", failed); return out.str () + "\nCould not import:\n\n" + bad; } - +*/ return out.str (); } //////////////////////////////////////////////////////////////////////////////// static std::string importTaskCmdLine ( - TDB& tdb, +// TDB& tdb, const std::vector & lines) { +/* std::vector failed; std::vector ::const_iterator it; @@ -683,8 +693,10 @@ static std::string importTaskCmdLine ( failed.push_back (line); } } +*/ std::stringstream out; +/* out << "Imported " << (lines.size () - failed.size ()) << " tasks successfully, with " @@ -698,15 +710,17 @@ static std::string importTaskCmdLine ( join (bad, "\n", failed); return out.str () + "\nCould not import:\n\n" + bad; } +*/ return out.str (); } //////////////////////////////////////////////////////////////////////////////// static std::string importTodoSh_2_0 ( - TDB& tdb, +// TDB& tdb, const std::vector & lines) { +/* std::vector failed; std::vector ::const_iterator it; @@ -804,8 +818,10 @@ static std::string importTodoSh_2_0 ( failed.push_back (*it); } } +*/ std::stringstream out; +/* out << "Imported " << (lines.size () - failed.size ()) << " tasks successfully, with " @@ -819,15 +835,16 @@ static std::string importTodoSh_2_0 ( join (bad, "\n", failed); return out.str () + "\nCould not import:\n\n" + bad; } - +*/ return out.str (); } //////////////////////////////////////////////////////////////////////////////// static std::string importText ( - TDB& tdb, +// TDB& tdb, const std::vector & lines) { +/* std::vector failed; int count = 0; @@ -865,8 +882,10 @@ static std::string importText ( } } } +*/ std::stringstream out; +/* out << "Imported " << count << " tasks successfully, with " @@ -880,15 +899,17 @@ static std::string importText ( join (bad, "\n", failed); return out.str () + "\nCould not import:\n\n" + bad; } +*/ return out.str (); } //////////////////////////////////////////////////////////////////////////////// static std::string importCSV ( - TDB& tdb, +// TDB& tdb, const std::vector & lines) { +/* std::vector failed; // Set up mappings. Assume no fields match. @@ -1107,8 +1128,10 @@ static std::string importCSV ( failed.push_back (*it); } } +*/ std::stringstream out; +/* out << "Imported " << (lines.size () - failed.size () - 1) << " tasks successfully, with " @@ -1122,6 +1145,7 @@ static std::string importCSV ( join (bad, "\n", failed); return out.str () + "\nCould not import:\n\n" + bad; } +*/ return out.str (); } diff --git a/src/main.cpp b/src/main.cpp index 70760ad45..32e4e2111 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,7 +40,6 @@ #include "Date.h" #include "Duration.h" #include "Table.h" -#include "TDB.h" #include "T.h" #include "text.h" #include "util.h" @@ -117,54 +116,9 @@ int main (int argc, char** argv) } //////////////////////////////////////////////////////////////////////////////// -void updateShadowFile (TDB& tdb) +// TODO Obsolete +void updateShadowFile () { - try - { - // Determine if shadow file is enabled. - std::string shadowFile = expandPath (context.config.get ("shadow.file")); - if (shadowFile != "") - { - std::string oldCurses = context.config.get ("curses"); - std::string oldColor = context.config.get ("color"); - context.config.set ("curses", "off"); - context.config.set ("color", "off"); - - // Run report. Use shadow.command, using default.command as a fallback - // with "list" as a default. - std::string command = context.config.get ("shadow.command", - context.config.get ("default.command", "list")); - std::vector args; - split (args, command, ' '); - std::string result = runTaskCommand (args, tdb); - - std::ofstream out (shadowFile.c_str ()); - if (out.good ()) - { - out << result; - out.close (); - } - else - throw std::string ("Could not write file '") + shadowFile + "'"; - - context.config.set ("curses", oldCurses); - context.config.set ("color", oldColor); - } - - // Optionally display a notification that the shadow file was updated. - if (context.config.get (std::string ("shadow.notify"), false)) - std::cout << "[Shadow file '" << shadowFile << "' updated]" << std::endl; - } - - catch (std::string& error) - { - std::cerr << error << std::endl; - } - - catch (...) - { - std::cerr << "Unknown error." << std::endl; - } } //////////////////////////////////////////////////////////////////////////////// @@ -172,10 +126,11 @@ void updateShadowFile (TDB& tdb) std::string runTaskCommand ( int argc, char** argv, - TDB& tdb, +// TDB& tdb, bool gc /* = true */, bool shadow /* = true */) { +/* std::vector args; for (int i = 1; i < argc; ++i) if (strncmp (argv[i], "rc:", 3) && @@ -186,16 +141,19 @@ std::cout << "arg=" << argv[i] << std::endl; } return runTaskCommand (args, tdb, gc, shadow); +*/ + return ""; } //////////////////////////////////////////////////////////////////////////////// // TODO Obsolete std::string runTaskCommand ( std::vector & args, - TDB& tdb, +// TDB& tdb, bool gc /* = false */, bool shadow /* = false */) { +/* // If argc == 1 and there is a default.command, use it. Otherwise use // argc/argv. std::string defaultCommand = context.config.get ("default.command"); @@ -215,6 +173,7 @@ std::string runTaskCommand ( bool gcMod = false; // Change occurred by way of gc. bool cmdMod = false; // Change occurred by way of command type. +*/ std::string out; /* // Read-only commands with no side effects. diff --git a/src/main.h b/src/main.h index 1efeaa283..33346d45f 100644 --- a/src/main.h +++ b/src/main.h @@ -31,7 +31,6 @@ #include #include "Context.h" #include "T.h" -#include "TDB.h" #include "Table.h" #include "Date.h" #include "color.h" @@ -49,18 +48,20 @@ bool isCustomReport (const std::string&); void allCustomReports (std::vector &); // task.cpp -void gatherNextTasks (const TDB&, T&, std::vector &, std::vector &); +void gatherNextTasks (/*const TDB&,*/ T&, std::vector &, std::vector &); void onChangeCallback (); +/* std::string runTaskCommand (int, char**, TDB&, bool gc = true, bool shadow = true); std::string runTaskCommand (std::vector &, TDB&, bool gc = false, bool shadow = false); +*/ // recur.cpp void handleRecurrence (); Date getNextRecurrence (Date&, std::string&); bool generateDueDates (T&, std::vector &); -void updateRecurrenceMask (TDB&, std::vector &, T&); +void updateRecurrenceMask (/*TDB&,*/ std::vector &, T&); int getDueState (const std::string&); -void nag (TDB&, T&); +void nag (/*TDB&,*/ T&); // command.cpp std::string handleAdd (); diff --git a/src/recur.cpp b/src/recur.cpp index 5ff8b9fa5..28bae5ac4 100644 --- a/src/recur.cpp +++ b/src/recur.cpp @@ -39,8 +39,6 @@ #include "Context.h" #include "Date.h" #include "Duration.h" -#include "Table.h" -#include "TDB.h" #include "T.h" #include "text.h" #include "util.h" @@ -330,10 +328,11 @@ Date getNextRecurrence (Date& current, std::string& period) // When the status of a recurring child task changes, the parent task must // update it's mask. void updateRecurrenceMask ( - TDB& tdb, +// TDB& tdb, std::vector & all, T& task) { +/* std::string parent = task.getAttribute ("parent"); if (parent != "") { @@ -370,6 +369,7 @@ void updateRecurrenceMask ( } } } +*/ } //////////////////////////////////////////////////////////////////////////////// @@ -399,8 +399,9 @@ int getDueState (const std::string& due) } //////////////////////////////////////////////////////////////////////////////// -void nag (TDB& tdb, T& task) +void nag (/*TDB& tdb,*/ T& task) { +/* std::string nagMessage = context.config.get ("nag", std::string ("")); if (nagMessage != "") { @@ -456,6 +457,7 @@ void nag (TDB& tdb, T& task) // All the excuses are made, all that remains is to nag the user. std::cout << nagMessage << std::endl; } +*/ } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/report.cpp b/src/report.cpp index 6a0f8213f..be048a1ee 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -38,7 +38,6 @@ #include "Context.h" #include "Date.h" #include "Table.h" -#include "TDB.h" #include "T.h" #include "text.h" #include "util.h" @@ -2431,7 +2430,7 @@ std::string handleReportStats () //////////////////////////////////////////////////////////////////////////////// void gatherNextTasks ( - const TDB& tdb, +// const TDB& tdb, T& task, std::vector & pending, std::vector & all) diff --git a/src/tests/Makefile b/src/tests/Makefile index 090344daf..12557ea11 100644 --- a/src/tests/Makefile +++ b/src/tests/Makefile @@ -3,12 +3,11 @@ PROJECT = t.t t2.t tdb.t date.t duration.t t.benchmark.t text.t autocomplete.t \ cmd.t config.t CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti LFLAGS = -L/usr/local/lib -lncurses -OBJECTS = ../TDB.o ../TDB2.o ../T.o ../Task.o ../parse.o ../text.o ../Date.o \ - ../Duration.o ../util.o ../Config.o ../Sequence.o ../Att.o \ +OBJECTS = ../TDB2.o ../T.o ../Task.o ../parse.o ../text.o ../Date.o ../Table.o \ + ../Duration.o ../util.o ../Config.o ../Sequence.o ../Att.o ../Cmd.o \ ../Record.o ../StringTable.o ../Subst.o ../Nibbler.o ../Location.o \ - ../Filter.o ../Context.o ../Keymap.o ../Cmd.o ../command.o \ - ../report.o ../Table.o ../Grid.o ../color.o ../rules.o ../recur.o \ - ../interactive.o + ../Filter.o ../Context.o ../Keymap.o ../command.o ../interactive.o \ + ../report.o ../Grid.o ../color.o ../rules.o ../recur.o all: $(PROJECT) diff --git a/src/tests/t.t.cpp b/src/tests/t.t.cpp index 2d5704c42..a88a9a0c3 100644 --- a/src/tests/t.t.cpp +++ b/src/tests/t.t.cpp @@ -24,7 +24,6 @@ // USA // //////////////////////////////////////////////////////////////////////////////// -#include "TDB.h" #include "T.h" #include "main.h" #include "test.h" diff --git a/src/tests/tdb.t.cpp b/src/tests/tdb.t.cpp index 3fc8df123..468137b79 100644 --- a/src/tests/tdb.t.cpp +++ b/src/tests/tdb.t.cpp @@ -27,7 +27,6 @@ #include #include -#include "TDB.h" #include "main.h" #include "test.h" @@ -40,6 +39,7 @@ int main (int argc, char** argv) try { +/* // Remove any residual test file. unlink ("./pending.data"); unlink ("./completed.data"); @@ -113,6 +113,7 @@ int main (int argc, char** argv) // GC the files. t.is (tdb.gc (), 1, "1 <- TDB::gc"); +*/ } catch (std::string& error) diff --git a/src/util.cpp b/src/util.cpp index f5ea97801..82759d584 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -36,10 +36,8 @@ #include #include #include + #include "Date.h" -#include "Table.h" -#include "T.h" -#include "TDB.h" #include "text.h" #include "main.h" #include "i18n.h"