From 69ed1e0ebbb40aa139e1371e5e5bfaa3317f2d7a Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 16 May 2009 17:38:54 -0400 Subject: [PATCH] FF4 - Skeleton code for 2.0 - Created new objects for the 2.0.0 code base, needed in 1.8.0. - Sketched out basic interfaces. --- src/rewrite/.gitignore | 1 + src/rewrite/Att.cpp | 100 ++++++++++++++++++++++++++++++++++++++- src/rewrite/Att.h | 44 ++++++++++------- src/rewrite/Context.cpp | 31 +++++++++--- src/rewrite/Date.cpp | 15 +++++- src/rewrite/Date.h | 13 +++-- src/rewrite/Duration.cpp | 12 ++++- src/rewrite/Duration.h | 11 +++-- src/rewrite/Filter.cpp | 19 +++++++- src/rewrite/Filter.h | 16 ++++--- src/rewrite/Keymap.cpp | 8 ++++ src/rewrite/Keymap.h | 13 ++++- src/rewrite/Record.cpp | 6 ++- src/rewrite/Record.h | 8 +++- src/rewrite/Sequence.cpp | 12 ++++- src/rewrite/Sequence.h | 10 +++- src/rewrite/T.cpp | 28 +++++++++++ src/rewrite/T.h | 12 ++--- src/rewrite/TDB.cpp | 42 +++++++++++++++- src/rewrite/TDB.h | 28 +++++------ src/rewrite/main.cpp | 7 +++ 21 files changed, 357 insertions(+), 79 deletions(-) create mode 100644 src/rewrite/.gitignore diff --git a/src/rewrite/.gitignore b/src/rewrite/.gitignore new file mode 100644 index 000000000..625934097 --- /dev/null +++ b/src/rewrite/.gitignore @@ -0,0 +1 @@ +1.8 diff --git a/src/rewrite/Att.cpp b/src/rewrite/Att.cpp index f0b6274c7..d10b68ea4 100644 --- a/src/rewrite/Att.cpp +++ b/src/rewrite/Att.cpp @@ -29,21 +29,39 @@ //////////////////////////////////////////////////////////////////////////////// Att::Att () +: mName ("") +, mValue ("") { + mMods.clear (); } +//////////////////////////////////////////////////////////////////////////////// +Att::Att (const std::string& name, const std::string& value) +{ + throw std::string ("unimplemented"); + mName = name; + mValue = value; + + mMods.clear (); +} //////////////////////////////////////////////////////////////////////////////// Att::Att (const Att& other) { -// mOne = other.mOne; + throw std::string ("unimplemented"); + mName = other.mName; + mValue = other.mValue; + mMods = other.mMods; } //////////////////////////////////////////////////////////////////////////////// Att& Att::operator= (const Att& other) { + throw std::string ("unimplemented"); if (this != &other) { -// mOne = other.mOne; + mName = other.mName; + mValue = other.mValue; + mMods = other.mMods; } return *this; @@ -55,4 +73,82 @@ Att::~Att () } //////////////////////////////////////////////////////////////////////////////// +// Parse the following forms: +// name [[.mod] ...] : [value] +void Att::parse (const std::string& input) +{ + throw std::string ("unimplemented"); +} +//////////////////////////////////////////////////////////////////////////////// +std::string Att::composeF4 () const +{ + throw std::string ("unimplemented"); + return ""; +} + +//////////////////////////////////////////////////////////////////////////////// +void Att::addMod (const std::string&) +{ + throw std::string ("unimplemented"); +} + +//////////////////////////////////////////////////////////////////////////////// +std::string Att::name () const +{ + return mName; +} + +//////////////////////////////////////////////////////////////////////////////// +void Att::name (const std::string& name) +{ + mName = name; +} + +//////////////////////////////////////////////////////////////////////////////// +std::string Att::value () const +{ + return mValue; +} + +//////////////////////////////////////////////////////////////////////////////// +void Att::value (const std::string& value) +{ + mValue = value; +} + +//////////////////////////////////////////////////////////////////////////////// +int Att::value_int () const +{ + throw std::string ("unimplemented"); + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +void Att::value_int (int) +{ + throw std::string ("unimplemented"); +} + +//////////////////////////////////////////////////////////////////////////////// +bool Att::filter () const +{ + throw std::string ("unimplemented"); + return false; +} + +//////////////////////////////////////////////////////////////////////////////// +bool Att::required () const +{ + throw std::string ("unimplemented"); + return false; +} + +//////////////////////////////////////////////////////////////////////////////// +bool Att::internal () const +{ + throw std::string ("unimplemented"); + return false; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Att.h b/src/rewrite/Att.h index fa33b5a0a..2dd8ac8c2 100644 --- a/src/rewrite/Att.h +++ b/src/rewrite/Att.h @@ -27,28 +27,40 @@ #ifndef INCLUDED_ATT #define INCLUDED_ATT +#include +#include + class Att { public: - Att (); // Default constructor - Att (const Att&); // Copy constructor - Att& operator= (const Att&); // Assignment operator - ~Att (); // Destructor + Att (); // Default constructor + Att (const std::string&, const std::string&); + Att (const Att&); // Copy constructor + Att& operator= (const Att&); // Assignment operator + ~Att (); // Destructor -/* -Att (name, value) -std::string name () -std::string value () -int value_int () -addMod () -bool isFilter () -bool isRequired () -bool isInternal () -composeF4 () -parse (const std::stirng&) -*/ + void parse (const std::string&); + std::string composeF4 () const; + + void addMod (const std::string&); + + std::string name () const; + void name (const std::string&); + + std::string value () const; + void value (const std::string&); + + int value_int () const; + void value_int (int); + + bool filter () const; + bool required () const; + bool internal () const; private: + std::string mName; + std::string mValue; + std::vector mMods; }; #endif diff --git a/src/rewrite/Context.cpp b/src/rewrite/Context.cpp index ba357bf45..b93afc562 100644 --- a/src/rewrite/Context.cpp +++ b/src/rewrite/Context.cpp @@ -35,15 +35,27 @@ Context::Context () //////////////////////////////////////////////////////////////////////////////// Context::Context (const Context& other) { -// mOne = other.mOne; + throw std::string ("unimplemented"); +// config = other.config; + filter = other.filter; + keymap = other.keymap; + sequence = other.sequence; + task = other.task; + tdb = other.tdb; } //////////////////////////////////////////////////////////////////////////////// Context& Context::operator= (const Context& other) { + throw std::string ("unimplemented"); if (this != &other) { -// mOne = other.mOne; +// config = other.config; + filter = other.filter; + keymap = other.keymap; + sequence = other.sequence; + task = other.task; + tdb = other.tdb; } return *this; @@ -57,15 +69,17 @@ Context::~Context () //////////////////////////////////////////////////////////////////////////////// void Context::initialize () { - // TODO Load config - // TODO Load pending.data - // TODO Load completed.data - // TODO Load deleted.data + throw std::string ("unimplemented"); + // TODO Load config. + // TODO Load pending.data. + // TODO Load completed.data. + // TODO Load deleted.data. } //////////////////////////////////////////////////////////////////////////////// int Context::commandLine (int argc, char** argv) { + throw std::string ("unimplemented"); // TODO Support rc: override. return 0; } @@ -73,6 +87,11 @@ int Context::commandLine (int argc, char** argv) //////////////////////////////////////////////////////////////////////////////// int Context::run () { + throw std::string ("unimplemented"); + // TODO Dispatch to command handlers. + // TODO Auto shadow update. + // TODO Auto gc. + return 0; } diff --git a/src/rewrite/Date.cpp b/src/rewrite/Date.cpp index af9a4b56a..f01d22506 100644 --- a/src/rewrite/Date.cpp +++ b/src/rewrite/Date.cpp @@ -35,15 +35,17 @@ Date::Date () //////////////////////////////////////////////////////////////////////////////// Date::Date (const Date& other) { -// mOne = other.mOne; + throw std::string ("unimplemented"); + mTime = other.mTime; } //////////////////////////////////////////////////////////////////////////////// Date& Date::operator= (const Date& other) { + throw std::string ("unimplemented"); if (this != &other) { -// mOne = other.mOne; + mTime = other.mTime; } return *this; @@ -55,4 +57,13 @@ Date::~Date () } //////////////////////////////////////////////////////////////////////////////// +// TODO Support m/d/y +// TODO Support ISO-??? +// TODO Support time_t +// TODO Relative dates (today, tomorrow, yesterday, +1d, -2w, eow, eom, eoy) +void Date::parse (const std::string& input) +{ + throw std::string ("unimplemented"); +} +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Date.h b/src/rewrite/Date.h index 40b906db1..935367ae0 100644 --- a/src/rewrite/Date.h +++ b/src/rewrite/Date.h @@ -27,19 +27,22 @@ #ifndef INCLUDED_DATE #define INCLUDED_DATE +#include +#include + class Date { public: - Date (); // Default constructor + Date (); // Default constructor Date (const Date&); // Copy constructor + Date (time_t); // Copy constructor Date& operator= (const Date&); // Assignment operator - ~Date (); // Destructor + ~Date (); // Destructor -/* -bool isDate (const std::string&) -*/ + void parse (const std::string&); private: + time_t mTime; }; #endif diff --git a/src/rewrite/Duration.cpp b/src/rewrite/Duration.cpp index f6acb8964..87c797c68 100644 --- a/src/rewrite/Duration.cpp +++ b/src/rewrite/Duration.cpp @@ -29,21 +29,24 @@ //////////////////////////////////////////////////////////////////////////////// Duration::Duration () +: mSeconds (0) { } //////////////////////////////////////////////////////////////////////////////// Duration::Duration (const Duration& other) { -// mOne = other.mOne; + throw std::string ("unimplemented"); + mSeconds = other.mSeconds; } //////////////////////////////////////////////////////////////////////////////// Duration& Duration::operator= (const Duration& other) { + throw std::string ("unimplemented"); if (this != &other) { -// mOne = other.mOne; + mSeconds = other.mSeconds; } return *this; @@ -55,4 +58,9 @@ Duration::~Duration () } //////////////////////////////////////////////////////////////////////////////// +void Duration::parse (const std::string& input) +{ + throw std::string ("unimplemented"); +} +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Duration.h b/src/rewrite/Duration.h index 891a00c4d..dee0ee578 100644 --- a/src/rewrite/Duration.h +++ b/src/rewrite/Duration.h @@ -27,19 +27,20 @@ #ifndef INCLUDED_DURATION #define INCLUDED_DURATION +#include + class Duration { public: - Duration (); // Default constructor + Duration (); // Default constructor Duration (const Duration&); // Copy constructor Duration& operator= (const Duration&); // Assignment operator - ~Duration (); // Destructor + ~Duration (); // Destructor -/* -bool isDuration (const std::string&) -*/ + void parse (const std::string&); private: + int mSeconds; }; #endif diff --git a/src/rewrite/Filter.cpp b/src/rewrite/Filter.cpp index 10ad23768..c6260d880 100644 --- a/src/rewrite/Filter.cpp +++ b/src/rewrite/Filter.cpp @@ -35,15 +35,17 @@ Filter::Filter () //////////////////////////////////////////////////////////////////////////////// Filter::Filter (const Filter& other) { -// mOne = other.mOne; + throw std::string ("unimplemented"); + mAtts = other.mAtts; } //////////////////////////////////////////////////////////////////////////////// Filter& Filter::operator= (const Filter& other) { + throw std::string ("unimplemented"); if (this != &other) { -// mOne = other.mOne; + mAtts = other.mAtts; } return *this; @@ -55,4 +57,17 @@ Filter::~Filter () } //////////////////////////////////////////////////////////////////////////////// +void Filter::add (Att& att) +{ + throw std::string ("unimplemented"); + mAtts.push_back (att); +} +//////////////////////////////////////////////////////////////////////////////// +bool Filter::pass (T&) +{ + throw std::string ("unimplemented"); + return false; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Filter.h b/src/rewrite/Filter.h index 814a1851f..6f368b157 100644 --- a/src/rewrite/Filter.h +++ b/src/rewrite/Filter.h @@ -27,21 +27,23 @@ #ifndef INCLUDED_FILTER #define INCLUDED_FILTER +#include +#include "Att.h" +#include "T.h" + class Filter { public: - Filter (); // Default constructor + Filter (); // Default constructor Filter (const Filter&); // Copy constructor Filter& operator= (const Filter&); // Assignment operator - ~Filter (); // Destructor + ~Filter (); // Destructor -/* -add (Att&) -bool Filter::pass (T&) -Filter::parse () -*/ + void add (Att&); + bool pass (T&); private: + std::vector mAtts; }; #endif diff --git a/src/rewrite/Keymap.cpp b/src/rewrite/Keymap.cpp index de7c0a549..c4101ffda 100644 --- a/src/rewrite/Keymap.cpp +++ b/src/rewrite/Keymap.cpp @@ -25,6 +25,7 @@ // //////////////////////////////////////////////////////////////////////////////// +#include #include "Keymap.h" //////////////////////////////////////////////////////////////////////////////// @@ -35,12 +36,14 @@ Keymap::Keymap () //////////////////////////////////////////////////////////////////////////////// Keymap::Keymap (const Keymap& other) { + throw std::string ("unimplemented"); // mOne = other.mOne; } //////////////////////////////////////////////////////////////////////////////// Keymap& Keymap::operator= (const Keymap& other) { + throw std::string ("unimplemented"); if (this != &other) { // mOne = other.mOne; @@ -55,4 +58,9 @@ Keymap::~Keymap () } //////////////////////////////////////////////////////////////////////////////// +void Keymap::load (const std::string& file) +{ + throw std::string ("unimplemented"); +} +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Keymap.h b/src/rewrite/Keymap.h index 91c27ba8b..6ba8986f9 100644 --- a/src/rewrite/Keymap.h +++ b/src/rewrite/Keymap.h @@ -27,15 +27,24 @@ #ifndef INCLUDED_KEYMAP #define INCLUDED_KEYMAP +#include + class Keymap { public: - Keymap (); // Default constructor + Keymap (); // Default constructor Keymap (const Keymap&); // Copy constructor Keymap& operator= (const Keymap&); // Assignment operator - ~Keymap (); // Destructor + ~Keymap (); // Destructor + + void load (const std::string&); // Load the map file +/* + real (); // Convert soft to real + soft (); // Convert real to soft +*/ private: + // TODO Structure for mapping strings to keys. }; #endif diff --git a/src/rewrite/Record.cpp b/src/rewrite/Record.cpp index c6a97feaf..f3eaad67c 100644 --- a/src/rewrite/Record.cpp +++ b/src/rewrite/Record.cpp @@ -35,15 +35,17 @@ Record::Record () //////////////////////////////////////////////////////////////////////////////// Record::Record (const Record& other) { -// mOne = other.mOne; + throw std::string ("unimplemented"); + mAtts = other.mAtts; } //////////////////////////////////////////////////////////////////////////////// Record& Record::operator= (const Record& other) { + throw std::string ("unimplemented"); if (this != &other) { -// mOne = other.mOne; + mAtts = other.mAtts; } return *this; diff --git a/src/rewrite/Record.h b/src/rewrite/Record.h index d2ea855d7..20c10977d 100644 --- a/src/rewrite/Record.h +++ b/src/rewrite/Record.h @@ -27,15 +27,19 @@ #ifndef INCLUDED_RECORD #define INCLUDED_RECORD +#include +#include "Att.h" + class Record { public: - Record (); // Default constructor + Record (); // Default constructor Record (const Record&); // Copy constructor Record& operator= (const Record&); // Assignment operator - ~Record (); // Destructor + ~Record (); // Destructor private: + std::vector mAtts; }; #endif diff --git a/src/rewrite/Sequence.cpp b/src/rewrite/Sequence.cpp index 0a626e157..75b68bcd3 100644 --- a/src/rewrite/Sequence.cpp +++ b/src/rewrite/Sequence.cpp @@ -25,6 +25,7 @@ // //////////////////////////////////////////////////////////////////////////////// +#include #include "Sequence.h" //////////////////////////////////////////////////////////////////////////////// @@ -35,15 +36,17 @@ Sequence::Sequence () //////////////////////////////////////////////////////////////////////////////// Sequence::Sequence (const Sequence& other) { -// mOne = other.mOne; + throw std::string ("unimplemented"); + mSequence = other.mSequence; } //////////////////////////////////////////////////////////////////////////////// Sequence& Sequence::operator= (const Sequence& other) { + throw std::string ("unimplemented"); if (this != &other) { -// mOne = other.mOne; + mSequence = other.mSequence; } return *this; @@ -55,4 +58,9 @@ Sequence::~Sequence () } //////////////////////////////////////////////////////////////////////////////// +void Sequence::parse (const std::string& input) +{ + throw std::string ("unimplemented"); +} +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Sequence.h b/src/rewrite/Sequence.h index f70912b39..57857785b 100644 --- a/src/rewrite/Sequence.h +++ b/src/rewrite/Sequence.h @@ -27,15 +27,21 @@ #ifndef INCLUDED_SEQUENCE #define INCLUDED_SEQUENCE +#include +#include + class Sequence { public: - Sequence (); // Default constructor + Sequence (); // Default constructor Sequence (const Sequence&); // Copy constructor Sequence& operator= (const Sequence&); // Assignment operator - ~Sequence (); // Destructor + ~Sequence (); // Destructor + + void parse (const std::string&); private: + std::vector mSequence; }; #endif diff --git a/src/rewrite/T.cpp b/src/rewrite/T.cpp index 9fe6bee95..9a76e9cc2 100644 --- a/src/rewrite/T.cpp +++ b/src/rewrite/T.cpp @@ -25,6 +25,7 @@ // //////////////////////////////////////////////////////////////////////////////// +#include #include "T.h" //////////////////////////////////////////////////////////////////////////////// @@ -35,12 +36,20 @@ T::T () //////////////////////////////////////////////////////////////////////////////// T::T (const T& other) { + throw std::string ("unimplemented"); // mOne = other.mOne; } +//////////////////////////////////////////////////////////////////////////////// +T::T (const std::string& input) +{ + throw std::string ("unimplemented"); +} + //////////////////////////////////////////////////////////////////////////////// T& T::operator= (const T& other) { + throw std::string ("unimplemented"); if (this != &other) { // mOne = other.mOne; @@ -55,4 +64,23 @@ T::~T () } //////////////////////////////////////////////////////////////////////////////// +std::string T::composeF4 () +{ + throw std::string ("unimplemented"); + return ""; +} +//////////////////////////////////////////////////////////////////////////////// +std::string T::composeCSV () +{ + throw std::string ("unimplemented"); + return ""; +} + +//////////////////////////////////////////////////////////////////////////////// +void T::parse (const std::string& input) +{ + throw std::string ("unimplemented"); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/T.h b/src/rewrite/T.h index 1ee4b8055..1453c7347 100644 --- a/src/rewrite/T.h +++ b/src/rewrite/T.h @@ -27,20 +27,20 @@ #ifndef INCLUDED_T #define INCLUDED_T +#include + class T { public: T (); // Default constructor T (const T&); // Copy constructor + T (const std::string&); // Parse T& operator= (const T&); // Assignment operator ~T (); // Destructor -/* -T (const std::string&); -composeF4 -composeCSV -parse -*/ + std::string composeF4 (); + std::string composeCSV (); + void parse (const std::string&); private: }; diff --git a/src/rewrite/TDB.cpp b/src/rewrite/TDB.cpp index ec988693a..a8283d2bf 100644 --- a/src/rewrite/TDB.cpp +++ b/src/rewrite/TDB.cpp @@ -25,6 +25,7 @@ // //////////////////////////////////////////////////////////////////////////////// +#include #include "TDB.h" //////////////////////////////////////////////////////////////////////////////// @@ -35,15 +36,17 @@ TDB::TDB () //////////////////////////////////////////////////////////////////////////////// TDB::TDB (const TDB& other) { -// mOne = other.mOne; + throw std::string ("unimplemented"); + mLocations = other.mLocations; } //////////////////////////////////////////////////////////////////////////////// TDB& TDB::operator= (const TDB& other) { + throw std::string ("unimplemented"); if (this != &other) { -// mOne = other.mOne; + mLocations = other.mLocations; } return *this; @@ -55,4 +58,39 @@ TDB::~TDB () } //////////////////////////////////////////////////////////////////////////////// +void TDB::location (const std::string& path) +{ + throw std::string ("unimplemented"); + mLocations.push_back (path); +} +//////////////////////////////////////////////////////////////////////////////// +// TODO Returns number of filtered tasks. +int TDB::load (std::vector & tasks, Filter& filter) +{ + throw std::string ("unimplemented"); + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +// TODO Write to transaction log. +void TDB::update (T& before, T& after) +{ + throw std::string ("unimplemented"); +} + +//////////////////////////////////////////////////////////////////////////////// +// TODO writes all, including comments +int TDB::commit () +{ + throw std::string ("unimplemented"); +} + +//////////////////////////////////////////////////////////////////////////////// +// TODO -> FF4 +void TDB::upgrade () +{ + throw std::string ("unimplemented"); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/TDB.h b/src/rewrite/TDB.h index 2fa604c2b..468fefb47 100644 --- a/src/rewrite/TDB.h +++ b/src/rewrite/TDB.h @@ -27,28 +27,28 @@ #ifndef INCLUDED_TDB #define INCLUDED_TDB +#include +#include +#include "Filter.h" +#include "T.h" + class TDB { public: - TDB (); // Default constructor + TDB (); // Default constructor TDB (const TDB&); // Copy constructor TDB& operator= (const TDB&); // Assignment operator - ~TDB (); // Destructor + ~TDB (); // Destructor -/* -location (path to task dir) -std::vector load (filter) - caches all raw, including comments - -update (T& old, T& new) -commit () - writes all, including comments - -autoupgrade () - -> FF4 -*/ + void location (const std::string&); + int load (std::vector &, Filter&); + void update (T&, T&); + int commit (); + void upgrade (); private: + std::vector mLocations; + // TODO Need cache of raw file contents. }; #endif diff --git a/src/rewrite/main.cpp b/src/rewrite/main.cpp index 493d11931..b145dae1d 100644 --- a/src/rewrite/main.cpp +++ b/src/rewrite/main.cpp @@ -1,4 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// +#include +#include #include "Context.h" int main (int argc, char** argv) @@ -13,6 +15,11 @@ int main (int argc, char** argv) return 0; } + catch (std::string e) + { + std::cerr << e << std::endl; + } + catch (...) { }