mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Enhancement - Object rename prior to integration
- T -> T2 - TDB -> TDB2
This commit is contained in:
parent
766c2d3620
commit
fe4c8f3a9d
12 changed files with 96 additions and 81 deletions
|
@ -161,6 +161,12 @@ void Att::addMod (const Mod& mod)
|
|||
mMods.push_back (mod);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Att::mods (std::vector <Mod>& all)
|
||||
{
|
||||
all = mMods;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Att::name () const
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
std::string composeF4 () const;
|
||||
|
||||
void addMod (const Mod&);
|
||||
// TODO Need method to access mods.
|
||||
void mods (std::vector <Mod>&);
|
||||
|
||||
std::string name () const;
|
||||
void name (const std::string&);
|
||||
|
|
|
@ -53,12 +53,6 @@ Record::Record (const std::string& input)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
Record& Record::operator= (const Record& other)
|
||||
{
|
||||
throw std::string ("unimplemented Record:operator=");
|
||||
if (this != &other)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -88,25 +82,23 @@ std::string Record::composeF4 ()
|
|||
//
|
||||
// start --> name --> : --> " --> value --> " --> end
|
||||
// ^ |
|
||||
// |________________________________|
|
||||
// +------------- \s <--------------+
|
||||
//
|
||||
void Record::parse (const std::string& input)
|
||||
{
|
||||
Nibbler n (input);
|
||||
std::string line;
|
||||
if (n.skip ('[') && n.getUntil (']', line))
|
||||
if (n.skip ('[') &&
|
||||
n.getUntil (']', line) &&
|
||||
n.skip (']') &&
|
||||
n.depleted ())
|
||||
{
|
||||
Nibbler nl (line);
|
||||
|
||||
bool first = true;
|
||||
Att a;
|
||||
while (a.parse (nl))
|
||||
{
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
nl.skip (' ');
|
||||
|
||||
nl.skip (' ');
|
||||
(*this)[a.name ()] = a;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
#include "Keymap.h"
|
||||
#include "Config.h"
|
||||
#include "Sequence.h"
|
||||
#include "T.h"
|
||||
#include "TDB.h"
|
||||
#include "T2.h"
|
||||
#include "TDB2.h"
|
||||
#include "StringTable.h"
|
||||
|
||||
class Context
|
||||
|
@ -55,8 +55,8 @@ public:
|
|||
Filter filter;
|
||||
Keymap keymap;
|
||||
Sequence sequence;
|
||||
T task;
|
||||
TDB tdb;
|
||||
T2 task;
|
||||
TDB2 tdb;
|
||||
StringTable stringtable;
|
||||
|
||||
private:
|
||||
|
|
|
@ -2,7 +2,7 @@ PROJECT = 1.8
|
|||
CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti -fno-stack-check
|
||||
LFLAGS =
|
||||
LIBS =
|
||||
OBJECTS = main.o Context.o TDB.o T.o ../Sequence.o ../Filter.o ../Att.o \
|
||||
OBJECTS = main.o Context.o TDB2.o T2.o ../Sequence.o ../Filter.o ../Att.o \
|
||||
../Keymap.o ../Record.o ../Mod.o ../StringTable.o ../util.o \
|
||||
../text.o ../Date.o ../Config.o ../Location.o ../Subst.o ../Nibbler.o
|
||||
|
||||
|
|
|
@ -26,23 +26,23 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <string>
|
||||
#include "T.h"
|
||||
#include "T2.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
T::T ()
|
||||
T2::T2 ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
T::T (const std::string& input)
|
||||
T2::T2 (const std::string& input)
|
||||
{
|
||||
parse (input);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
T& T::operator= (const T& other)
|
||||
T2& T2::operator= (const T2& other)
|
||||
{
|
||||
throw std::string ("unimplemented T::operator=");
|
||||
throw std::string ("unimplemented T2::operator=");
|
||||
if (this != &other)
|
||||
{
|
||||
// mOne = other.mOne;
|
||||
|
@ -52,27 +52,27 @@ T& T::operator= (const T& other)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
T::~T ()
|
||||
T2::~T2 ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// [name:value, name:"value",name:[name:value,name:value]]
|
||||
std::string T::composeF4 ()
|
||||
std::string T2::composeF4 ()
|
||||
{
|
||||
throw std::string ("unimplemented T::composeF4");
|
||||
throw std::string ("unimplemented T2::composeF4");
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string T::composeCSV ()
|
||||
std::string T2::composeCSV ()
|
||||
{
|
||||
throw std::string ("unimplemented T::composeCSV");
|
||||
throw std::string ("unimplemented T2::composeCSV");
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool T::validate () const
|
||||
bool T2::validate () const
|
||||
{
|
||||
// TODO Verify until > due
|
||||
// TODO Verify entry < until, due, start, end
|
|
@ -24,19 +24,19 @@
|
|||
// USA
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef INCLUDED_T
|
||||
#define INCLUDED_T
|
||||
#ifndef INCLUDED_T2
|
||||
#define INCLUDED_T2
|
||||
|
||||
#include <string>
|
||||
#include "Record.h"
|
||||
|
||||
class T : public Record
|
||||
class T2 : public Record
|
||||
{
|
||||
public:
|
||||
T (); // Default constructor
|
||||
T (const std::string&); // Parse
|
||||
T& operator= (const T&); // Assignment operator
|
||||
~T (); // Destructor
|
||||
T2 (); // Default constructor
|
||||
T2 (const std::string&); // Parse
|
||||
T2& operator= (const T2&); // Assignment operator
|
||||
~T2 (); // Destructor
|
||||
|
||||
std::string composeF4 ();
|
||||
std::string composeCSV ();
|
|
@ -31,7 +31,7 @@
|
|||
#include <sys/file.h>
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
#include "TDB.h"
|
||||
#include "TDB2.h"
|
||||
#include "task.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -64,16 +64,16 @@
|
|||
// +- TDB::~TDB
|
||||
// [TDB::unlock]
|
||||
//
|
||||
TDB::TDB ()
|
||||
TDB2::TDB2 ()
|
||||
: mLock (true)
|
||||
, mAllOpenAndLocked (false)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
TDB::TDB (const TDB& other)
|
||||
TDB2::TDB2 (const TDB2& other)
|
||||
{
|
||||
throw std::string ("unimplemented TDB::TDB");
|
||||
throw std::string ("unimplemented TDB2::TDB2");
|
||||
// mLocations = other.mLocations;
|
||||
// mFiles = other.mFiles;
|
||||
// mLock = other.mLock;
|
||||
|
@ -85,9 +85,9 @@ TDB::TDB (const TDB& other)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
TDB& TDB::operator= (const TDB& other)
|
||||
TDB2& TDB2::operator= (const TDB2& other)
|
||||
{
|
||||
throw std::string ("unimplemented TDB::operator=");
|
||||
throw std::string ("unimplemented TDB2::operator=");
|
||||
// if (this != &other)
|
||||
// {
|
||||
// mLocations = other.mLocations;
|
||||
|
@ -104,14 +104,14 @@ TDB& TDB::operator= (const TDB& other)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
TDB::~TDB ()
|
||||
TDB2::~TDB2 ()
|
||||
{
|
||||
if (mAllOpenAndLocked)
|
||||
unlock ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TDB::location (const std::string& path)
|
||||
void TDB2::location (const std::string& path)
|
||||
{
|
||||
if (access (expandPath (path).c_str (), F_OK))
|
||||
throw std::string ("Data location '") +
|
||||
|
@ -122,7 +122,7 @@ void TDB::location (const std::string& path)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TDB::lock (bool lockFile /* = true */)
|
||||
void TDB2::lock (bool lockFile /* = true */)
|
||||
{
|
||||
mLock = lockFile;
|
||||
|
||||
|
@ -136,7 +136,7 @@ void TDB::lock (bool lockFile /* = true */)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TDB::unlock ()
|
||||
void TDB2::unlock ()
|
||||
{
|
||||
if (mAllOpenAndLocked)
|
||||
{
|
||||
|
@ -154,7 +154,7 @@ void TDB::unlock ()
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Returns number of filtered tasks.
|
||||
int TDB::load (std::vector <T>& tasks, Filter& filter)
|
||||
int TDB2::load (std::vector <T2>& tasks, Filter& filter)
|
||||
{
|
||||
std::string file;
|
||||
int line_number;
|
||||
|
@ -176,7 +176,7 @@ int TDB::load (std::vector <T>& tasks, Filter& filter)
|
|||
line[length - 1] = '\0'; // Kill \n
|
||||
std::cout << "# line: " << line << std::endl;
|
||||
|
||||
T task (line);
|
||||
T2 task (line);
|
||||
|
||||
if (filter.pass (task))
|
||||
{
|
||||
|
@ -198,7 +198,7 @@ int TDB::load (std::vector <T>& tasks, Filter& filter)
|
|||
line[length - 1] = '\0'; // Kill \n
|
||||
std::cout << "# line: " << line << std::endl;
|
||||
|
||||
T task (line);
|
||||
T2 task (line);
|
||||
|
||||
if (filter.pass (task))
|
||||
{
|
||||
|
@ -224,9 +224,9 @@ int TDB::load (std::vector <T>& tasks, Filter& filter)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TODO Write to transaction log.
|
||||
void TDB::add (T& after)
|
||||
void TDB2::add (T2& after)
|
||||
{
|
||||
throw std::string ("unimplemented TDB::add");
|
||||
throw std::string ("unimplemented TDB2::add");
|
||||
|
||||
// TODO Seek to end of pending.
|
||||
// TODO write after.composeFF4 ().
|
||||
|
@ -234,27 +234,27 @@ void TDB::add (T& after)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TODO Write to transaction log.
|
||||
void TDB::update (T& before, T& after)
|
||||
void TDB2::update (T2& before, T2& after)
|
||||
{
|
||||
throw std::string ("unimplemented TDB::update");
|
||||
throw std::string ("unimplemented TDB2::update");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TODO writes all, including comments
|
||||
int TDB::commit ()
|
||||
int TDB2::commit ()
|
||||
{
|
||||
throw std::string ("unimplemented TDB::commit");
|
||||
throw std::string ("unimplemented TDB2::commit");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TODO -> FF4
|
||||
void TDB::upgrade ()
|
||||
void TDB2::upgrade ()
|
||||
{
|
||||
throw std::string ("unimplemented TDB::upgrade");
|
||||
throw std::string ("unimplemented TDB2::upgrade");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
FILE* TDB::openAndLock (const std::string& file)
|
||||
FILE* TDB2::openAndLock (const std::string& file)
|
||||
{
|
||||
// Check for access.
|
||||
if (access (file.c_str (), F_OK | R_OK | W_OK))
|
|
@ -24,35 +24,35 @@
|
|||
// USA
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef INCLUDED_TDB
|
||||
#define INCLUDED_TDB
|
||||
#ifndef INCLUDED_TDB2
|
||||
#define INCLUDED_TDB2
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <Location.h>
|
||||
#include <Filter.h>
|
||||
#include <T.h>
|
||||
#include <T2.h>
|
||||
|
||||
// Length of longest line.
|
||||
#define T_LINE_MAX 32768
|
||||
|
||||
class TDB
|
||||
class TDB2
|
||||
{
|
||||
public:
|
||||
TDB (); // Default constructor
|
||||
TDB (const TDB&); // Copy constructor
|
||||
TDB& operator= (const TDB&); // Assignment operator
|
||||
~TDB (); // Destructor
|
||||
TDB2 (); // Default constructor
|
||||
TDB2 (const TDB2&); // Copy constructor
|
||||
TDB2& operator= (const TDB2&); // Assignment operator
|
||||
~TDB2 (); // Destructor
|
||||
|
||||
void location (const std::string&);
|
||||
|
||||
void lock (bool lockFile = true);
|
||||
void unlock ();
|
||||
|
||||
int load (std::vector <T>&, Filter&);
|
||||
void add (T&);
|
||||
void update (T&, T&);
|
||||
int load (std::vector <T2>&, Filter&);
|
||||
void add (T2&);
|
||||
void update (T2&, T2&);
|
||||
int commit ();
|
||||
void upgrade ();
|
||||
|
|
@ -17,7 +17,7 @@ int main (int argc, char** argv)
|
|||
|
||||
c.filter.push_back (Att ("priority", "L"));
|
||||
|
||||
std::vector <T> tasks;
|
||||
std::vector <T2> tasks;
|
||||
int quantity = c.tdb.load (tasks, c.filter);
|
||||
std::cout << "# " << quantity << " <-- c.tdb.load" << std::endl;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (36);
|
||||
UnitTest t (38);
|
||||
|
||||
Att a1 ("name", "value");
|
||||
t.is (a1.name (), "name", "Att::Att (name, value), Att.name");
|
||||
|
@ -73,6 +73,12 @@ int main (int argc, char** argv)
|
|||
try {a6.addMod (Mod ("fartwizzle"));} catch (...) {good = false;}
|
||||
t.notok (good, "Att::addMod (fartwizzle)");
|
||||
|
||||
// Att::mods
|
||||
std::vector <Mod> mods;
|
||||
a6.mods (mods);
|
||||
t.is (mods.size (), (size_t)1, "Att::mods () size == 1");
|
||||
t.is (mods[0], "is", "Att::mods [0] == 'is'");
|
||||
|
||||
// Att::parse
|
||||
Nibbler n ("");
|
||||
Att a7;
|
||||
|
|
|
@ -32,11 +32,26 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
Record parseRecord (const std::string& input)
|
||||
{
|
||||
try { Record r (input); return r; }
|
||||
catch (...) {}
|
||||
try
|
||||
{
|
||||
Record r (input);
|
||||
return r;
|
||||
}
|
||||
|
||||
catch (std::string& e)
|
||||
{
|
||||
std::cout << "# Exception: " << e << std::endl;
|
||||
}
|
||||
|
||||
catch (...)
|
||||
{
|
||||
std::cout << "# Exception!" << std::endl;
|
||||
}
|
||||
|
||||
return Record ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (4);
|
||||
|
@ -49,8 +64,8 @@ int main (int argc, char** argv)
|
|||
record = parseRecord ("[]");
|
||||
t.is (record.size (), (size_t)0, "Record []");
|
||||
|
||||
// [name:value]
|
||||
record = parseRecord ("[name:value]");
|
||||
// [name:"value"]
|
||||
record = parseRecord ("[name:\"value\"]");
|
||||
t.is (record.size (), (size_t)1, "Record [name:value]");
|
||||
if (record.size () == 1)
|
||||
{
|
||||
|
@ -66,10 +81,6 @@ int main (int argc, char** argv)
|
|||
// TODO [name:"one two"]
|
||||
// TODO [one:two three:four]
|
||||
|
||||
// TODO FF3
|
||||
// TODO FF2
|
||||
// TODO FF1
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue