Code Cleanup - TDB removal

- TDB removed from all code, but source kept for further reference.
This commit is contained in:
Paul Beckingham 2009-06-10 22:54:56 -04:00
parent fc7b344a8b
commit 9776495286
13 changed files with 71 additions and 89 deletions

View file

@ -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 \ 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 \ StringTable.h Subst.h Task.h TDB2.h Table.h Timer.h color.h \
i18n.h main.h text.h util.h \ i18n.h main.h text.h util.h \
T.cpp T.h TDB.cpp TDB.h T.cpp T.h

View file

@ -34,8 +34,6 @@
#include <pwd.h> #include <pwd.h>
#include <time.h> #include <time.h>
#include "T.h"
#include "TDB.h"
#include "text.h" #include "text.h"
#include "util.h" #include "util.h"
#include "main.h" #include "main.h"
@ -546,7 +544,7 @@ std::string handleStart ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string handleStop (TDB& tdb, T& task) std::string handleStop ()
{ {
std::stringstream out; std::stringstream out;
/* /*

View file

@ -34,7 +34,6 @@
#include <limits.h> #include <limits.h>
#include <string.h> #include <string.h>
#include "T.h" #include "T.h"
#include "TDB.h"
#include "Date.h" #include "Date.h"
#include "text.h" #include "text.h"
#include "util.h" #include "util.h"
@ -93,6 +92,7 @@ static std::string findDate (
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Obsolete - use Task::statusToText
static std::string formatStatus (T& task) static std::string formatStatus (T& task)
{ {
switch (task.getStatus ()) 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 // 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) std::string handleEdit ()
{ {
std::stringstream out; std::stringstream out;
/*
std::vector <T> all; std::vector <T> all;
tdb.allPendingT (all); tdb.allPendingT (all);
@ -587,6 +588,7 @@ ARE_THESE_REALLY_HARMFUL:
unlink (file); unlink (file);
} }
*/
return out.str (); return out.str ();
} }

View file

