Code Cleanup

- Renamed T2.h -> Task.h, T2.cpp -> Task.cpp.  This permanently avoids
  the problem where g++ on OpenBSD 4.5 fails because of the T class,
  which probably conflicts with C++ templates.  Who knows.
This commit is contained in:
Paul Beckingham 2009-06-10 21:35:07 -04:00
parent 71f4749d56
commit d7da182450
12 changed files with 83 additions and 83 deletions

View file

@ -33,7 +33,7 @@
#include "Sequence.h"
#include "Subst.h"
#include "Cmd.h"
#include "T2.h"
#include "Task.h"
#include "TDB2.h"
#include "StringTable.h"
@ -64,7 +64,7 @@ public:
Keymap keymap;
Sequence sequence;
Subst subst;
T2 task;
Task task;
TDB2 tdb;
StringTable stringtable;
std::string program;

View file

@ -1,12 +1,12 @@
bin_PROGRAMS = task
task_SOURCES = Att.cpp Cmd.cpp Config.cpp Context.cpp Date.cpp Duration.cpp \
Filter.cpp Grid.cpp Keymap.cpp Location.cpp Nibbler.cpp \
Record.cpp Sequence.cpp StringTable.cpp Subst.cpp T2.cpp \
Record.cpp Sequence.cpp StringTable.cpp Subst.cpp Task.cpp \
TDB2.cpp Table.cpp Timer.cpp color.cpp command.cpp edit.cpp \
import.cpp interactive.cpp parse.cpp recur.cpp report.cpp \
rules.cpp main.cpp text.cpp util.cpp \
Att.h Cmd.h Config.h Context.h Date.h Duration.h Filter.h \
Grid.h Keymap.h Location.h Nibbler.h Record.h Sequence.h \
StringTable.h Subst.h T2.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 \
T.cpp T.h TDB.cpp TDB.h

View file

