From e754fa6eacfc85346944607f80d1dca54499ef1a Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 19 May 2009 01:38:05 -0400 Subject: [PATCH] FF4 - Snapshot - Sketched out Filter - Implemented part of TDB --- src/rewrite/Att.cpp | 14 ++++++++++++-- src/rewrite/Context.cpp | 4 ++-- src/rewrite/Filter.cpp | 11 ++++++++--- src/rewrite/Filter.h | 4 ++-- src/rewrite/Sequence.cpp | 2 -- src/rewrite/Sequence.h | 5 +---- src/rewrite/T.cpp | 1 + src/rewrite/TDB.cpp | 7 +++++++ src/rewrite/main.cpp | 1 + 9 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/rewrite/Att.cpp b/src/rewrite/Att.cpp index 1082d77ad..43f51bdd7 100644 --- a/src/rewrite/Att.cpp +++ b/src/rewrite/Att.cpp @@ -152,14 +152,24 @@ bool Att::internal () const } //////////////////////////////////////////////////////////////////////////////// -// TODO Encode values prior to serialization. +// Encode values prior to serialization. +// \t -> &tab; +// " -> " +// , -> , +// [ -> &open; +// ] -> &close; void Att::encode (std::string&) const { throw std::string ("unimplemented Att::internal"); } //////////////////////////////////////////////////////////////////////////////// -// TODO Decode values after parse. +// Decode values after parse. +// \t <- &tab; +// " <- " +// , <- , +// [ <- &open; +// ] <- &close; void Att::decode (std::string&) const { throw std::string ("unimplemented Att::internal"); diff --git a/src/rewrite/Context.cpp b/src/rewrite/Context.cpp index 35c64a68c..20233e4eb 100644 --- a/src/rewrite/Context.cpp +++ b/src/rewrite/Context.cpp @@ -80,8 +80,8 @@ Context::~Context () //////////////////////////////////////////////////////////////////////////////// void Context::initialize (int argc, char** argv) { - // Load the config file from the home directory. If the file cannot be - // found, offer to create a sample one. + // Load the configuration file from the home directory. If the file cannot + // be found, offer to create a sample one. loadCorrectConfigFile (argc, argv); // When redirecting output to a file, do not use color, curses. diff --git a/src/rewrite/Filter.cpp b/src/rewrite/Filter.cpp index ba5e2b521..69751fb32 100644 --- a/src/rewrite/Filter.cpp +++ b/src/rewrite/Filter.cpp @@ -59,15 +59,20 @@ Filter::~Filter () //////////////////////////////////////////////////////////////////////////////// void Filter::add (Att& att) { - throw std::string ("unimplemented Filter::add"); mAtts.push_back (att); } //////////////////////////////////////////////////////////////////////////////// -bool Filter::pass (T&) +bool Filter::pass (Record& record) { throw std::string ("unimplemented Filter::pass"); - return false; +/* + foreach (att, mAtts) + if (! att->match (record)) + return false; +*/ + + return true; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Filter.h b/src/rewrite/Filter.h index 6f368b157..879956fe3 100644 --- a/src/rewrite/Filter.h +++ b/src/rewrite/Filter.h @@ -29,7 +29,7 @@ #include #include "Att.h" -#include "T.h" +#include "Record.h" class Filter { @@ -40,7 +40,7 @@ public: ~Filter (); // Destructor void add (Att&); - bool pass (T&); + bool pass (Record&); private: std::vector mAtts; diff --git a/src/rewrite/Sequence.cpp b/src/rewrite/Sequence.cpp index 709a23a46..4c6bcf7f7 100644 --- a/src/rewrite/Sequence.cpp +++ b/src/rewrite/Sequence.cpp @@ -37,7 +37,6 @@ Sequence::Sequence () Sequence::Sequence (const Sequence& other) { throw std::string ("unimplemented Sequence::Sequence"); - mSequence = other.mSequence; } //////////////////////////////////////////////////////////////////////////////// @@ -46,7 +45,6 @@ Sequence& Sequence::operator= (const Sequence& other) throw std::string ("unimplemented Sequence::operator="); if (this != &other) { - mSequence = other.mSequence; } return *this; diff --git a/src/rewrite/Sequence.h b/src/rewrite/Sequence.h index 57857785b..eb2abbee6 100644 --- a/src/rewrite/Sequence.h +++ b/src/rewrite/Sequence.h @@ -30,7 +30,7 @@ #include #include -class Sequence +class Sequence : public std::vector { public: Sequence (); // Default constructor @@ -39,9 +39,6 @@ public: ~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 af5f9c234..933bf218f 100644 --- a/src/rewrite/T.cpp +++ b/src/rewrite/T.cpp @@ -66,6 +66,7 @@ T::~T () } //////////////////////////////////////////////////////////////////////////////// +// [name:value, name:"value",name:[name:value,name:value]] std::string T::composeF4 () { throw std::string ("unimplemented T::composeF4"); diff --git a/src/rewrite/TDB.cpp b/src/rewrite/TDB.cpp index 6a4ccb018..c53e9e9af 100644 --- a/src/rewrite/TDB.cpp +++ b/src/rewrite/TDB.cpp @@ -148,6 +148,10 @@ void TDB::unlock () int TDB::load (std::vector & tasks, Filter& filter) { throw std::string ("unimplemented TDB::load"); + + // TODO Read each row. + // TODO Let T::parse disassemble it. + // TODO If task passes filter, add to tasks. return 0; } @@ -156,6 +160,9 @@ int TDB::load (std::vector & tasks, Filter& filter) void TDB::add (T& after) { throw std::string ("unimplemented TDB::add"); + + // TODO Seek to end of pending. + // TODO write after.composeFF4 (). } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/main.cpp b/src/rewrite/main.cpp index 3b1cc6c5b..a4571e89e 100644 --- a/src/rewrite/main.cpp +++ b/src/rewrite/main.cpp @@ -21,6 +21,7 @@ int main (int argc, char** argv) catch (...) { + std::cerr << "task internal error." << std::endl; } return -1;