@ -30,7 +30,6 @@
#include <unistd.h> #include <unistd.h>
#include "Date.h" #include "Date.h"
#include "T.h" #include "T.h"
#include "TDB.h"
#include "text.h" #include "text.h"
#include "util.h" #include "util.h"
#include "main.h" #include "main.h"
@ -182,9 +181,10 @@ static void decorateTask (T& task)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static std::string importTask_1_4_3 ( static std::string importTask_1_4_3 (
TDB& tdb, // TDB& tdb,
const std::vector <std::string>& lines) const std::vector <std::string>& lines)
{ {
/*
std::vector <std::string> failed; std::vector <std::string> failed;
std::vector <std::string>::const_iterator it; std::vector <std::string>::const_iterator it;
@ -316,8 +316,10 @@ static std::string importTask_1_4_3 (
failed.push_back (*it); failed.push_back (*it);
} }
} }
*/
std::stringstream out; std::stringstream out;
/*
out << "Imported " out << "Imported "
<< (lines.size () - failed.size () - 1) << (lines.size () - failed.size () - 1)
<< " tasks successfully, with " << " tasks successfully, with "
@ -331,15 +333,16 @@ static std::string importTask_1_4_3 (
join (bad, "\n", failed); join (bad, "\n", failed);
return out.str () + "\nCould not import:\n\n" + bad; return out.str () + "\nCould not import:\n\n" + bad;
} }
*/
return out.str (); return out.str ();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static std::string importTask_1_5_0 ( static std::string importTask_1_5_0 (
TDB& tdb, // TDB& tdb,
const std::vector <std::string>& lines) const std::vector <std::string>& lines)
{ {
/*
std::vector <std::string> failed; std::vector <std::string> failed;
std::vector <std::string>::const_iterator it; std::vector <std::string>::const_iterator it;
@ -477,7 +480,9 @@ static std::string importTask_1_5_0 (
} }
} }
*/
std::stringstream out; std::stringstream out;
/*
out << "Imported " out << "Imported "
<< (lines.size () - failed.size () - 1) << (lines.size () - failed.size () - 1)
<< " tasks successfully, with " << " tasks successfully, with "
@ -491,15 +496,17 @@ static std::string importTask_1_5_0 (
join (bad, "\n", failed); join (bad, "\n", failed);
return out.str () + "\nCould not import:\n\n" + bad; return out.str () + "\nCould not import:\n\n" + bad;
} }
*/
return out.str (); return out.str ();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static std::string importTask_1_6_0 ( static std::string importTask_1_6_0 (
TDB& tdb, // TDB& tdb,
const std::vector <std::string>& lines) const std::vector <std::string>& lines)
{ {
/*
std::vector <std::string> failed; std::vector <std::string> failed;
std::vector <std::string>::const_iterator it; std::vector <std::string>::const_iterator it;
@ -636,8 +643,10 @@ static std::string importTask_1_6_0 (
failed.push_back (*it); failed.push_back (*it);
} }
} }
*/
std::stringstream out; std::stringstream out;
/*
out << "Imported " out << "Imported "
<< (lines.size () - failed.size () - 1) << (lines.size () - failed.size () - 1)
<< " tasks successfully, with " << " tasks successfully, with "
@ -651,15 +660,16 @@ static std::string importTask_1_6_0 (
join (bad, "\n", failed); join (bad, "\n", failed);
return out.str () + "\nCould not import:\n\n" + bad; return out.str () + "\nCould not import:\n\n" + bad;
} }
*/
return out.str (); return out.str ();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static std::string importTaskCmdLine ( static std::string importTaskCmdLine (
TDB& tdb, // TDB& tdb,
const std::vector <std::string>& lines) const std::vector <std::string>& lines)
{ {
/*
std::vector <std::string> failed; std::vector <std::string> failed;
std::vector <std::string>::const_iterator it; std::vector <std::string>::const_iterator it;
@ -683,8 +693,10 @@ static std::string importTaskCmdLine (
failed.push_back (line); failed.push_back (line);
} }
} }
*/
std::stringstream out; std::stringstream out;
/*
out << "Imported " out << "Imported "
<< (lines.size () - failed.size ()) << (lines.size () - failed.size ())
<< " tasks successfully, with " << " tasks successfully, with "
@ -698,15 +710,17 @@ static std::string importTaskCmdLine (
join (bad, "\n", failed); join (bad, "\n", failed);
return out.str () + "\nCould not import:\n\n" + bad; return out.str () + "\nCould not import:\n\n" + bad;
} }
*/
return out.str (); return out.str ();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static std::string importTodoSh_2_0 ( static std::string importTodoSh_2_0 (
TDB& tdb, // TDB& tdb,
const std::vector <std::string>& lines) const std::vector <std::string>& lines)
{ {
/*
std::vector <std::string> failed; std::vector <std::string> failed;
std::vector <std::string>::const_iterator it; std::vector <std::string>::const_iterator it;
@ -804,8 +818,10 @@ static std::string importTodoSh_2_0 (
failed.push_back (*it); failed.push_back (*it);
} }
} }
*/
std::stringstream out; std::stringstream out;
/*
out << "Imported " out << "Imported "
<< (lines.size () - failed.size ()) << (lines.size () - failed.size ())
<< " tasks successfully, with " << " tasks successfully, with "
@ -819,15 +835,16 @@ static std::string importTodoSh_2_0 (
join (bad, "\n", failed); join (bad, "\n", failed);
return out.str () + "\nCould not import:\n\n" + bad; return out.str () + "\nCould not import:\n\n" + bad;
} }
*/
return out.str (); return out.str ();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static std::string importText ( static std::string importText (
TDB& tdb, // TDB& tdb,
const std::vector <std::string>& lines) const std::vector <std::string>& lines)
{ {
/*
std::vector <std::string> failed; std::vector <std::string> failed;
int count = 0; int count = 0;
@ -865,8 +882,10 @@ static std::string importText (
} }
} }
} }
*/
std::stringstream out; std::stringstream out;
/*
out << "Imported " out << "Imported "
<< count << count
<< " tasks successfully, with " << " tasks successfully, with "
@ -880,15 +899,17 @@ static std::string importText (
join (bad, "\n", failed); join (bad, "\n", failed);
return out.str () + "\nCould not import:\n\n" + bad; return out.str () + "\nCould not import:\n\n" + bad;
} }
*/
return out.str (); return out.str ();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static std::string importCSV ( static std::string importCSV (
TDB& tdb, // TDB& tdb,
const std::vector <std::string>& lines) const std::vector <std::string>& lines)
{ {
/*
std::vector <std::string> failed; std::vector <std::string> failed;
// Set up mappings. Assume no fields match. // Set up mappings. Assume no fields match.
@ -1107,8 +1128,10 @@ static std::string importCSV (
failed.push_back (*it); failed.push_back (*it);
} }
} }
*/
std::stringstream out; std::stringstream out;
/*
out << "Imported " out << "Imported "
<< (lines.size () - failed.size () - 1) << (lines.size () - failed.size () - 1)
<< " tasks successfully, with " << " tasks successfully, with "
@ -1122,6 +1145,7 @@ static std::string importCSV (
join (bad, "\n", failed); join (bad, "\n", failed);
return out.str () + "\nCould not import:\n\n" + bad; return out.str () + "\nCould not import:\n\n" + bad;
} }
*/
return out.str (); return out.str ();
} }

View file

@ -40,7 +40,6 @@
#include "Date.h" #include "Date.h"
#include "Duration.h" #include "Duration.h"
#include "Table.h" #include "Table.h"
#include "TDB.h"
#include "T.h" #include "T.h"
#include "text.h" #include "text.h"
#include "util.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 <std::string> 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 ( std::string runTaskCommand (
int argc, int argc,
char** argv, char** argv,
TDB& tdb, // TDB& tdb,
bool gc /* = true */, bool gc /* = true */,
bool shadow /* = true */) bool shadow /* = true */)
{ {
/*
std::vector <std::string> args; std::vector <std::string> args;
for (int i = 1; i < argc; ++i) for (int i = 1; i < argc; ++i)
if (strncmp (argv[i], "rc:", 3) && if (strncmp (argv[i], "rc:", 3) &&
@ -186,16 +141,19 @@ std::cout << "arg=" << argv[i] << std::endl;
} }
return runTaskCommand (args, tdb, gc, shadow); return runTaskCommand (args, tdb, gc, shadow);
*/
return "";
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// TODO Obsolete // TODO Obsolete
std::string runTaskCommand ( std::string runTaskCommand (
std::vector <std::string>& args, std::vector <std::string>& args,
TDB& tdb, // TDB& tdb,
bool gc /* = false */, bool gc /* = false */,
bool shadow /* = false */) bool shadow /* = false */)
{ {
/*
// If argc == 1 and there is a default.command, use it. Otherwise use // If argc == 1 and there is a default.command, use it. Otherwise use
// argc/argv. // argc/argv.
std::string defaultCommand = context.config.get ("default.command"); 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 gcMod = false; // Change occurred by way of gc.
bool cmdMod = false; // Change occurred by way of command type. bool cmdMod = false; // Change occurred by way of command type.
*/
std::string out; std::string out;
/* /*
// Read-only commands with no side effects. // Read-only commands with no side effects.

View file

@ -31,7 +31,6 @@
#include <sys/types.h> #include <sys/types.h>
#include "Context.h" #include "Context.h"
#include "T.h" #include "T.h"
#include "TDB.h"
#include "Table.h" #include "Table.h"
#include "Date.h" #include "Date.h"
#include "color.h" #include "color.h"
@ -49,18 +48,20 @@ 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&, std::vector <T>&, std::vector <int>&); void gatherNextTasks (/*const TDB&,*/ T&, std::vector <T>&, std::vector <int>&);
void onChangeCallback (); void onChangeCallback ();
/*
std::string runTaskCommand (int, char**, TDB&, bool gc = true, bool shadow = true); std::string runTaskCommand (int, char**, TDB&, bool gc = true, bool shadow = true);
std::string runTaskCommand (std::vector <std::string>&, TDB&, bool gc = false, bool shadow = false); std::string runTaskCommand (std::vector <std::string>&, TDB&, bool gc = false, bool shadow = false);
*/
// recur.cpp // recur.cpp
void handleRecurrence (); void handleRecurrence ();
Date getNextRecurrence (Date&, std::string&); Date getNextRecurrence (Date&, std::string&);
bool generateDueDates (T&, std::vector <Date>&); bool generateDueDates (T&, std::vector <Date>&);
void updateRecurrenceMask (TDB&, std::vector <T>&, T&); void updateRecurrenceMask (/*TDB&,*/ std::vector <T>&, T&);
int getDueState (const std::string&); int getDueState (const std::string&);
void nag (TDB&, T&); void nag (/*TDB&,*/ T&);
// command.cpp // command.cpp
std::string handleAdd (); std::string handleAdd ();

View file

@ -39,8 +39,6 @@
#include "Context.h" #include "Context.h"
#include "Date.h" #include "Date.h"
#include "Duration.h" #include "Duration.h"
#include "Table.h"
#include "TDB.h"
#include "T.h" #include "T.h"
#include "text.h" #include "text.h"
#include "util.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 // When the status of a recurring child task changes, the parent task must
// update it's mask. // update it's mask.
void updateRecurrenceMask ( void updateRecurrenceMask (
TDB& tdb, // TDB& tdb,
std::vector <T>& all, std::vector <T>& all,
T& task) T& task)
{ {
/*
std::string parent = task.getAttribute ("parent"); std::string parent = task.getAttribute ("parent");
if (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 ("")); std::string nagMessage = context.config.get ("nag", std::string (""));
if (nagMessage != "") 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. // All the excuses are made, all that remains is to nag the user.
std::cout << nagMessage << std::endl; std::cout << nagMessage << std::endl;
} }
*/
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -38,7 +38,6 @@
#include "Context.h" #include "Context.h"
#include "Date.h" #include "Date.h"
#include "Table.h" #include "Table.h"
#include "TDB.h"
#include "T.h" #include "T.h"
#include "text.h" #include "text.h"
#include "util.h" #include "util.h"
@ -2431,7 +2430,7 @@ std::string handleReportStats ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void gatherNextTasks ( void gatherNextTasks (
const TDB& tdb, // const TDB& tdb,
T& task, T& task,
std::vector <T>& pending, std::vector <T>& pending,
std::vector <int>& all) std::vector <int>& all)

View file

@ -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 cmd.t config.t
CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti
LFLAGS = -L/usr/local/lib -lncurses LFLAGS = -L/usr/local/lib -lncurses
OBJECTS = ../TDB.o ../TDB2.o ../T.o ../Task.o ../parse.o ../text.o ../Date.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 \ ../Duration.o ../util.o ../Config.o ../Sequence.o ../Att.o ../Cmd.o \
../Record.o ../StringTable.o ../Subst.o ../Nibbler.o ../Location.o \ ../Record.o ../StringTable.o ../Subst.o ../Nibbler.o ../Location.o \
../Filter.o ../Context.o ../Keymap.o ../Cmd.o ../command.o \ ../Filter.o ../Context.o ../Keymap.o ../command.o ../interactive.o \
../report.o ../Table.o ../Grid.o ../color.o ../rules.o ../recur.o \ ../report.o ../Grid.o ../color.o ../rules.o ../recur.o
../interactive.o
all: $(PROJECT) all: $(PROJECT)

View file

@ -24,7 +24,6 @@
// USA // USA
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include "TDB.h"
#include "T.h" #include "T.h"
#include "main.h" #include "main.h"
#include "test.h" #include "test.h"

View file

@ -27,7 +27,6 @@
#include <iostream> #include <iostream>
#include <unistd.h> #include <unistd.h>
#include "TDB.h"
#include "main.h" #include "main.h"
#include "test.h" #include "test.h"
@ -40,6 +39,7 @@ int main (int argc, char** argv)
try try
{ {
/*
// Remove any residual test file. // Remove any residual test file.
unlink ("./pending.data"); unlink ("./pending.data");
unlink ("./completed.data"); unlink ("./completed.data");
@ -113,6 +113,7 @@ int main (int argc, char** argv)
// GC the files. // GC the files.
t.is (tdb.gc (), 1, "1 <- TDB::gc"); t.is (tdb.gc (), 1, "1 <- TDB::gc");
*/
} }
catch (std::string& error) catch (std::string& error)

View file

@ -36,10 +36,8 @@
#include <string.h> #include <string.h>
#include <pwd.h> #include <pwd.h>
#include <errno.h> #include <errno.h>
#include "Date.h" #include "Date.h"
#include "Table.h"
#include "T.h"
#include "TDB.h"
#include "text.h" #include "text.h"
#include "main.h" #include "main.h"
#include "i18n.h" #include "i18n.h"