@ -154,7 +154,7 @@ void TDB2::unlock ()
////////////////////////////////////////////////////////////////////////////////
// Returns number of filtered tasks.
int TDB2::load (std::vector <T2>& tasks, Filter& filter)
int TDB2::load (std::vector <Task>& tasks, Filter& filter)
{
// Note: tasks.clear () is deliberately not called, to allow the combination
// of multiple files.
@ -178,7 +178,7 @@ int TDB2::load (std::vector <T2>& tasks, Filter& filter)
{
// TODO Add hidden attribute indicating source?
line[length - 1] = '\0'; // Kill \n
T2 task (line);
Task task (line);
if (filter.pass (task))
tasks.push_back (task);
}
@ -198,7 +198,7 @@ int TDB2::load (std::vector <T2>& tasks, Filter& filter)
{
// TODO Add hidden attribute indicating source?
line[length - 1] = '\0'; // Kill \n
T2 task (line);
Task task (line);
if (filter.pass (task))
tasks.push_back (task);
}
@ -220,7 +220,7 @@ int TDB2::load (std::vector <T2>& tasks, Filter& filter)
////////////////////////////////////////////////////////////////////////////////
// TODO Write to transaction log.
void TDB2::add (T2& after)
void TDB2::add (Task& after)
{
throw std::string ("unimplemented TDB2::add");
@ -230,7 +230,7 @@ void TDB2::add (T2& after)
////////////////////////////////////////////////////////////////////////////////
// TODO Write to transaction log.
void TDB2::update (T2& before, T2& after)
void TDB2::update (Task& before, Task& after)
{
throw std::string ("unimplemented TDB2::update");
}

View file

@ -32,7 +32,7 @@
#include <string>
#include <Location.h>
#include <Filter.h>
#include <T2.h>
#include <Task.h>
// Length of longest line.
#define T_LINE_MAX 32768
@ -50,9 +50,9 @@ public:
void lock (bool lockFile = true);
void unlock ();
int load (std::vector <T2>&, Filter&);
void add (T2&);
void update (T2&, T2&);
int load (std::vector <Task>&, Filter&);
void add (Task&);
void update (Task&, Task&);
int commit ();
void upgrade ();

View file

@ -28,12 +28,12 @@
#include <sstream>
#include <algorithm>
#include "Nibbler.h"
#include "T2.h"
#include "Task.h"
#include "text.h"
#include "util.h"
////////////////////////////////////////////////////////////////////////////////
T2::T2 ()
Task::Task ()
{
// Each new task gets a uuid.
set ("uuid", uuid ());
@ -42,7 +42,7 @@ T2::T2 ()
////////////////////////////////////////////////////////////////////////////////
// Attempt an FF4 parse first, using Record::parse, and in the event of an error
// try a legacy parse (F3, FF2). Note that FF1 is no longer supported.
T2::T2 (const std::string& input)
Task::Task (const std::string& input)
{
try
{
@ -56,9 +56,9 @@ T2::T2 (const std::string& input)
}
////////////////////////////////////////////////////////////////////////////////
T2& T2::operator= (const T2& other)
Task& Task::operator= (const Task& other)
{
throw std::string ("unimplemented T2::operator=");
throw std::string ("unimplemented Task::operator=");
if (this != &other)
{
sequence = other.sequence;
@ -69,12 +69,12 @@ T2& T2::operator= (const T2& other)
}
////////////////////////////////////////////////////////////////////////////////
T2::~T2 ()
Task::~Task ()
{
}
////////////////////////////////////////////////////////////////////////////////
T2::status T2::textToStatus (const std::string& input)
Task::status Task::textToStatus (const std::string& input)
{
if (input == "pending") return pending;
else if (input == "completed") return completed;
@ -85,7 +85,7 @@ T2::status T2::textToStatus (const std::string& input)
}
////////////////////////////////////////////////////////////////////////////////
std::string T2::statusToText (T2::status s)
std::string Task::statusToText (Task::status s)
{
if (s == pending) return "pending";
else if (s == completed) return "completed";
@ -96,19 +96,19 @@ std::string T2::statusToText (T2::status s)
}
////////////////////////////////////////////////////////////////////////////////
T2::status T2::getStatus ()
Task::status Task::getStatus ()
{
return textToStatus (get ("status"));
}
////////////////////////////////////////////////////////////////////////////////
void T2::setSatus (T2::status status)
void Task::setSatus (Task::status status)
{
set ("status", statusToText (status));
}
////////////////////////////////////////////////////////////////////////////////
void T2::parse (const std::string& line)
void Task::parse (const std::string& line)
{
try
{
@ -124,7 +124,7 @@ void T2::parse (const std::string& line)
////////////////////////////////////////////////////////////////////////////////
// Support FF2, FF3.
// Thankfully FF1 is no longer supported.
void T2::legacyParse (const std::string& line)
void Task::legacyParse (const std::string& line)
{
switch (determineVersion (line))
{
@ -141,7 +141,7 @@ void T2::legacyParse (const std::string& line)
{
set ("uuid", line.substr (0, 36));
T2::status status = line[37] == '+' ? completed
Task::status status = line[37] == '+' ? completed
: line[37] == 'X' ? deleted
: line[37] == 'r' ? recurring
: pending;
@ -198,7 +198,7 @@ void T2::legacyParse (const std::string& line)
{
set ("uuid", line.substr (0, 36));
T2::status status = line[37] == '+' ? completed
Task::status status = line[37] == '+' ? completed
: line[37] == 'X' ? deleted
: line[37] == 'r' ? recurring
: pending;
@ -302,14 +302,14 @@ void T2::legacyParse (const std::string& line)
}
////////////////////////////////////////////////////////////////////////////////
std::string T2::composeCSV ()
std::string Task::composeCSV ()
{
throw std::string ("unimplemented T2::composeCSV");
throw std::string ("unimplemented Task::composeCSV");
return "";
}
////////////////////////////////////////////////////////////////////////////////
void T2::getAnnotations (std::vector <Att>& annotations) const
void Task::getAnnotations (std::vector <Att>& annotations) const
{
annotations.clear ();
@ -320,7 +320,7 @@ void T2::getAnnotations (std::vector <Att>& annotations) const
}
////////////////////////////////////////////////////////////////////////////////
void T2::setAnnotations (const std::vector <Att>& annotations)
void Task::setAnnotations (const std::vector <Att>& annotations)
{
// Erase old annotations.
removeAnnotations ();
@ -334,7 +334,7 @@ void T2::setAnnotations (const std::vector <Att>& annotations)
// The timestamp is part of the name:
// annotation_1234567890:"..."
//
void T2::addAnnotation (const std::string& description)
void Task::addAnnotation (const std::string& description)
{
std::stringstream s;
s << "annotation_" << time (NULL);
@ -343,7 +343,7 @@ void T2::addAnnotation (const std::string& description)
}
////////////////////////////////////////////////////////////////////////////////
void T2::removeAnnotations ()
void Task::removeAnnotations ()
{
// Erase old annotations.
Record::iterator i;
@ -353,7 +353,7 @@ void T2::removeAnnotations ()
}
////////////////////////////////////////////////////////////////////////////////
int T2::getTagCount ()
int Task::getTagCount ()
{
std::vector <std::string> tags;
split (tags, get ("tags"), ',');
@ -362,7 +362,7 @@ int T2::getTagCount ()
}
////////////////////////////////////////////////////////////////////////////////
bool T2::hasTag (const std::string& tag)
bool Task::hasTag (const std::string& tag)
{
std::vector <std::string> tags;
split (tags, get ("tags"), ',');
@ -374,7 +374,7 @@ bool T2::hasTag (const std::string& tag)
}
////////////////////////////////////////////////////////////////////////////////
void T2::addTag (const std::string& tag)
void Task::addTag (const std::string& tag)
{
std::vector <std::string> tags;
split (tags, get ("tags"), ',');
@ -389,7 +389,7 @@ void T2::addTag (const std::string& tag)
}
////////////////////////////////////////////////////////////////////////////////
void T2::addTags (const std::vector <std::string>& tags)
void Task::addTags (const std::vector <std::string>& tags)
{
remove ("tags");
@ -399,13 +399,13 @@ void T2::addTags (const std::vector <std::string>& tags)
}
////////////////////////////////////////////////////////////////////////////////
void T2::getTags (std::vector<std::string>& tags)
void Task::getTags (std::vector<std::string>& tags)
{
split (tags, get ("tags"), ',');
}
////////////////////////////////////////////////////////////////////////////////
void T2::removeTag (const std::string& tag)
void Task::removeTag (const std::string& tag)
{
std::vector <std::string> tags;
split (tags, get ("tags"), ',');
@ -422,7 +422,7 @@ void T2::removeTag (const std::string& tag)
}
////////////////////////////////////////////////////////////////////////////////
bool T2::valid () const
bool Task::valid () const
{
// TODO Verify until > due
// TODO Verify entry < until, due, start, end
@ -431,7 +431,7 @@ bool T2::valid () const
}
////////////////////////////////////////////////////////////////////////////////
int T2::determineVersion (const std::string& line)
int Task::determineVersion (const std::string& line)
{
// Version 2 looks like:
//

View file

@ -24,21 +24,21 @@
// USA
//
////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_T2
#define INCLUDED_T2
#ifndef INCLUDED_TASK
#define INCLUDED_TASK
#include <string>
#include "Record.h"
#include "Subst.h"
#include "Sequence.h"
class T2 : public Record
class Task : public Record
{
public:
T2 (); // Default constructor
T2 (const std::string&); // Parse
T2& operator= (const T2&); // Assignment operator
~T2 (); // Destructor
Task (); // Default constructor
Task (const std::string&); // Parse
Task& operator= (const Task&); // Assignment operator
~Task (); // Destructor
void parse (const std::string&);
std::string composeCSV ();

View file

@ -98,7 +98,7 @@ std::string handleProjects ()
context.filter.push_back (Att ("status", "pending"));
std::vector <T2> tasks;
std::vector <Task> tasks;
context.tdb.lock (context.config.get ("locking", true));
int quantity = context.tdb.load (tasks, context.filter);
context.tdb.unlock ();
@ -155,7 +155,7 @@ std::string handleTags ()
context.filter.push_back (Att ("status", "pending"));
std::vector <T2> tasks;
std::vector <Task> tasks;
context.tdb.lock (context.config.get ("locking", true));
int quantity = context.tdb.load (tasks, context.filter);
context.tdb.unlock ();

View file

@ -56,7 +56,7 @@ extern Context context;
////////////////////////////////////////////////////////////////////////////////
// Scans all tasks, and for any recurring tasks, determines whether any new
// child tasks need to be generated to fill gaps.
void handleRecurrence (std::vector <T2>& tasks)
void handleRecurrence (std::vector <Task>& tasks)
{
/*
std::vector <T> modified;

View file

@ -3,7 +3,7 @@ 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 ../T2.o ../parse.o ../text.o ../Date.o \
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 \
../Record.o ../StringTable.o ../Subst.o ../Nibbler.o ../Location.o \
../Filter.o ../Context.o ../Keymap.o ../Cmd.o ../command.o \

View file

@ -27,7 +27,7 @@
#include "main.h"
#include "test.h"
#include "Filter.h"
#include "T2.h"
#include "Task.h"
Context context;
@ -42,8 +42,8 @@ int main (int argc, char** argv)
f.push_back (Att ("name2", "value2"));
test.is (f.size (), (size_t)2, "Filter created");
// Create a T2 to match against.
T2 yes;
// Create a Task to match against.
Task yes;
yes.set ("name1", "value1");
yes.set ("name2", "value2");
test.ok (f.pass (yes), "full match");
@ -52,19 +52,19 @@ int main (int argc, char** argv)
test.ok (f.pass (yes), "over match");
// Negative tests.
T2 no0;
test.notok (f.pass (no0), "no match against default T2");
Task no0;
test.notok (f.pass (no0), "no match against default Task");
T2 no1;
Task no1;
no1.set ("name3", "value3");
test.notok (f.pass (no1), "no match against mismatch T2");
test.notok (f.pass (no1), "no match against mismatch Task");
T2 partial;
Task partial;
partial.set ("name1", "value1");
test.notok (f.pass (partial), "no match against partial T2");
test.notok (f.pass (partial), "no match against partial Task");
// Modifiers.
T2 mods;
Task mods;
mods.set ("name", "value");
Att a ("name", "value");

View file

@ -25,7 +25,7 @@
//
////////////////////////////////////////////////////////////////////////////////
#include <Context.h>
#include <T2.h>
#include <Task.h>
#include <Subst.h>
#include <test.h>
@ -36,7 +36,7 @@ int main (int argc, char** argv)
{
UnitTest t (15);
T2 task;
Task task;
task.set ("description", "one two three four");
Subst s;

View file

@ -34,18 +34,18 @@ int main (int argc, char** argv)
{
UnitTest test (34);
test.is ((int)T2::textToStatus ("pending"), (int)T2::pending, "textToStatus pending");
test.is ((int)T2::textToStatus ("completed"), (int)T2::completed, "textToStatus completed");
test.is ((int)T2::textToStatus ("deleted"), (int)T2::deleted, "textToStatus deleted");
test.is ((int)T2::textToStatus ("recurring"), (int)T2::recurring, "textToStatus recurring");
test.is ((int)Task::textToStatus ("pending"), (int)Task::pending, "textToStatus pending");
test.is ((int)Task::textToStatus ("completed"), (int)Task::completed, "textToStatus completed");
test.is ((int)Task::textToStatus ("deleted"), (int)Task::deleted, "textToStatus deleted");
test.is ((int)Task::textToStatus ("recurring"), (int)Task::recurring, "textToStatus recurring");
test.is (T2::statusToText (T2::pending), "pending", "statusToText pending");
test.is (T2::statusToText (T2::completed), "completed", "statusToText completed");
test.is (T2::statusToText (T2::deleted), "deleted", "statusToText deleted");
test.is (T2::statusToText (T2::recurring), "recurring", "statusToText recurring");
test.is (Task::statusToText (Task::pending), "pending", "statusToText pending");
test.is (Task::statusToText (Task::completed), "completed", "statusToText completed");
test.is (Task::statusToText (Task::deleted), "deleted", "statusToText deleted");
test.is (Task::statusToText (Task::recurring), "recurring", "statusToText recurring");
// Round-trip testing.
T2 t3;
Task t3;
std::string before = t3.composeF4 ();
t3.parse (before);
std::string after = t3.composeF4 ();
@ -53,7 +53,7 @@ int main (int argc, char** argv)
after = t3.composeF4 ();
t3.parse (after);
after = t3.composeF4 ();
test.is (before, after, "T2::composeF4 -> parse round trip 4 iterations");
test.is (before, after, "Task::composeF4 -> parse round trip 4 iterations");
// Legacy Format 1
// [tags] [attributes] description\n
@ -64,7 +64,7 @@ int main (int argc, char** argv)
"[att1:value1 att2:value2] "
"Description";
bool good = true;
try { T2 ff1 (sample); } catch (...) { good = false; }
try { Task ff1 (sample); } catch (...) { good = false; }
test.notok (good, "Support for ff1 removed");
// Legacy Format 2
@ -74,7 +74,7 @@ int main (int argc, char** argv)
"[tag1 tag2] "
"[att1:value1 att2:value2] "
"Description";
T2 ff2 (sample);
Task ff2 (sample);
std::string value = ff2.get ("uuid");
test.is (value, "00000000-0000-0000-0000-000000000000", "ff2 uuid");
value = ff2.get ("status");
@ -96,7 +96,7 @@ int main (int argc, char** argv)
"[tag1 tag2] "
"[att1:value1 att2:value2] "
"[123:ann1 456:ann2] Description";
T2 ff3 (sample);
Task ff3 (sample);
value = ff2.get ("uuid");
test.is (value, "00000000-0000-0000-0000-000000000000", "ff3 uuid");
value = ff2.get ("status");
@ -121,7 +121,7 @@ int main (int argc, char** argv)
"att2:\"value2\" "
"description:\"Description\""
"]";
T2 ff4 (sample);
Task ff4 (sample);
value = ff2.get ("uuid");
test.is (value, "00000000-0000-0000-0000-000000000000", "ff4 uuid");
value = ff2.get ("status");
@ -138,11 +138,11 @@ int main (int argc, char** argv)
/*
T2::composeCSV
T2::id
T2::*Status
T2::*Tag*
T2::*Annotation*
Task::composeCSV
Task::id
Task::*Status
Task::*Tag*
Task::*Annotation*
*/