From 833fac3c133eb8bde4941037794fcc1024d24c2b Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 16 May 2009 15:45:31 -0400 Subject: [PATCH 01/18] FF4 - Skeleton objects Created skeleton objects for all new 1.8.0 code. --- src/rewrite/Att.cpp | 58 +++++++++++++++++++++++++++++ src/rewrite/Att.h | 55 +++++++++++++++++++++++++++ src/rewrite/Context.cpp | 80 ++++++++++++++++++++++++++++++++++++++++ src/rewrite/Context.h | 62 +++++++++++++++++++++++++++++++ src/rewrite/Date.cpp | 58 +++++++++++++++++++++++++++++ src/rewrite/Date.h | 46 +++++++++++++++++++++++ src/rewrite/Duration.cpp | 58 +++++++++++++++++++++++++++++ src/rewrite/Duration.h | 46 +++++++++++++++++++++++ src/rewrite/Filter.cpp | 58 +++++++++++++++++++++++++++++ src/rewrite/Filter.h | 48 ++++++++++++++++++++++++ src/rewrite/Keymap.cpp | 58 +++++++++++++++++++++++++++++ src/rewrite/Keymap.h | 42 +++++++++++++++++++++ src/rewrite/Makefile | 23 ++++++++++++ src/rewrite/Record.cpp | 58 +++++++++++++++++++++++++++++ src/rewrite/Record.h | 42 +++++++++++++++++++++ src/rewrite/Sequence.cpp | 58 +++++++++++++++++++++++++++++ src/rewrite/Sequence.h | 42 +++++++++++++++++++++ src/rewrite/T.cpp | 58 +++++++++++++++++++++++++++++ src/rewrite/T.h | 49 ++++++++++++++++++++++++ src/rewrite/TDB.cpp | 58 +++++++++++++++++++++++++++++ src/rewrite/TDB.h | 55 +++++++++++++++++++++++++++ src/rewrite/X.cpp | 58 +++++++++++++++++++++++++++++ src/rewrite/X.h | 42 +++++++++++++++++++++ src/rewrite/main.cpp | 23 ++++++++++++ 24 files changed, 1235 insertions(+) create mode 100644 src/rewrite/Att.cpp create mode 100644 src/rewrite/Att.h create mode 100644 src/rewrite/Context.cpp create mode 100644 src/rewrite/Context.h create mode 100644 src/rewrite/Date.cpp create mode 100644 src/rewrite/Date.h create mode 100644 src/rewrite/Duration.cpp create mode 100644 src/rewrite/Duration.h create mode 100644 src/rewrite/Filter.cpp create mode 100644 src/rewrite/Filter.h create mode 100644 src/rewrite/Keymap.cpp create mode 100644 src/rewrite/Keymap.h create mode 100644 src/rewrite/Makefile create mode 100644 src/rewrite/Record.cpp create mode 100644 src/rewrite/Record.h create mode 100644 src/rewrite/Sequence.cpp create mode 100644 src/rewrite/Sequence.h create mode 100644 src/rewrite/T.cpp create mode 100644 src/rewrite/T.h create mode 100644 src/rewrite/TDB.cpp create mode 100644 src/rewrite/TDB.h create mode 100644 src/rewrite/X.cpp create mode 100644 src/rewrite/X.h create mode 100644 src/rewrite/main.cpp diff --git a/src/rewrite/Att.cpp b/src/rewrite/Att.cpp new file mode 100644 index 000000000..f0b6274c7 --- /dev/null +++ b/src/rewrite/Att.cpp @@ -0,0 +1,58 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// + +#include "Att.h" + +//////////////////////////////////////////////////////////////////////////////// +Att::Att () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +Att::Att (const Att& other) +{ +// mOne = other.mOne; +} + +//////////////////////////////////////////////////////////////////////////////// +Att& Att::operator= (const Att& other) +{ + if (this != &other) + { +// mOne = other.mOne; + } + + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +Att::~Att () +{ +} + +//////////////////////////////////////////////////////////////////////////////// + diff --git a/src/rewrite/Att.h b/src/rewrite/Att.h new file mode 100644 index 000000000..fa33b5a0a --- /dev/null +++ b/src/rewrite/Att.h @@ -0,0 +1,55 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_ATT +#define INCLUDED_ATT + +class Att +{ +public: + Att (); // Default constructor + 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&) +*/ + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Context.cpp b/src/rewrite/Context.cpp new file mode 100644 index 000000000..ba357bf45 --- /dev/null +++ b/src/rewrite/Context.cpp @@ -0,0 +1,80 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// + +#include "Context.h" + +//////////////////////////////////////////////////////////////////////////////// +Context::Context () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +Context::Context (const Context& other) +{ +// mOne = other.mOne; +} + +//////////////////////////////////////////////////////////////////////////////// +Context& Context::operator= (const Context& other) +{ + if (this != &other) + { +// mOne = other.mOne; + } + + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +Context::~Context () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +void Context::initialize () +{ + // TODO Load config + // TODO Load pending.data + // TODO Load completed.data + // TODO Load deleted.data +} + +//////////////////////////////////////////////////////////////////////////////// +int Context::commandLine (int argc, char** argv) +{ + // TODO Support rc: override. + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// +int Context::run () +{ + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// + diff --git a/src/rewrite/Context.h b/src/rewrite/Context.h new file mode 100644 index 000000000..1be1b185f --- /dev/null +++ b/src/rewrite/Context.h @@ -0,0 +1,62 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_CONTEXT +#define INCLUDED_CONTEXT + +#include "Filter.h" +#include "Keymap.h" +//#include "Config.h" +#include "Sequence.h" +#include "TDB.h" +#include "T.h" + + +class Context +{ +public: + Context (); // Default constructor + Context (const Context&); // Copy constructor + Context& operator= (const Context&); // Assignment operator + ~Context (); // Destructor + + void initialize (); + int commandLine (int, char**); + int run (); + +public: +// Config config; + Filter filter; + Keymap keymap; + Sequence sequence; + T task; + TDB tdb; + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Date.cpp b/src/rewrite/Date.cpp new file mode 100644 index 000000000..af9a4b56a --- /dev/null +++ b/src/rewrite/Date.cpp @@ -0,0 +1,58 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// + +#include "Date.h" + +//////////////////////////////////////////////////////////////////////////////// +Date::Date () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +Date::Date (const Date& other) +{ +// mOne = other.mOne; +} + +//////////////////////////////////////////////////////////////////////////////// +Date& Date::operator= (const Date& other) +{ + if (this != &other) + { +// mOne = other.mOne; + } + + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +Date::~Date () +{ +} + +//////////////////////////////////////////////////////////////////////////////// + diff --git a/src/rewrite/Date.h b/src/rewrite/Date.h new file mode 100644 index 000000000..40b906db1 --- /dev/null +++ b/src/rewrite/Date.h @@ -0,0 +1,46 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_DATE +#define INCLUDED_DATE + +class Date +{ +public: + Date (); // Default constructor + Date (const Date&); // Copy constructor + Date& operator= (const Date&); // Assignment operator + ~Date (); // Destructor + +/* +bool isDate (const std::string&) +*/ + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Duration.cpp b/src/rewrite/Duration.cpp new file mode 100644 index 000000000..f6acb8964 --- /dev/null +++ b/src/rewrite/Duration.cpp @@ -0,0 +1,58 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// + +#include "Duration.h" + +//////////////////////////////////////////////////////////////////////////////// +Duration::Duration () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +Duration::Duration (const Duration& other) +{ +// mOne = other.mOne; +} + +//////////////////////////////////////////////////////////////////////////////// +Duration& Duration::operator= (const Duration& other) +{ + if (this != &other) + { +// mOne = other.mOne; + } + + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +Duration::~Duration () +{ +} + +//////////////////////////////////////////////////////////////////////////////// + diff --git a/src/rewrite/Duration.h b/src/rewrite/Duration.h new file mode 100644 index 000000000..891a00c4d --- /dev/null +++ b/src/rewrite/Duration.h @@ -0,0 +1,46 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_DURATION +#define INCLUDED_DURATION + +class Duration +{ +public: + Duration (); // Default constructor + Duration (const Duration&); // Copy constructor + Duration& operator= (const Duration&); // Assignment operator + ~Duration (); // Destructor + +/* +bool isDuration (const std::string&) +*/ + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Filter.cpp b/src/rewrite/Filter.cpp new file mode 100644 index 000000000..10ad23768 --- /dev/null +++ b/src/rewrite/Filter.cpp @@ -0,0 +1,58 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// + +#include "Filter.h" + +//////////////////////////////////////////////////////////////////////////////// +Filter::Filter () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +Filter::Filter (const Filter& other) +{ +// mOne = other.mOne; +} + +//////////////////////////////////////////////////////////////////////////////// +Filter& Filter::operator= (const Filter& other) +{ + if (this != &other) + { +// mOne = other.mOne; + } + + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +Filter::~Filter () +{ +} + +//////////////////////////////////////////////////////////////////////////////// + diff --git a/src/rewrite/Filter.h b/src/rewrite/Filter.h new file mode 100644 index 000000000..814a1851f --- /dev/null +++ b/src/rewrite/Filter.h @@ -0,0 +1,48 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_FILTER +#define INCLUDED_FILTER + +class Filter +{ +public: + Filter (); // Default constructor + Filter (const Filter&); // Copy constructor + Filter& operator= (const Filter&); // Assignment operator + ~Filter (); // Destructor + +/* +add (Att&) +bool Filter::pass (T&) +Filter::parse () +*/ + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Keymap.cpp b/src/rewrite/Keymap.cpp new file mode 100644 index 000000000..de7c0a549 --- /dev/null +++ b/src/rewrite/Keymap.cpp @@ -0,0 +1,58 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// + +#include "Keymap.h" + +//////////////////////////////////////////////////////////////////////////////// +Keymap::Keymap () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +Keymap::Keymap (const Keymap& other) +{ +// mOne = other.mOne; +} + +//////////////////////////////////////////////////////////////////////////////// +Keymap& Keymap::operator= (const Keymap& other) +{ + if (this != &other) + { +// mOne = other.mOne; + } + + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +Keymap::~Keymap () +{ +} + +//////////////////////////////////////////////////////////////////////////////// + diff --git a/src/rewrite/Keymap.h b/src/rewrite/Keymap.h new file mode 100644 index 000000000..91c27ba8b --- /dev/null +++ b/src/rewrite/Keymap.h @@ -0,0 +1,42 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_KEYMAP +#define INCLUDED_KEYMAP + +class Keymap +{ +public: + Keymap (); // Default constructor + Keymap (const Keymap&); // Copy constructor + Keymap& operator= (const Keymap&); // Assignment operator + ~Keymap (); // Destructor + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Makefile b/src/rewrite/Makefile new file mode 100644 index 000000000..7115320db --- /dev/null +++ b/src/rewrite/Makefile @@ -0,0 +1,23 @@ +PROJECT = 1.8 +CFLAGS = -I. -I../../library/include -Wall -pedantic -ggdb3 -fno-rtti -fstack-check +LFLAGS = +LIBS = +OBJECTS = main.o Context.o TDB.o T.o Sequence.o Filter.o Att.o Date.o Duration.o Keymap.o + +all: $(PROJECT) + +install: $(PROJECT) + @echo unimplemented + +test: $(PROJECT) + @echo unimplemented + +clean: + -rm *.o $(PROJECT) + +.cpp.o: $(INCLUDE) + g++ -c $(CFLAGS) $< + +$(PROJECT): $(OBJECTS) + g++ $(OBJECTS) $(LFLAGS) $(LIBS) -o $(PROJECT) + diff --git a/src/rewrite/Record.cpp b/src/rewrite/Record.cpp new file mode 100644 index 000000000..c6a97feaf --- /dev/null +++ b/src/rewrite/Record.cpp @@ -0,0 +1,58 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// + +#include "Record.h" + +//////////////////////////////////////////////////////////////////////////////// +Record::Record () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +Record::Record (const Record& other) +{ +// mOne = other.mOne; +} + +//////////////////////////////////////////////////////////////////////////////// +Record& Record::operator= (const Record& other) +{ + if (this != &other) + { +// mOne = other.mOne; + } + + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +Record::~Record () +{ +} + +//////////////////////////////////////////////////////////////////////////////// + diff --git a/src/rewrite/Record.h b/src/rewrite/Record.h new file mode 100644 index 000000000..d2ea855d7 --- /dev/null +++ b/src/rewrite/Record.h @@ -0,0 +1,42 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_RECORD +#define INCLUDED_RECORD + +class Record +{ +public: + Record (); // Default constructor + Record (const Record&); // Copy constructor + Record& operator= (const Record&); // Assignment operator + ~Record (); // Destructor + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Sequence.cpp b/src/rewrite/Sequence.cpp new file mode 100644 index 000000000..0a626e157 --- /dev/null +++ b/src/rewrite/Sequence.cpp @@ -0,0 +1,58 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// + +#include "Sequence.h" + +//////////////////////////////////////////////////////////////////////////////// +Sequence::Sequence () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +Sequence::Sequence (const Sequence& other) +{ +// mOne = other.mOne; +} + +//////////////////////////////////////////////////////////////////////////////// +Sequence& Sequence::operator= (const Sequence& other) +{ + if (this != &other) + { +// mOne = other.mOne; + } + + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +Sequence::~Sequence () +{ +} + +//////////////////////////////////////////////////////////////////////////////// + diff --git a/src/rewrite/Sequence.h b/src/rewrite/Sequence.h new file mode 100644 index 000000000..f70912b39 --- /dev/null +++ b/src/rewrite/Sequence.h @@ -0,0 +1,42 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_SEQUENCE +#define INCLUDED_SEQUENCE + +class Sequence +{ +public: + Sequence (); // Default constructor + Sequence (const Sequence&); // Copy constructor + Sequence& operator= (const Sequence&); // Assignment operator + ~Sequence (); // Destructor + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/T.cpp b/src/rewrite/T.cpp new file mode 100644 index 000000000..9fe6bee95 --- /dev/null +++ b/src/rewrite/T.cpp @@ -0,0 +1,58 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// + +#include "T.h" + +//////////////////////////////////////////////////////////////////////////////// +T::T () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +T::T (const T& other) +{ +// mOne = other.mOne; +} + +//////////////////////////////////////////////////////////////////////////////// +T& T::operator= (const T& other) +{ + if (this != &other) + { +// mOne = other.mOne; + } + + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +T::~T () +{ +} + +//////////////////////////////////////////////////////////////////////////////// + diff --git a/src/rewrite/T.h b/src/rewrite/T.h new file mode 100644 index 000000000..1ee4b8055 --- /dev/null +++ b/src/rewrite/T.h @@ -0,0 +1,49 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_T +#define INCLUDED_T + +class T +{ +public: + T (); // Default constructor + T (const T&); // Copy constructor + T& operator= (const T&); // Assignment operator + ~T (); // Destructor + +/* +T (const std::string&); +composeF4 +composeCSV +parse +*/ + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/TDB.cpp b/src/rewrite/TDB.cpp new file mode 100644 index 000000000..ec988693a --- /dev/null +++ b/src/rewrite/TDB.cpp @@ -0,0 +1,58 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// + +#include "TDB.h" + +//////////////////////////////////////////////////////////////////////////////// +TDB::TDB () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +TDB::TDB (const TDB& other) +{ +// mOne = other.mOne; +} + +//////////////////////////////////////////////////////////////////////////////// +TDB& TDB::operator= (const TDB& other) +{ + if (this != &other) + { +// mOne = other.mOne; + } + + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +TDB::~TDB () +{ +} + +//////////////////////////////////////////////////////////////////////////////// + diff --git a/src/rewrite/TDB.h b/src/rewrite/TDB.h new file mode 100644 index 000000000..2fa604c2b --- /dev/null +++ b/src/rewrite/TDB.h @@ -0,0 +1,55 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_TDB +#define INCLUDED_TDB + +class TDB +{ +public: + TDB (); // Default constructor + TDB (const TDB&); // Copy constructor + TDB& operator= (const TDB&); // Assignment operator + ~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 +*/ + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/X.cpp b/src/rewrite/X.cpp new file mode 100644 index 000000000..24688b1ef --- /dev/null +++ b/src/rewrite/X.cpp @@ -0,0 +1,58 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// + +#include "X.h" + +//////////////////////////////////////////////////////////////////////////////// +X::X () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +X::X (const X& other) +{ +// mOne = other.mOne; +} + +//////////////////////////////////////////////////////////////////////////////// +X& X::operator= (const X& other) +{ + if (this != &other) + { +// mOne = other.mOne; + } + + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +X::~X () +{ +} + +//////////////////////////////////////////////////////////////////////////////// + diff --git a/src/rewrite/X.h b/src/rewrite/X.h new file mode 100644 index 000000000..95b9c6d0e --- /dev/null +++ b/src/rewrite/X.h @@ -0,0 +1,42 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_X +#define INCLUDED_X + +class X +{ +public: + X (); // Default constructor + X (const X&); // Copy constructor + X& operator= (const X&); // Assignment operator + ~X (); // Destructor + +private: +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/main.cpp b/src/rewrite/main.cpp new file mode 100644 index 000000000..493d11931 --- /dev/null +++ b/src/rewrite/main.cpp @@ -0,0 +1,23 @@ +//////////////////////////////////////////////////////////////////////////////// +#include "Context.h" + +int main (int argc, char** argv) +{ + try + { + Context c; + c.initialize (); + c.commandLine (argc, argv); + c.run (); + + return 0; + } + + catch (...) + { + } + + return -1; +} + +//////////////////////////////////////////////////////////////////////////////// From 69ed1e0ebbb40aa139e1371e5e5bfaa3317f2d7a Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 16 May 2009 17:38:54 -0400 Subject: [PATCH 02/18] 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 (...) { } From 7a03d819a0cb6592c7fb6100ade570a1cdc6a531 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 16 May 2009 17:50:30 -0400 Subject: [PATCH 03/18] FF4 - Snapshot - Objects ready for implementation. - Removed template X.h X.cpp. --- src/rewrite/Att.cpp | 22 +++++++-------- src/rewrite/Context.cpp | 10 +++---- src/rewrite/Date.cpp | 6 ++--- src/rewrite/Duration.cpp | 6 ++--- src/rewrite/Filter.cpp | 8 +++--- src/rewrite/Keymap.cpp | 6 ++--- src/rewrite/Record.cpp | 4 +-- src/rewrite/Sequence.cpp | 6 ++--- src/rewrite/T.cpp | 12 ++++----- src/rewrite/TDB.cpp | 14 +++++----- src/rewrite/X.cpp | 58 ---------------------------------------- src/rewrite/X.h | 42 ----------------------------- 12 files changed, 47 insertions(+), 147 deletions(-) delete mode 100644 src/rewrite/X.cpp delete mode 100644 src/rewrite/X.h diff --git a/src/rewrite/Att.cpp b/src/rewrite/Att.cpp index d10b68ea4..8bd34fb1f 100644 --- a/src/rewrite/Att.cpp +++ b/src/rewrite/Att.cpp @@ -38,7 +38,7 @@ Att::Att () //////////////////////////////////////////////////////////////////////////////// Att::Att (const std::string& name, const std::string& value) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Att::Att"); mName = name; mValue = value; @@ -47,7 +47,7 @@ Att::Att (const std::string& name, const std::string& value) //////////////////////////////////////////////////////////////////////////////// Att::Att (const Att& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Att::Att"); mName = other.mName; mValue = other.mValue; mMods = other.mMods; @@ -56,7 +56,7 @@ Att::Att (const Att& other) //////////////////////////////////////////////////////////////////////////////// Att& Att::operator= (const Att& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Att::operator="); if (this != &other) { mName = other.mName; @@ -77,20 +77,20 @@ Att::~Att () // name [[.mod] ...] : [value] void Att::parse (const std::string& input) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Att::parse"); } //////////////////////////////////////////////////////////////////////////////// std::string Att::composeF4 () const { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Att::composeF4"); return ""; } //////////////////////////////////////////////////////////////////////////////// void Att::addMod (const std::string&) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Att::addMod"); } //////////////////////////////////////////////////////////////////////////////// @@ -120,34 +120,34 @@ void Att::value (const std::string& value) //////////////////////////////////////////////////////////////////////////////// int Att::value_int () const { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Att::value_int"); return 0; } //////////////////////////////////////////////////////////////////////////////// void Att::value_int (int) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Att::value_int"); } //////////////////////////////////////////////////////////////////////////////// bool Att::filter () const { - throw std::string ("unimplemented"); + throw std::string ("unimplemented filter"); return false; } //////////////////////////////////////////////////////////////////////////////// bool Att::required () const { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Att::required"); return false; } //////////////////////////////////////////////////////////////////////////////// bool Att::internal () const { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Att::internal"); return false; } diff --git a/src/rewrite/Context.cpp b/src/rewrite/Context.cpp index b93afc562..c68344681 100644 --- a/src/rewrite/Context.cpp +++ b/src/rewrite/Context.cpp @@ -35,7 +35,7 @@ Context::Context () //////////////////////////////////////////////////////////////////////////////// Context::Context (const Context& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Context::Context"); // config = other.config; filter = other.filter; keymap = other.keymap; @@ -47,7 +47,7 @@ Context::Context (const Context& other) //////////////////////////////////////////////////////////////////////////////// Context& Context::operator= (const Context& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Context::operator="); if (this != &other) { // config = other.config; @@ -69,7 +69,7 @@ Context::~Context () //////////////////////////////////////////////////////////////////////////////// void Context::initialize () { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Context::initialize"); // TODO Load config. // TODO Load pending.data. // TODO Load completed.data. @@ -79,7 +79,7 @@ void Context::initialize () //////////////////////////////////////////////////////////////////////////////// int Context::commandLine (int argc, char** argv) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Context::commandLine"); // TODO Support rc: override. return 0; } @@ -87,7 +87,7 @@ int Context::commandLine (int argc, char** argv) //////////////////////////////////////////////////////////////////////////////// int Context::run () { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Context::run"); // TODO Dispatch to command handlers. // TODO Auto shadow update. // TODO Auto gc. diff --git a/src/rewrite/Date.cpp b/src/rewrite/Date.cpp index f01d22506..ad761b2a6 100644 --- a/src/rewrite/Date.cpp +++ b/src/rewrite/Date.cpp @@ -35,14 +35,14 @@ Date::Date () //////////////////////////////////////////////////////////////////////////////// Date::Date (const Date& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Date::Date"); mTime = other.mTime; } //////////////////////////////////////////////////////////////////////////////// Date& Date::operator= (const Date& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Date::operator="); if (this != &other) { mTime = other.mTime; @@ -63,7 +63,7 @@ Date::~Date () // TODO Relative dates (today, tomorrow, yesterday, +1d, -2w, eow, eom, eoy) void Date::parse (const std::string& input) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Date::parse"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Duration.cpp b/src/rewrite/Duration.cpp index 87c797c68..56d0ee4a5 100644 --- a/src/rewrite/Duration.cpp +++ b/src/rewrite/Duration.cpp @@ -36,14 +36,14 @@ Duration::Duration () //////////////////////////////////////////////////////////////////////////////// Duration::Duration (const Duration& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Duration::Duration"); mSeconds = other.mSeconds; } //////////////////////////////////////////////////////////////////////////////// Duration& Duration::operator= (const Duration& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Duration::operator="); if (this != &other) { mSeconds = other.mSeconds; @@ -60,7 +60,7 @@ Duration::~Duration () //////////////////////////////////////////////////////////////////////////////// void Duration::parse (const std::string& input) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Duration::parse"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Filter.cpp b/src/rewrite/Filter.cpp index c6260d880..ba5e2b521 100644 --- a/src/rewrite/Filter.cpp +++ b/src/rewrite/Filter.cpp @@ -35,14 +35,14 @@ Filter::Filter () //////////////////////////////////////////////////////////////////////////////// Filter::Filter (const Filter& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Filter::Filter"); mAtts = other.mAtts; } //////////////////////////////////////////////////////////////////////////////// Filter& Filter::operator= (const Filter& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Filter::operator="); if (this != &other) { mAtts = other.mAtts; @@ -59,14 +59,14 @@ Filter::~Filter () //////////////////////////////////////////////////////////////////////////////// void Filter::add (Att& att) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Filter::add"); mAtts.push_back (att); } //////////////////////////////////////////////////////////////////////////////// bool Filter::pass (T&) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Filter::pass"); return false; } diff --git a/src/rewrite/Keymap.cpp b/src/rewrite/Keymap.cpp index c4101ffda..388300cfd 100644 --- a/src/rewrite/Keymap.cpp +++ b/src/rewrite/Keymap.cpp @@ -36,14 +36,14 @@ Keymap::Keymap () //////////////////////////////////////////////////////////////////////////////// Keymap::Keymap (const Keymap& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Keymap::Keymap"); // mOne = other.mOne; } //////////////////////////////////////////////////////////////////////////////// Keymap& Keymap::operator= (const Keymap& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Keymap::operator="); if (this != &other) { // mOne = other.mOne; @@ -60,7 +60,7 @@ Keymap::~Keymap () //////////////////////////////////////////////////////////////////////////////// void Keymap::load (const std::string& file) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Keymap::load"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Record.cpp b/src/rewrite/Record.cpp index f3eaad67c..f74517d9d 100644 --- a/src/rewrite/Record.cpp +++ b/src/rewrite/Record.cpp @@ -35,14 +35,14 @@ Record::Record () //////////////////////////////////////////////////////////////////////////////// Record::Record (const Record& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Record::Record"); mAtts = other.mAtts; } //////////////////////////////////////////////////////////////////////////////// Record& Record::operator= (const Record& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Record:operator="); if (this != &other) { mAtts = other.mAtts; diff --git a/src/rewrite/Sequence.cpp b/src/rewrite/Sequence.cpp index 75b68bcd3..709a23a46 100644 --- a/src/rewrite/Sequence.cpp +++ b/src/rewrite/Sequence.cpp @@ -36,14 +36,14 @@ Sequence::Sequence () //////////////////////////////////////////////////////////////////////////////// Sequence::Sequence (const Sequence& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Sequence::Sequence"); mSequence = other.mSequence; } //////////////////////////////////////////////////////////////////////////////// Sequence& Sequence::operator= (const Sequence& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Sequence::operator="); if (this != &other) { mSequence = other.mSequence; @@ -60,7 +60,7 @@ Sequence::~Sequence () //////////////////////////////////////////////////////////////////////////////// void Sequence::parse (const std::string& input) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented Sequence::parse"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/T.cpp b/src/rewrite/T.cpp index 9a76e9cc2..f88d4b179 100644 --- a/src/rewrite/T.cpp +++ b/src/rewrite/T.cpp @@ -36,20 +36,20 @@ T::T () //////////////////////////////////////////////////////////////////////////////// T::T (const T& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented T::T"); // mOne = other.mOne; } //////////////////////////////////////////////////////////////////////////////// T::T (const std::string& input) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented T::T"); } //////////////////////////////////////////////////////////////////////////////// T& T::operator= (const T& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented T::operator="); if (this != &other) { // mOne = other.mOne; @@ -66,21 +66,21 @@ T::~T () //////////////////////////////////////////////////////////////////////////////// std::string T::composeF4 () { - throw std::string ("unimplemented"); + throw std::string ("unimplemented T::composeF4"); return ""; } //////////////////////////////////////////////////////////////////////////////// std::string T::composeCSV () { - throw std::string ("unimplemented"); + throw std::string ("unimplemented T::composeCSV"); return ""; } //////////////////////////////////////////////////////////////////////////////// void T::parse (const std::string& input) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented T::parse"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/TDB.cpp b/src/rewrite/TDB.cpp index a8283d2bf..5526a5611 100644 --- a/src/rewrite/TDB.cpp +++ b/src/rewrite/TDB.cpp @@ -36,14 +36,14 @@ TDB::TDB () //////////////////////////////////////////////////////////////////////////////// TDB::TDB (const TDB& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented TDB::TDB"); mLocations = other.mLocations; } //////////////////////////////////////////////////////////////////////////////// TDB& TDB::operator= (const TDB& other) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented TDB::operator="); if (this != &other) { mLocations = other.mLocations; @@ -60,7 +60,7 @@ TDB::~TDB () //////////////////////////////////////////////////////////////////////////////// void TDB::location (const std::string& path) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented TDB::location"); mLocations.push_back (path); } @@ -68,7 +68,7 @@ void TDB::location (const std::string& path) // TODO Returns number of filtered tasks. int TDB::load (std::vector & tasks, Filter& filter) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented TDB::load"); return 0; } @@ -76,21 +76,21 @@ int TDB::load (std::vector & tasks, Filter& filter) // TODO Write to transaction log. void TDB::update (T& before, T& after) { - throw std::string ("unimplemented"); + throw std::string ("unimplemented TDB::update"); } //////////////////////////////////////////////////////////////////////////////// // TODO writes all, including comments int TDB::commit () { - throw std::string ("unimplemented"); + throw std::string ("unimplemented TDB::commit"); } //////////////////////////////////////////////////////////////////////////////// // TODO -> FF4 void TDB::upgrade () { - throw std::string ("unimplemented"); + throw std::string ("unimplemented TDB::upgrade"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/X.cpp b/src/rewrite/X.cpp deleted file mode 100644 index 24688b1ef..000000000 --- a/src/rewrite/X.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// task - a command line task list manager. -// -// Copyright 2006 - 2009, Paul Beckingham. -// All rights reserved. -// -// This program is free software; you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free Software -// Foundation; either version 2 of the License, or (at your option) any later -// version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -// details. -// -// You should have received a copy of the GNU General Public License along with -// this program; if not, write to the -// -// Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, -// Boston, MA -// 02110-1301 -// USA -// -//////////////////////////////////////////////////////////////////////////////// - -#include "X.h" - -//////////////////////////////////////////////////////////////////////////////// -X::X () -{ -} - -//////////////////////////////////////////////////////////////////////////////// -X::X (const X& other) -{ -// mOne = other.mOne; -} - -//////////////////////////////////////////////////////////////////////////////// -X& X::operator= (const X& other) -{ - if (this != &other) - { -// mOne = other.mOne; - } - - return *this; -} - -//////////////////////////////////////////////////////////////////////////////// -X::~X () -{ -} - -//////////////////////////////////////////////////////////////////////////////// - diff --git a/src/rewrite/X.h b/src/rewrite/X.h deleted file mode 100644 index 95b9c6d0e..000000000 --- a/src/rewrite/X.h +++ /dev/null @@ -1,42 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// task - a command line task list manager. -// -// Copyright 2006 - 2009, Paul Beckingham. -// All rights reserved. -// -// This program is free software; you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free Software -// Foundation; either version 2 of the License, or (at your option) any later -// version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -// details. -// -// You should have received a copy of the GNU General Public License along with -// this program; if not, write to the -// -// Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, -// Boston, MA -// 02110-1301 -// USA -// -//////////////////////////////////////////////////////////////////////////////// -#ifndef INCLUDED_X -#define INCLUDED_X - -class X -{ -public: - X (); // Default constructor - X (const X&); // Copy constructor - X& operator= (const X&); // Assignment operator - ~X (); // Destructor - -private: -}; - -#endif -//////////////////////////////////////////////////////////////////////////////// From fa76326aba26a914ce0ff3057370d315b46db794 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 16 May 2009 21:50:04 -0400 Subject: [PATCH 04/18] FF4 - Duration object complete - Replaces util.cpp:convertDuration --- src/rewrite/Duration.cpp | 101 +++++++++++++++++++++++++++++++++++++-- src/rewrite/Duration.h | 9 +++- 2 files changed, 105 insertions(+), 5 deletions(-) diff --git a/src/rewrite/Duration.cpp b/src/rewrite/Duration.cpp index 56d0ee4a5..d0cb4a469 100644 --- a/src/rewrite/Duration.cpp +++ b/src/rewrite/Duration.cpp @@ -25,11 +25,13 @@ // //////////////////////////////////////////////////////////////////////////////// +#include +#include "task.h" #include "Duration.h" //////////////////////////////////////////////////////////////////////////////// Duration::Duration () -: mSeconds (0) +: mDays (0) { } @@ -37,7 +39,13 @@ Duration::Duration () Duration::Duration (const Duration& other) { throw std::string ("unimplemented Duration::Duration"); - mSeconds = other.mSeconds; + mDays = other.mDays; +} + +//////////////////////////////////////////////////////////////////////////////// +Duration::Duration (const std::string& input) +{ + parse (input); } //////////////////////////////////////////////////////////////////////////////// @@ -46,12 +54,36 @@ Duration& Duration::operator= (const Duration& other) throw std::string ("unimplemented Duration::operator="); if (this != &other) { - mSeconds = other.mSeconds; + mDays = other.mDays; } return *this; } +//////////////////////////////////////////////////////////////////////////////// +Duration::operator int () +{ + return (int) mDays; +} + +//////////////////////////////////////////////////////////////////////////////// +Duration::operator time_t () +{ + return mDays; +} + +//////////////////////////////////////////////////////////////////////////////// +bool Duration::operator< (const Duration& other) +{ + return mDays < other.mDays; +} + +//////////////////////////////////////////////////////////////////////////////// +bool Duration::operator> (const Duration& other) +{ + return mDays > other.mDays; +} + //////////////////////////////////////////////////////////////////////////////// Duration::~Duration () { @@ -60,7 +92,68 @@ Duration::~Duration () //////////////////////////////////////////////////////////////////////////////// void Duration::parse (const std::string& input) { - throw std::string ("unimplemented Duration::parse"); + std::string lower_input = lowerCase (input); + + std::vector supported; + supported.push_back ("daily"); + supported.push_back ("day"); + supported.push_back ("weekly"); + supported.push_back ("weekdays"); + supported.push_back ("sennight"); + supported.push_back ("biweekly"); + supported.push_back ("fortnight"); + supported.push_back ("monthly"); + supported.push_back ("bimonthly"); + supported.push_back ("quarterly"); + supported.push_back ("biannual"); + supported.push_back ("biyearly"); + supported.push_back ("annual"); + supported.push_back ("semiannual"); + supported.push_back ("yearly"); + + std::vector matches; + if (autoComplete (lower_input, supported, matches) == 1) + { + std::string found = matches[0]; + + if (found == "daily" || found == "day") mDays = 1; + else if (found == "weekdays") mDays = 1; + else if (found == "weekly" || found == "sennight") mDays = 7; + else if (found == "biweekly" || found == "fortnight") mDays = 14; + else if (found == "monthly") mDays = 30; + else if (found == "bimonthly") mDays = 61; + else if (found == "quarterly") mDays = 91; + else if (found == "semiannual") mDays = 183; + else if (found == "yearly" || found == "annual") mDays = 365; + else if (found == "biannual" || found == "biyearly") mDays = 730; + } + + // Support \d+ d|w|m|q|y + else + { + // Verify all digits followed by d, w, m, q, or y. + unsigned int length = lower_input.length (); + for (unsigned int i = 0; i < length; ++i) + { + if (! isdigit (lower_input[i]) && + i == length - 1) + { + int number = ::atoi (lower_input.substr (0, i).c_str ()); + + switch (lower_input[length - 1]) + { + case 'd': mDays = number * 1; break; + case 'w': mDays = number * 7; break; + case 'm': mDays = number * 30; break; + case 'q': mDays = number * 91; break; + case 'y': mDays = number * 365; break; + } + } + } + } + + if (mDays == 0) + throw std::string ("The duration '") + input + "' was not recognized."; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Duration.h b/src/rewrite/Duration.h index dee0ee578..d5e1361dc 100644 --- a/src/rewrite/Duration.h +++ b/src/rewrite/Duration.h @@ -28,19 +28,26 @@ #define INCLUDED_DURATION #include +#include class Duration { public: Duration (); // Default constructor Duration (const Duration&); // Copy constructor + Duration (const std::string&); // Parse Duration& operator= (const Duration&); // Assignment operator + bool operator< (const Duration&); + bool operator> (const Duration&); ~Duration (); // Destructor + operator int (); + operator time_t (); + void parse (const std::string&); private: - int mSeconds; + time_t mDays; }; #endif From 5ba1fd6aebb1fd965dde518515d320b027d55ccf Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 16 May 2009 21:56:54 -0400 Subject: [PATCH 05/18] FF4 - New Duration object - Replaces convertDuration. --- src/{rewrite => }/Duration.cpp | 0 src/{rewrite => }/Duration.h | 0 src/Makefile.am | 2 +- src/Makefile.in | 10 +++-- src/rewrite/Date.cpp | 69 ---------------------------------- src/rewrite/Date.h | 49 ------------------------ 6 files changed, 7 insertions(+), 123 deletions(-) rename src/{rewrite => }/Duration.cpp (100%) rename src/{rewrite => }/Duration.h (100%) delete mode 100644 src/rewrite/Date.cpp delete mode 100644 src/rewrite/Date.h diff --git a/src/rewrite/Duration.cpp b/src/Duration.cpp similarity index 100% rename from src/rewrite/Duration.cpp rename to src/Duration.cpp diff --git a/src/rewrite/Duration.h b/src/Duration.h similarity index 100% rename from src/rewrite/Duration.h rename to src/Duration.h diff --git a/src/Makefile.am b/src/Makefile.am index 1d898a521..baff7fbb1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,2 +1,2 @@ bin_PROGRAMS = task -task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp Grid.cpp Timer.cpp color.cpp parse.cpp task.cpp command.cpp edit.cpp report.cpp util.cpp text.cpp rules.cpp import.cpp Config.h Date.h T.h TDB.h Table.h Grid.h Timer.h color.h task.h +task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp Grid.cpp Timer.cpp Duration.cpp color.cpp parse.cpp task.cpp command.cpp edit.cpp report.cpp util.cpp text.cpp rules.cpp import.cpp Config.h Date.h T.h TDB.h Table.h Grid.h Timer.h Duration.h color.h task.h diff --git a/src/Makefile.in b/src/Makefile.in index ea3982dc4..a883c69a0 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -45,9 +45,10 @@ binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_task_OBJECTS = Config.$(OBJEXT) Date.$(OBJEXT) T.$(OBJEXT) \ TDB.$(OBJEXT) Table.$(OBJEXT) Grid.$(OBJEXT) Timer.$(OBJEXT) \ - color.$(OBJEXT) parse.$(OBJEXT) task.$(OBJEXT) \ - command.$(OBJEXT) edit.$(OBJEXT) report.$(OBJEXT) \ - util.$(OBJEXT) text.$(OBJEXT) rules.$(OBJEXT) import.$(OBJEXT) + Duration.$(OBJEXT) color.$(OBJEXT) parse.$(OBJEXT) \ + task.$(OBJEXT) command.$(OBJEXT) edit.$(OBJEXT) \ + report.$(OBJEXT) util.$(OBJEXT) text.$(OBJEXT) rules.$(OBJEXT) \ + import.$(OBJEXT) task_OBJECTS = $(am_task_OBJECTS) task_LDADD = $(LDADD) DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@ @@ -155,7 +156,7 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp Grid.cpp Timer.cpp color.cpp parse.cpp task.cpp command.cpp edit.cpp report.cpp util.cpp text.cpp rules.cpp import.cpp Config.h Date.h T.h TDB.h Table.h Grid.h Timer.h color.h task.h +task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp Grid.cpp Timer.cpp Duration.cpp color.cpp parse.cpp task.cpp command.cpp edit.cpp report.cpp util.cpp text.cpp rules.cpp import.cpp Config.h Date.h T.h TDB.h Table.h Grid.h Timer.h Duration.h color.h task.h all: all-am .SUFFIXES: @@ -224,6 +225,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Config.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Date.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Duration.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/T.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TDB.Po@am__quote@ diff --git a/src/rewrite/Date.cpp b/src/rewrite/Date.cpp deleted file mode 100644 index ad761b2a6..000000000 --- a/src/rewrite/Date.cpp +++ /dev/null @@ -1,69 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// task - a command line task list manager. -// -// Copyright 2006 - 2009, Paul Beckingham. -// All rights reserved. -// -// This program is free software; you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free Software -// Foundation; either version 2 of the License, or (at your option) any later -// version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -// details. -// -// You should have received a copy of the GNU General Public License along with -// this program; if not, write to the -// -// Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, -// Boston, MA -// 02110-1301 -// USA -// -//////////////////////////////////////////////////////////////////////////////// - -#include "Date.h" - -//////////////////////////////////////////////////////////////////////////////// -Date::Date () -{ -} - -//////////////////////////////////////////////////////////////////////////////// -Date::Date (const Date& other) -{ - throw std::string ("unimplemented Date::Date"); - mTime = other.mTime; -} - -//////////////////////////////////////////////////////////////////////////////// -Date& Date::operator= (const Date& other) -{ - throw std::string ("unimplemented Date::operator="); - if (this != &other) - { - mTime = other.mTime; - } - - return *this; -} - -//////////////////////////////////////////////////////////////////////////////// -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 Date::parse"); -} - -//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Date.h b/src/rewrite/Date.h deleted file mode 100644 index 935367ae0..000000000 --- a/src/rewrite/Date.h +++ /dev/null @@ -1,49 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// task - a command line task list manager. -// -// Copyright 2006 - 2009, Paul Beckingham. -// All rights reserved. -// -// This program is free software; you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free Software -// Foundation; either version 2 of the License, or (at your option) any later -// version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -// details. -// -// You should have received a copy of the GNU General Public License along with -// this program; if not, write to the -// -// Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, -// Boston, MA -// 02110-1301 -// USA -// -//////////////////////////////////////////////////////////////////////////////// -#ifndef INCLUDED_DATE -#define INCLUDED_DATE - -#include -#include - -class Date -{ -public: - Date (); // Default constructor - Date (const Date&); // Copy constructor - Date (time_t); // Copy constructor - Date& operator= (const Date&); // Assignment operator - ~Date (); // Destructor - - void parse (const std::string&); - -private: - time_t mTime; -}; - -#endif -//////////////////////////////////////////////////////////////////////////////// From 2e39929d710cf50eaa1c5ce3e7a2eb0fe7bb7b0f Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 16 May 2009 22:14:32 -0400 Subject: [PATCH 06/18] FF4 - util.cpp:convertDuration -> Duration - Replaced util.cpp convertDuration function with Duration object. --- DEVELOPERS | 33 +++++++++---------- src/Table.cpp | 5 +-- src/parse.cpp | 5 ++- src/task.cpp | 6 +++- src/tests/Makefile | 3 +- src/tests/duration.t.cpp | 45 +++++++++++++++----------- src/util.cpp | 68 ---------------------------------------- 7 files changed, 57 insertions(+), 108 deletions(-) diff --git a/DEVELOPERS b/DEVELOPERS index 6351d0819..e1bda67fe 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1,22 +1,23 @@ Developers may wish to change task, and here is a high-level guide to the files included. - task.{cpp,h} Implements main, high level processing. - command.cpp Implements all non-report task commands. - report.cpp Implements all task reports. - parse.cpp Parses the command line. - TDB.{cpp,h} The task database, performs all file I/O. - T.{cpp,h} Represents a single task - parses a record from TDB, and also - composes record for TDB. Provides accessors for tasks. - Grid.{cpp,h} Implements a sparse 2D array, provides data storage for the - Table object. - Table.{cpp,h} Implements tabular data rendering, wrapping etc. - Config.{cpp,h} Implements a reader for the .taskrc file. - Date.{cpp,h} General date class for the time_t type. - text.cpp Text manipulation functions. - util.cpp General utility functions. - color.cpp Color support functions. - rules.cpp Auto-colorization rules. + task.{cpp,h} Implements main, high level processing. + command.cpp Implements all non-report task commands. + report.cpp Implements all task reports. + parse.cpp Parses the command line. + TDB.{cpp,h} The task database, performs all file I/O. + T.{cpp,h} Represents a single task - parses a record from TDB, and also + composes record for TDB. Provides accessors for tasks. + Grid.{cpp,h} Implements a sparse 2D array, provides data storage for the + Table object. + Table.{cpp,h} Implements tabular data rendering, wrapping etc. + Config.{cpp,h} Implements a reader for the .taskrc file. + Date.{cpp,h} General date class for the time_t type. + Duration.{cpp,h} General duration class for time deltas. + text.cpp Text manipulation functions. + util.cpp General utility functions. + color.cpp Color support functions. + rules.cpp Auto-colorization rules. Please send bugs, patches to task@beckingham.net diff --git a/src/Table.cpp b/src/Table.cpp index 1d78dfde1..37b9a48e5 100644 --- a/src/Table.cpp +++ b/src/Table.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include //////////////////////////////////////////////////////////////////////////////// @@ -989,7 +990,7 @@ void Table::sort (std::vector & order) break; else if ((std::string)*left != "" && (std::string)*right == "") SWAP - else if (convertDuration ((std::string)*left) > convertDuration ((std::string)*right)) + else if (Duration ((std::string)*left) > Duration ((std::string)*right)) SWAP break; @@ -998,7 +999,7 @@ void Table::sort (std::vector & order) break; else if ((std::string)*left == "" && (std::string)*right != "") SWAP - else if (convertDuration ((std::string)*left) < convertDuration ((std::string)*right)) + else if (Duration ((std::string)*left) < Duration ((std::string)*right)) SWAP break; } diff --git a/src/parse.cpp b/src/parse.cpp index ae10e2be5..7e5a86f9f 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -31,6 +31,7 @@ #include #include "Date.h" +#include "Duration.h" #include "task.h" #include "T.h" @@ -445,7 +446,9 @@ static bool validSubstitution ( //////////////////////////////////////////////////////////////////////////////// bool validDuration (std::string& input) { - return (convertDuration (input) != 0) ? true : false; + try { Duration (input); } + catch (...) { return false; } + return true; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/task.cpp b/src/task.cpp index 4d2390154..4984b5a11 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -38,6 +38,7 @@ #include "Config.h" #include "Date.h" +#include "Duration.h" #include "Table.h" #include "TDB.h" #include "T.h" @@ -717,7 +718,10 @@ Date getNextRecurrence (Date& current, std::string& period) } // If the period is an 'easy' one, add it to current, and we're done. - int days = convertDuration (period); + int days = 0; + try { Duration du (period); days = du; } + catch (...) { days = 0; } + return current + (days * 86400); } diff --git a/src/tests/Makefile b/src/tests/Makefile index a71c8633e..6278cf5e7 100644 --- a/src/tests/Makefile +++ b/src/tests/Makefile @@ -2,7 +2,8 @@ PROJECT = t.t tdb.t date.t duration.t t.benchmark.t text.t autocomplete.t \ parse.t CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti LFLAGS = -L/usr/local/lib -OBJECTS = ../TDB.o ../T.o ../parse.o ../text.o ../Date.o ../util.o ../Config.o +OBJECTS = ../TDB.o ../T.o ../parse.o ../text.o ../Date.o ../Duration.o \ + ../util.o ../Config.o all: $(PROJECT) diff --git a/src/tests/duration.t.cpp b/src/tests/duration.t.cpp index 77e46a95c..c1c5e2108 100644 --- a/src/tests/duration.t.cpp +++ b/src/tests/duration.t.cpp @@ -25,9 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include -#include <../task.h> //////////////////////////////////////////////////////////////////////////////// // daily, day, Nd @@ -36,29 +35,37 @@ // 1st 2nd 3rd 4th .. 31st // quarterly, Nq // biannual, biyearly, annual, semiannual, yearly, Ny + +int convertDuration (const std::string& input) +{ + try { Duration d (input); return (int) d; } + catch (...) {} + return 0; +} + int main (int argc, char** argv) { UnitTest t (17); std::string d; - d = "daily"; t.is (convertDuration (d), 1, "duration daily = 1"); - d = "weekdays"; t.is (convertDuration (d), 1, "duration weekdays = 1"); - d = "day"; t.is (convertDuration (d), 1, "duration day = 1"); - d = "0d"; t.is (convertDuration (d), 0, "duration 0d = 0"); - d = "1d"; t.is (convertDuration (d), 1, "duration 1d = 1"); - d = "7d"; t.is (convertDuration (d), 7, "duration 7d = 7"); - d = "10d"; t.is (convertDuration (d), 10, "duration 10d = 10"); - d = "100d"; t.is (convertDuration (d), 100, "duration 100d = 100"); + t.is (convertDuration ("daily"), 1, "duration daily = 1"); + t.is (convertDuration ("weekdays"), 1, "duration weekdays = 1"); + t.is (convertDuration ("day"), 1, "duration day = 1"); + t.is (convertDuration ("0d"), 0, "duration 0d = 0"); + t.is (convertDuration ("1d"), 1, "duration 1d = 1"); + t.is (convertDuration ("7d"), 7, "duration 7d = 7"); + t.is (convertDuration ("10d"), 10, "duration 10d = 10"); + t.is (convertDuration ("100d"), 100, "duration 100d = 100"); - d = "weekly"; t.is (convertDuration (d), 7, "duration weekly = 7"); - d = "sennight"; t.is (convertDuration (d), 7, "duration sennight = 7"); - d = "biweekly"; t.is (convertDuration (d), 14, "duration biweekly = 14"); - d = "fortnight"; t.is (convertDuration (d), 14, "duration fortnight = 14"); - d = "0w"; t.is (convertDuration (d), 0, "duration 0w = 0"); - d = "1w"; t.is (convertDuration (d), 7, "duration 1w = 7"); - d = "7w"; t.is (convertDuration (d), 49, "duration 7w = 49"); - d = "10w"; t.is (convertDuration (d), 70, "duration 10w = 70"); - d = "100w"; t.is (convertDuration (d), 700, "duration 100w = 700"); + t.is (convertDuration ("weekly"), 7, "duration weekly = 7"); + t.is (convertDuration ("sennight"), 7, "duration sennight = 7"); + t.is (convertDuration ("biweekly"), 14, "duration biweekly = 14"); + t.is (convertDuration ("fortnight"), 14, "duration fortnight = 14"); + t.is (convertDuration ("0w"), 0, "duration 0w = 0"); + t.is (convertDuration ("1w"), 7, "duration 1w = 7"); + t.is (convertDuration ("7w"), 49, "duration 7w = 49"); + t.is (convertDuration ("10w"), 70, "duration 10w = 70"); + t.is (convertDuration ("100w"), 700, "duration 100w = 700"); return 0; } diff --git a/src/util.cpp b/src/util.cpp index 261e7d4af..736f24825 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -280,74 +280,6 @@ const std::string uuid () } #endif -//////////////////////////////////////////////////////////////////////////////// -// Recognize the following constructs, and return the number of days represented -int convertDuration (const std::string& input) -{ - std::string lower_input = lowerCase (input); - Date today; - - std::vector supported; - supported.push_back ("daily"); - supported.push_back ("day"); - supported.push_back ("weekly"); - supported.push_back ("weekdays"); - supported.push_back ("sennight"); - supported.push_back ("biweekly"); - supported.push_back ("fortnight"); - supported.push_back ("monthly"); - supported.push_back ("bimonthly"); - supported.push_back ("quarterly"); - supported.push_back ("biannual"); - supported.push_back ("biyearly"); - supported.push_back ("annual"); - supported.push_back ("semiannual"); - supported.push_back ("yearly"); - - std::vector matches; - if (autoComplete (lower_input, supported, matches) == 1) - { - std::string found = matches[0]; - - if (found == "daily" || found == "day") return 1; - else if (found == "weekdays") return 1; - else if (found == "weekly" || found == "sennight") return 7; - else if (found == "biweekly" || found == "fortnight") return 14; - else if (found == "monthly") return 30; - else if (found == "bimonthly") return 61; - else if (found == "quarterly") return 91; - else if (found == "semiannual") return 183; - else if (found == "yearly" || found == "annual") return 365; - else if (found == "biannual" || found == "biyearly") return 730; - } - - // Support \d+ d|w|m|q|y - else - { - // Verify all digits followed by d, w, m, q, or y. - unsigned int length = lower_input.length (); - for (unsigned int i = 0; i < length; ++i) - { - if (! isdigit (lower_input[i]) && - i == length - 1) - { - int number = ::atoi (lower_input.substr (0, i).c_str ()); - - switch (lower_input[length - 1]) - { - case 'd': return number * 1; break; - case 'w': return number * 7; break; - case 'm': return number * 30; break; - case 'q': return number * 91; break; - case 'y': return number * 365; break; - } - } - } - } - - return 0; // Error. -} - //////////////////////////////////////////////////////////////////////////////// std::string expandPath (const std::string& in) { From fdd43a961924835844c4fa886f3dd96b9c07c8d1 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 16 May 2009 22:22:56 -0400 Subject: [PATCH 07/18] FF4 - Snapshot - Added more Context responsibilities. --- src/rewrite/Context.cpp | 5 +++-- src/rewrite/Context.h | 4 ++-- src/rewrite/Makefile | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/rewrite/Context.cpp b/src/rewrite/Context.cpp index c68344681..0f8b14c95 100644 --- a/src/rewrite/Context.cpp +++ b/src/rewrite/Context.cpp @@ -36,7 +36,7 @@ Context::Context () Context::Context (const Context& other) { throw std::string ("unimplemented Context::Context"); -// config = other.config; + config = other.config; filter = other.filter; keymap = other.keymap; sequence = other.sequence; @@ -50,7 +50,7 @@ Context& Context::operator= (const Context& other) throw std::string ("unimplemented Context::operator="); if (this != &other) { -// config = other.config; + config = other.config; filter = other.filter; keymap = other.keymap; sequence = other.sequence; @@ -81,6 +81,7 @@ int Context::commandLine (int argc, char** argv) { throw std::string ("unimplemented Context::commandLine"); // TODO Support rc: override. + // TODO Handle "--version, -v" right here. return 0; } diff --git a/src/rewrite/Context.h b/src/rewrite/Context.h index 1be1b185f..26753a5eb 100644 --- a/src/rewrite/Context.h +++ b/src/rewrite/Context.h @@ -29,7 +29,7 @@ #include "Filter.h" #include "Keymap.h" -//#include "Config.h" +#include "Config.h" #include "Sequence.h" #include "TDB.h" #include "T.h" @@ -48,7 +48,7 @@ public: int run (); public: -// Config config; + Config config; Filter filter; Keymap keymap; Sequence sequence; diff --git a/src/rewrite/Makefile b/src/rewrite/Makefile index 7115320db..f4021e3ba 100644 --- a/src/rewrite/Makefile +++ b/src/rewrite/Makefile @@ -1,8 +1,9 @@ PROJECT = 1.8 -CFLAGS = -I. -I../../library/include -Wall -pedantic -ggdb3 -fno-rtti -fstack-check +CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti -fstack-check LFLAGS = LIBS = -OBJECTS = main.o Context.o TDB.o T.o Sequence.o Filter.o Att.o Date.o Duration.o Keymap.o +OBJECTS = main.o Context.o TDB.o T.o Sequence.o Filter.o Att.o Keymap.o \ + ../util.o ../text.o ../Config.o ../Date.o all: $(PROJECT) From 58e1f3691c3b3ae2c5d6bb26766487619fdff978 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 17 May 2009 17:11:35 -0400 Subject: [PATCH 08/18] FF4 - Snapshot - Added encode/decode Att methods. Necessary if description is to be an attribute, which will be quoted. --- src/rewrite/Att.cpp | 14 ++++++++++++++ src/rewrite/Att.h | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/src/rewrite/Att.cpp b/src/rewrite/Att.cpp index 8bd34fb1f..1082d77ad 100644 --- a/src/rewrite/Att.cpp +++ b/src/rewrite/Att.cpp @@ -152,3 +152,17 @@ bool Att::internal () const } //////////////////////////////////////////////////////////////////////////////// +// TODO Encode values prior to serialization. +void Att::encode (std::string&) const +{ + throw std::string ("unimplemented Att::internal"); +} + +//////////////////////////////////////////////////////////////////////////////// +// TODO Decode values after parse. +void Att::decode (std::string&) const +{ + throw std::string ("unimplemented Att::internal"); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Att.h b/src/rewrite/Att.h index 2dd8ac8c2..e496a9261 100644 --- a/src/rewrite/Att.h +++ b/src/rewrite/Att.h @@ -57,6 +57,10 @@ public: bool required () const; bool internal () const; +private: + void encode (std::string&) const; + void decode (std::string&) const; + private: std::string mName; std::string mValue; From 04f60a4d8cdcba315223419d9862f5ab4b86d980 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 17 May 2009 23:29:53 -0400 Subject: [PATCH 09/18] FF4 - header file reorg - Added new util.h and text.h header files. - Corresponding edits. --- src/Config.cpp | 3 +- src/Date.cpp | 3 +- src/Duration.cpp | 3 +- src/T.cpp | 3 +- src/TDB.cpp | 3 +- src/Table.cpp | 3 +- src/command.cpp | 4 +++ src/edit.cpp | 5 ++++ src/import.cpp | 4 +++ src/parse.cpp | 3 +- src/report.cpp | 2 ++ src/rules.cpp | 3 +- src/task.cpp | 2 ++ src/task.h | 56 ----------------------------------- src/text.cpp | 4 ++- src/text.h | 51 ++++++++++++++++++++++++++++++++ src/util.cpp | 3 ++ src/util.h | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ 18 files changed, 166 insertions(+), 65 deletions(-) create mode 100644 src/text.h create mode 100644 src/util.h diff --git a/src/Config.cpp b/src/Config.cpp index 6a99189ad..ac63f9871 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -32,8 +32,9 @@ #include #include #include -#include "task.h" #include "Config.h" +#include "text.h" +#include "util.h" //////////////////////////////////////////////////////////////////////////////// // These are default (but overridable) reports. These entries are necessary diff --git a/src/Date.cpp b/src/Date.cpp index 995011345..cdc5cc7d3 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -28,8 +28,9 @@ #include #include #include -#include "task.h" #include "Date.h" +#include "text.h" +#include "util.h" //////////////////////////////////////////////////////////////////////////////// // Defaults to "now". diff --git a/src/Duration.cpp b/src/Duration.cpp index d0cb4a469..7c55be345 100644 --- a/src/Duration.cpp +++ b/src/Duration.cpp @@ -26,7 +26,8 @@ //////////////////////////////////////////////////////////////////////////////// #include -#include "task.h" +#include "text.h" +#include "util.h" #include "Duration.h" //////////////////////////////////////////////////////////////////////////////// diff --git a/src/T.cpp b/src/T.cpp index 58a280f62..43bf0e200 100644 --- a/src/T.cpp +++ b/src/T.cpp @@ -27,8 +27,9 @@ #include #include #include -#include "task.h" #include "T.h" +#include "text.h" +#include "util.h" //////////////////////////////////////////////////////////////////////////////// // Default diff --git a/src/TDB.cpp b/src/TDB.cpp index 98c2c8009..299eda3e6 100644 --- a/src/TDB.cpp +++ b/src/TDB.cpp @@ -31,8 +31,9 @@ #include #include -#include "task.h" +#include "T.h" #include "TDB.h" +#include "util.h" //////////////////////////////////////////////////////////////////////////////// TDB::TDB () diff --git a/src/Table.cpp b/src/Table.cpp index 37b9a48e5..f737d52e6 100644 --- a/src/Table.cpp +++ b/src/Table.cpp @@ -49,7 +49,8 @@ #include #include #include -#include +#include "text.h" +#include "util.h" //////////////////////////////////////////////////////////////////////////////// Table::Table () diff --git a/src/command.cpp b/src/command.cpp index 4a89427e1..4f8cc67cc 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -34,6 +34,10 @@ #include #include +#include "T.h" +#include "TDB.h" +#include "text.h" +#include "util.h" #include "task.h" #ifdef HAVE_LIBNCURSES diff --git a/src/edit.cpp b/src/edit.cpp index 445e8a1c6..30be75ec7 100644 --- a/src/edit.cpp +++ b/src/edit.cpp @@ -33,6 +33,11 @@ #include #include #include +#include "T.h" +#include "TDB.h" +#include "Date.h" +#include "text.h" +#include "util.h" #include "task.h" //////////////////////////////////////////////////////////////////////////////// diff --git a/src/import.cpp b/src/import.cpp index 163dca30d..bcb154147 100644 --- a/src/import.cpp +++ b/src/import.cpp @@ -29,6 +29,10 @@ #include #include #include "Date.h" +#include "T.h" +#include "TDB.h" +#include "text.h" +#include "util.h" #include "task.h" //////////////////////////////////////////////////////////////////////////////// diff --git a/src/parse.cpp b/src/parse.cpp index 7e5a86f9f..b4e40aa34 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -32,8 +32,9 @@ #include "Date.h" #include "Duration.h" -#include "task.h" #include "T.h" +#include "text.h" +#include "util.h" //////////////////////////////////////////////////////////////////////////////// // NOTE: These are static arrays only because there is no initializer list for diff --git a/src/report.cpp b/src/report.cpp index 050f6e85c..17f5bd1fb 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -40,6 +40,8 @@ #include "Table.h" #include "TDB.h" #include "T.h" +#include "text.h" +#include "util.h" #include "task.h" #ifdef HAVE_LIBNCURSES diff --git a/src/rules.cpp b/src/rules.cpp index 5744dd3ca..2030e1a36 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -30,7 +30,8 @@ #include "Table.h" #include "Date.h" #include "T.h" -#include "task.h" +#include "text.h" +#include "util.h" static std::map gsFg; static std::map gsBg; diff --git a/src/task.cpp b/src/task.cpp index 4984b5a11..57526180a 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -42,6 +42,8 @@ #include "Table.h" #include "TDB.h" #include "T.h" +#include "text.h" +#include "util.h" #include "task.h" #ifdef HAVE_LIBNCURSES diff --git a/src/task.h b/src/task.h index 7599007ea..3104c5d6d 100644 --- a/src/task.h +++ b/src/task.h @@ -33,26 +33,8 @@ #include "Table.h" #include "Date.h" #include "color.h" -#include "TDB.h" -#include "T.h" #include "../auto.h" -#ifndef min -#define min(a,b) ((a) < (b) ? (a) : (b)) -#endif - -#ifndef max -#define max(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#define foreach(i, c) \ -for (typeof (c) *foreach_p = & (c); \ - foreach_p; \ - foreach_p = 0) \ - for (typeof (foreach_p->begin()) i = foreach_p->begin(); \ - i != foreach_p->end(); \ - ++i) - // parse.cpp void parse (std::vector &, std::string&, T&, Config&); bool validPriority (const std::string&); @@ -120,44 +102,6 @@ std::string handleCustomReport (TDB&, T&, Config&, const std::string&); void validReportColumns (const std::vector &); void validSortColumns (const std::vector &, const std::vector &); -// text.cpp -void wrapText (std::vector &, const std::string&, const int); -std::string trimLeft (const std::string& in, const std::string& t = " "); -std::string trimRight (const std::string& in, const std::string& t = " "); -std::string trim (const std::string& in, const std::string& t = " "); -std::string unquoteText (const std::string&); -void extractLine (std::string&, std::string&, int); -void split (std::vector&, const std::string&, const char); -void split (std::vector&, const std::string&, const std::string&); -void join (std::string&, const std::string&, const std::vector&); -std::string commify (const std::string&); -std::string lowerCase (const std::string&); -std::string upperCase (const std::string&); -const char* optionalBlankLine (Config&); - -// util.cpp -bool confirm (const std::string&); -void delay (float); -void formatTimeDeltaDays (std::string&, time_t); -std::string formatSeconds (time_t); -int autoComplete (const std::string&, const std::vector&, std::vector&); -const std::string uuid (); -int convertDuration (const std::string&); -std::string expandPath (const std::string&); - -#ifdef SOLARIS - #define LOCK_SH 1 - #define LOCK_EX 2 - #define LOCK_NB 4 - #define LOCK_UN 8 - - int flock (int, int); -#endif - -bool slurp (const std::string&, std::vector &, bool trimLines = false); -bool slurp (const std::string&, std::string&, bool trimLines = false); -void spit (const std::string&, const std::string&); - // rules.cpp void initializeColorRules (Config&); void autoColorize (T&, Text::color&, Text::color&, Config&); diff --git a/src/text.cpp b/src/text.cpp index 69689a5ac..ac1015031 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -27,7 +27,9 @@ #include #include #include -#include "task.h" +#include "Config.h" +#include "util.h" +#include "text.h" static const char* newline = "\n"; static const char* noline = ""; diff --git a/src/text.h b/src/text.h new file mode 100644 index 000000000..458d714d0 --- /dev/null +++ b/src/text.h @@ -0,0 +1,51 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_TEXT +#define INCLUDED_TEXT + +#include +#include +#include "Config.h" +#include "../auto.h" + +// text.cpp +void wrapText (std::vector &, const std::string&, const int); +std::string trimLeft (const std::string& in, const std::string& t = " "); +std::string trimRight (const std::string& in, const std::string& t = " "); +std::string trim (const std::string& in, const std::string& t = " "); +std::string unquoteText (const std::string&); +void extractLine (std::string&, std::string&, int); +void split (std::vector&, const std::string&, const char); +void split (std::vector&, const std::string&, const std::string&); +void join (std::string&, const std::string&, const std::vector&); +std::string commify (const std::string&); +std::string lowerCase (const std::string&); +std::string upperCase (const std::string&); +const char* optionalBlankLine (Config&); + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/util.cpp b/src/util.cpp index 736f24825..8cbb9cfe2 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -38,6 +38,9 @@ #include #include "Date.h" #include "Table.h" +#include "T.h" +#include "TDB.h" +#include "text.h" #include "task.h" #include "../auto.h" diff --git a/src/util.h b/src/util.h new file mode 100644 index 000000000..2bfaef59a --- /dev/null +++ b/src/util.h @@ -0,0 +1,76 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_UTIL +#define INCLUDED_UTIL + +#include +#include +#include +#include +#include "../auto.h" + +#ifndef min +#define min(a,b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a,b) ((a) > (b) ? (a) : (b)) +#endif + +#define foreach(i, c) \ +for (typeof (c) *foreach_p = & (c); \ + foreach_p; \ + foreach_p = 0) \ + for (typeof (foreach_p->begin()) i = foreach_p->begin(); \ + i != foreach_p->end(); \ + ++i) + +// util.cpp +bool confirm (const std::string&); +void delay (float); +void formatTimeDeltaDays (std::string&, time_t); +std::string formatSeconds (time_t); +int autoComplete (const std::string&, const std::vector&, std::vector&); +const std::string uuid (); +int convertDuration (const std::string&); +std::string expandPath (const std::string&); + +#ifdef SOLARIS + #define LOCK_SH 1 + #define LOCK_EX 2 + #define LOCK_NB 4 + #define LOCK_UN 8 + + int flock (int, int); +#endif + +bool slurp (const std::string&, std::vector &, bool trimLines = false); +bool slurp (const std::string&, std::string&, bool trimLines = false); +void spit (const std::string&, const std::string&); + +#endif +//////////////////////////////////////////////////////////////////////////////// From 3a9c98d342c08cb846e95d63b790cc86c4bd42c6 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 17 May 2009 23:31:25 -0400 Subject: [PATCH 10/18] FF4 - snapshot --- src/rewrite/Att.h | 2 +- src/rewrite/Context.cpp | 75 ++++++++++++++++++++++++++++++++++------- src/rewrite/Context.h | 8 +++-- src/rewrite/Makefile | 2 +- src/rewrite/Record.cpp | 5 +++ src/rewrite/Record.h | 6 +++- src/rewrite/T.cpp | 8 ++--- src/rewrite/T.h | 6 ++-- src/rewrite/TDB.cpp | 34 ++++++++++++++++++- src/rewrite/TDB.h | 8 +++++ src/rewrite/main.cpp | 3 +- 11 files changed, 127 insertions(+), 30 deletions(-) diff --git a/src/rewrite/Att.h b/src/rewrite/Att.h index e496a9261..708e82952 100644 --- a/src/rewrite/Att.h +++ b/src/rewrite/Att.h @@ -34,7 +34,7 @@ class Att { public: Att (); // Default constructor - Att (const std::string&, const std::string&); + Att (const std::string&, const std::string&); // Simple constructor Att (const Att&); // Copy constructor Att& operator= (const Att&); // Assignment operator ~Att (); // Destructor diff --git a/src/rewrite/Context.cpp b/src/rewrite/Context.cpp index 0f8b14c95..8c16ccfe4 100644 --- a/src/rewrite/Context.cpp +++ b/src/rewrite/Context.cpp @@ -25,11 +25,22 @@ // //////////////////////////////////////////////////////////////////////////////// +#include #include "Context.h" +#include "text.h" +#include "util.h" +#include "task.h" +#include "../auto.h" //////////////////////////////////////////////////////////////////////////////// Context::Context () { + // Set up randomness. +#ifdef HAVE_SRANDOM + srandom (time (NULL)); +#else + srand (time (NULL)); +#endif } //////////////////////////////////////////////////////////////////////////////// @@ -67,24 +78,39 @@ Context::~Context () } //////////////////////////////////////////////////////////////////////////////// -void Context::initialize () +void Context::initialize (int argc, char** argv) { - throw std::string ("unimplemented Context::initialize"); - // TODO Load config. + // Load the config 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. + if (!isatty (fileno (stdout))) + { + config.set ("curses", "off"); + + if (! config.get (std::string ("_forcecolor"), false)) + config.set ("color", "off"); + } + + // TODO Handle "--version, -v" right here. + + // init TDB. + std::string location = config.get ("data.location"); + std::vector all; + split (all, location, ','); + foreach (path, all) + tdb.location (expandPath (*path)); + + // Allow user override of file locking. Solaris/NFS machines may want this. + if (! config.get ("locking", true)) + tdb.noLock (); + // TODO Load pending.data. // TODO Load completed.data. // TODO Load deleted.data. } -//////////////////////////////////////////////////////////////////////////////// -int Context::commandLine (int argc, char** argv) -{ - throw std::string ("unimplemented Context::commandLine"); - // TODO Support rc: override. - // TODO Handle "--version, -v" right here. - return 0; -} - //////////////////////////////////////////////////////////////////////////////// int Context::run () { @@ -97,4 +123,29 @@ int Context::run () } //////////////////////////////////////////////////////////////////////////////// +void Context::loadCorrectConfigFile (int argc, char** argv) +{ + for (int i = 1; i < argc; ++i) + { + if (! strncmp (argv[i], "rc:", 3)) + { + if (! access (&(argv[i][3]), F_OK)) + { + std::string file = &(argv[i][3]); + config.load (file); + return; + } + else + throw std::string ("Could not read configuration file '") + &(argv[i][3]) + "'"; + } + } + struct passwd* pw = getpwuid (getuid ()); + if (!pw) + throw std::string ("Could not read home directory from passwd file."); + + std::string file = pw->pw_dir; + config.createDefault (file); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Context.h b/src/rewrite/Context.h index 26753a5eb..c0d50c68a 100644 --- a/src/rewrite/Context.h +++ b/src/rewrite/Context.h @@ -31,8 +31,8 @@ #include "Keymap.h" #include "Config.h" #include "Sequence.h" -#include "TDB.h" #include "T.h" +#include "TDB.h" class Context @@ -43,10 +43,12 @@ public: Context& operator= (const Context&); // Assignment operator ~Context (); // Destructor - void initialize (); - int commandLine (int, char**); + void initialize (int, char**); int run (); +private: + void loadCorrectConfigFile (int, char**); + public: Config config; Filter filter; diff --git a/src/rewrite/Makefile b/src/rewrite/Makefile index f4021e3ba..fd26bdde4 100644 --- a/src/rewrite/Makefile +++ b/src/rewrite/Makefile @@ -3,7 +3,7 @@ CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti -fstack-check LFLAGS = LIBS = OBJECTS = main.o Context.o TDB.o T.o Sequence.o Filter.o Att.o Keymap.o \ - ../util.o ../text.o ../Config.o ../Date.o + Record.o ../util.o ../text.o ../Config.o ../Date.o all: $(PROJECT) diff --git a/src/rewrite/Record.cpp b/src/rewrite/Record.cpp index f74517d9d..4249ac7e0 100644 --- a/src/rewrite/Record.cpp +++ b/src/rewrite/Record.cpp @@ -57,4 +57,9 @@ Record::~Record () } //////////////////////////////////////////////////////////////////////////////// +void Record::parse (const std::string& input) +{ + throw std::string ("unimplemented Record::parse"); +} +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Record.h b/src/rewrite/Record.h index 20c10977d..d35e8a02e 100644 --- a/src/rewrite/Record.h +++ b/src/rewrite/Record.h @@ -36,7 +36,11 @@ public: Record (); // Default constructor Record (const Record&); // Copy constructor Record& operator= (const Record&); // Assignment operator - ~Record (); // Destructor + virtual ~Record (); // Destructor + + virtual std::string composeF4 () = 0; + virtual std::string composeCSV () = 0; + void parse (const std::string&); private: std::vector mAtts; diff --git a/src/rewrite/T.cpp b/src/rewrite/T.cpp index f88d4b179..af5f9c234 100644 --- a/src/rewrite/T.cpp +++ b/src/rewrite/T.cpp @@ -34,11 +34,13 @@ T::T () } //////////////////////////////////////////////////////////////////////////////// +/* T::T (const T& other) { throw std::string ("unimplemented T::T"); // mOne = other.mOne; } +*/ //////////////////////////////////////////////////////////////////////////////// T::T (const std::string& input) @@ -78,9 +80,3 @@ std::string T::composeCSV () } //////////////////////////////////////////////////////////////////////////////// -void T::parse (const std::string& input) -{ - throw std::string ("unimplemented T::parse"); -} - -//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/T.h b/src/rewrite/T.h index 1453c7347..8275956fb 100644 --- a/src/rewrite/T.h +++ b/src/rewrite/T.h @@ -28,19 +28,19 @@ #define INCLUDED_T #include +#include "Record.h" -class T +class T : public Record { public: T (); // Default constructor - T (const T&); // Copy constructor +// T (const T&); // Copy constructor T (const std::string&); // Parse T& operator= (const T&); // Assignment operator ~T (); // Destructor 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 5526a5611..3f2d658be 100644 --- a/src/rewrite/TDB.cpp +++ b/src/rewrite/TDB.cpp @@ -26,10 +26,14 @@ //////////////////////////////////////////////////////////////////////////////// #include +#include "text.h" +#include "util.h" #include "TDB.h" +#include "task.h" //////////////////////////////////////////////////////////////////////////////// TDB::TDB () +: mLock (true) { } @@ -60,7 +64,11 @@ TDB::~TDB () //////////////////////////////////////////////////////////////////////////////// void TDB::location (const std::string& path) { - throw std::string ("unimplemented TDB::location"); + if (access (expandPath (path).c_str (), F_OK)) + throw std::string ("Data location '") + + path + + "' does not exist, or is not readable and writable."; + mLocations.push_back (path); } @@ -94,3 +102,27 @@ void TDB::upgrade () } //////////////////////////////////////////////////////////////////////////////// +void TDB::noLock () +{ + mLock = false; +} + +//////////////////////////////////////////////////////////////////////////////// +void TDB::getPendingFiles (std::vector files) +{ + files.clear (); + + foreach (location, mLocations) + files.push_back (*location + "/pending.data"); +} + +//////////////////////////////////////////////////////////////////////////////// +void TDB::getCompletedFiles (std::vector files) +{ + files.clear (); + + foreach (location, mLocations) + files.push_back (*location + "/completed.data"); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/TDB.h b/src/rewrite/TDB.h index 468fefb47..0e6721fb1 100644 --- a/src/rewrite/TDB.h +++ b/src/rewrite/TDB.h @@ -46,8 +46,16 @@ public: int commit (); void upgrade (); + void noLock (); + +private: + void getPendingFiles (std::vector ); + void getCompletedFiles (std::vector ); + private: std::vector mLocations; + bool mLock; + // TODO Need cache of raw file contents. }; diff --git a/src/rewrite/main.cpp b/src/rewrite/main.cpp index b145dae1d..3b1cc6c5b 100644 --- a/src/rewrite/main.cpp +++ b/src/rewrite/main.cpp @@ -8,8 +8,7 @@ int main (int argc, char** argv) try { Context c; - c.initialize (); - c.commandLine (argc, argv); + c.initialize (argc, argv); c.run (); return 0; From f97dff0125a18c782bd64e03358659b61a133f5b Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 18 May 2009 22:26:51 -0400 Subject: [PATCH 11/18] FF4 - Snapshot - Implemented TDB::lock, TDB::unlock. --- src/rewrite/Context.cpp | 6 +- src/rewrite/TDB.cpp | 119 ++++++++++++++++++++++++++++++++++++---- src/rewrite/TDB.h | 24 +++++--- 3 files changed, 126 insertions(+), 23 deletions(-) diff --git a/src/rewrite/Context.cpp b/src/rewrite/Context.cpp index 8c16ccfe4..35c64a68c 100644 --- a/src/rewrite/Context.cpp +++ b/src/rewrite/Context.cpp @@ -103,8 +103,7 @@ void Context::initialize (int argc, char** argv) tdb.location (expandPath (*path)); // Allow user override of file locking. Solaris/NFS machines may want this. - if (! config.get ("locking", true)) - tdb.noLock (); + tdb.lock (config.get ("locking", true)); // TODO Load pending.data. // TODO Load completed.data. @@ -114,11 +113,12 @@ void Context::initialize (int argc, char** argv) //////////////////////////////////////////////////////////////////////////////// int Context::run () { - throw std::string ("unimplemented Context::run"); // TODO Dispatch to command handlers. // TODO Auto shadow update. // TODO Auto gc. + // TODO tdb.load (Filter); + throw std::string ("unimplemented Context::run"); return 0; } diff --git a/src/rewrite/TDB.cpp b/src/rewrite/TDB.cpp index 3f2d658be..6a4ccb018 100644 --- a/src/rewrite/TDB.cpp +++ b/src/rewrite/TDB.cpp @@ -26,14 +26,45 @@ //////////////////////////////////////////////////////////////////////////////// #include +#include #include "text.h" #include "util.h" #include "TDB.h" #include "task.h" //////////////////////////////////////////////////////////////////////////////// +// The ctor/dtor do nothing. +// The lock/unlock methods hold the file open. +// There should be only one commit. +// +// +- TDB::TDB +// | +// | +- TDB::lock +// | | open +// | | [lock] +// | | +// | | +- TDB::load (Filter) +// | | | read all +// | | | apply filter +// | | | return subset +// | | | +// | | +- TDB::add (T) +// | | | +// | | +- TDB::update (T, T') +// | | | +// | | +- TDB::commit +// | | write all +// | | +// | +- TDB::unlock +// | [unlock] +// | close +// | +// +- TDB::~TDB +// [TDB::unlock] +// TDB::TDB () : mLock (true) +, mAllOpenAndLocked (false) { } @@ -41,7 +72,13 @@ TDB::TDB () TDB::TDB (const TDB& other) { throw std::string ("unimplemented TDB::TDB"); - mLocations = other.mLocations; + mLocations = other.mLocations; + mLock = other.mLock; + mAllOpenAndLocked = false; // Deliberately so. + + // Set all to NULL. + foreach (location, mLocations) + mLocations[location->first] = NULL; } //////////////////////////////////////////////////////////////////////////////// @@ -50,7 +87,13 @@ TDB& TDB::operator= (const TDB& other) throw std::string ("unimplemented TDB::operator="); if (this != &other) { - mLocations = other.mLocations; + mLocations = other.mLocations; + mLock = other.mLock; + mAllOpenAndLocked = false; // Deliberately so. + + // Set all to NULL. + foreach (location, mLocations) + mLocations[location->first] = NULL; } return *this; @@ -59,6 +102,8 @@ TDB& TDB::operator= (const TDB& other) //////////////////////////////////////////////////////////////////////////////// TDB::~TDB () { + if (mAllOpenAndLocked) + unlock (); } //////////////////////////////////////////////////////////////////////////////// @@ -69,7 +114,33 @@ void TDB::location (const std::string& path) path + "' does not exist, or is not readable and writable."; - mLocations.push_back (path); + mLocations[path] = NULL; +} + +//////////////////////////////////////////////////////////////////////////////// +void TDB::lock (bool lockFile /* = true */) +{ + mLock = lockFile; + + foreach (location, mLocations) + mLocations[location->first] = openAndLock (location->first); + + mAllOpenAndLocked = true; +} + +//////////////////////////////////////////////////////////////////////////////// +void TDB::unlock () +{ + foreach (location, mLocations) + { + if (mLocations[location->first] != NULL) + { + fclose (mLocations[location->first]); + mLocations[location->first] = NULL; + } + } + + mAllOpenAndLocked = false; } //////////////////////////////////////////////////////////////////////////////// @@ -80,6 +151,13 @@ int TDB::load (std::vector & tasks, Filter& filter) return 0; } +//////////////////////////////////////////////////////////////////////////////// +// TODO Write to transaction log. +void TDB::add (T& after) +{ + throw std::string ("unimplemented TDB::add"); +} + //////////////////////////////////////////////////////////////////////////////// // TODO Write to transaction log. void TDB::update (T& before, T& after) @@ -101,19 +179,13 @@ void TDB::upgrade () throw std::string ("unimplemented TDB::upgrade"); } -//////////////////////////////////////////////////////////////////////////////// -void TDB::noLock () -{ - mLock = false; -} - //////////////////////////////////////////////////////////////////////////////// void TDB::getPendingFiles (std::vector files) { files.clear (); foreach (location, mLocations) - files.push_back (*location + "/pending.data"); + files.push_back (location->first + "/pending.data"); } //////////////////////////////////////////////////////////////////////////////// @@ -122,7 +194,32 @@ void TDB::getCompletedFiles (std::vector files) files.clear (); foreach (location, mLocations) - files.push_back (*location + "/completed.data"); + files.push_back (location->first + "/completed.data"); +} + +//////////////////////////////////////////////////////////////////////////////// +FILE* TDB::openAndLock (const std::string& file) +{ + // Check for access. + if (access (file.c_str (), F_OK | R_OK | W_OK)) + throw std::string ("Task does not have the correct permissions for '") + + file + "'."; + + // Open the file. + FILE* in = fopen (file.c_str (), "rw"); + if (!in) + throw std::string ("Could not open '") + file + "'."; + + // Lock if desired. Try three times before failing. + int retry = 0; + if (mLock) + while (flock (fileno (in), LOCK_EX) && ++retry <= 3) + delay (0.1); + + if (!in) + throw std::string ("Could not lock '") + file + "'."; + + return in; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/TDB.h b/src/rewrite/TDB.h index 0e6721fb1..c2f94f697 100644 --- a/src/rewrite/TDB.h +++ b/src/rewrite/TDB.h @@ -27,6 +27,7 @@ #ifndef INCLUDED_TDB #define INCLUDED_TDB +#include #include #include #include "Filter.h" @@ -40,21 +41,26 @@ public: TDB& operator= (const TDB&); // Assignment operator ~TDB (); // Destructor - void location (const std::string&); - int load (std::vector &, Filter&); - void update (T&, T&); - int commit (); - void upgrade (); + void location (const std::string&); - void noLock (); + void lock (bool lockFile = true); + void unlock (); + + int load (std::vector &, Filter&); + void add (T&); + void update (T&, T&); + int commit (); + void upgrade (); private: - void getPendingFiles (std::vector ); - void getCompletedFiles (std::vector ); + void getPendingFiles (std::vector ); + void getCompletedFiles (std::vector ); + FILE* openAndLock (const std::string&); private: - std::vector mLocations; + std::map mLocations; bool mLock; + bool mAllOpenAndLocked; // TODO Need cache of raw file contents. }; From e754fa6eacfc85346944607f80d1dca54499ef1a Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 19 May 2009 01:38:05 -0400 Subject: [PATCH 12/18] 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; From eb5bd6345958ed6d9043f8e0780099828ee88f54 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 22 May 2009 20:12:10 -0400 Subject: [PATCH 13/18] FF4 - Snapshot --- src/rewrite/T.cpp | 9 --------- src/rewrite/T.h | 1 - 2 files changed, 10 deletions(-) diff --git a/src/rewrite/T.cpp b/src/rewrite/T.cpp index 933bf218f..d3b761766 100644 --- a/src/rewrite/T.cpp +++ b/src/rewrite/T.cpp @@ -33,15 +33,6 @@ T::T () { } -//////////////////////////////////////////////////////////////////////////////// -/* -T::T (const T& other) -{ - throw std::string ("unimplemented T::T"); -// mOne = other.mOne; -} -*/ - //////////////////////////////////////////////////////////////////////////////// T::T (const std::string& input) { diff --git a/src/rewrite/T.h b/src/rewrite/T.h index 8275956fb..09683d4ab 100644 --- a/src/rewrite/T.h +++ b/src/rewrite/T.h @@ -34,7 +34,6 @@ class T : public Record { public: T (); // Default constructor -// T (const T&); // Copy constructor T (const std::string&); // Parse T& operator= (const T&); // Assignment operator ~T (); // Destructor From 5ac3f0c47e98bc904217378988d5f518072d0f61 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 23 May 2009 00:35:47 -0400 Subject: [PATCH 14/18] FF4 - snapshot --- src/rewrite/Att.cpp | 76 +++++++++++++++++++++++++++++++++---- src/rewrite/Att.h | 4 +- src/rewrite/Makefile | 3 +- src/rewrite/Mod.cpp | 49 ++++++++++++++++++++++++ src/rewrite/Mod.h | 42 ++++++++++++++++++++ src/rewrite/StringTable.cpp | 59 ++++++++++++++++++++++++++++ src/rewrite/StringTable.h | 46 ++++++++++++++++++++++ 7 files changed, 269 insertions(+), 10 deletions(-) create mode 100644 src/rewrite/Mod.cpp create mode 100644 src/rewrite/Mod.h create mode 100644 src/rewrite/StringTable.cpp create mode 100644 src/rewrite/StringTable.h diff --git a/src/rewrite/Att.cpp b/src/rewrite/Att.cpp index 43f51bdd7..27146b10b 100644 --- a/src/rewrite/Att.cpp +++ b/src/rewrite/Att.cpp @@ -44,6 +44,7 @@ Att::Att (const std::string& name, const std::string& value) mMods.clear (); } + //////////////////////////////////////////////////////////////////////////////// Att::Att (const Att& other) { @@ -81,10 +82,14 @@ void Att::parse (const std::string& input) } //////////////////////////////////////////////////////////////////////////////// +// name : " value " std::string Att::composeF4 () const { - throw std::string ("unimplemented Att::composeF4"); - return ""; + std::string value = mValue; + encode (value); + enquote (value); + + return mName + ":" + value; } //////////////////////////////////////////////////////////////////////////////// @@ -145,12 +150,29 @@ bool Att::required () const } //////////////////////////////////////////////////////////////////////////////// -bool Att::internal () const +bool Att::reserved () const { - throw std::string ("unimplemented Att::internal"); + throw std::string ("unimplemented Att::reserved"); return false; } +//////////////////////////////////////////////////////////////////////////////// +// Add quotes. +void Att::enquote (std::string& value) const +{ + value = '"' + value + '"'; +} + +//////////////////////////////////////////////////////////////////////////////// +// Remove quotes. +void Att::dequote (std::string& value) const +{ + if (value.length () > 2 && + value[0] == '"' && + value[value.length () - 1] == '"') + value = value.substr (1, value.length () - 2); +} + //////////////////////////////////////////////////////////////////////////////// // Encode values prior to serialization. // \t -> &tab; @@ -158,9 +180,28 @@ bool Att::internal () const // , -> , // [ -> &open; // ] -> &close; -void Att::encode (std::string&) const +// : -> : +void Att::encode (std::string& value) const { - throw std::string ("unimplemented Att::internal"); + std::string::size_type i; + + while ((i = value.find ('\t')) != std::string::npos) + value.replace (i, 1, "&tab;"); + + while ((i = value.find ('"')) != std::string::npos) + value.replace (i, 1, """); + + while ((i = value.find (',')) != std::string::npos) + value.replace (i, 1, ","); + + while ((i = value.find ('[')) != std::string::npos) + value.replace (i, 1, "&open;"); + + while ((i = value.find (']')) != std::string::npos) + value.replace (i, 1, "&close;"); + + while ((i = value.find (':')) != std::string::npos) + value.replace (i, 1, ":"); } //////////////////////////////////////////////////////////////////////////////// @@ -170,9 +211,28 @@ void Att::encode (std::string&) const // , <- , // [ <- &open; // ] <- &close; -void Att::decode (std::string&) const +// : <- : +void Att::decode (std::string& value) const { - throw std::string ("unimplemented Att::internal"); + std::string::size_type i; + + while ((i = value.find ("&tab;")) != std::string::npos) + value.replace (i, 5, "\t"); + + while ((i = value.find (""")) != std::string::npos) + value.replace (i, 6, "\""); + + while ((i = value.find (",")) != std::string::npos) + value.replace (i, 7, ","); + + while ((i = value.find ("&open;")) != std::string::npos) + value.replace (i, 6, "["); + + while ((i = value.find ("&close;")) != std::string::npos) + value.replace (i, 7, "]"); + + while ((i = value.find (":")) != std::string::npos) + value.replace (i, 7, ":"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Att.h b/src/rewrite/Att.h index 708e82952..d0c116cc1 100644 --- a/src/rewrite/Att.h +++ b/src/rewrite/Att.h @@ -55,9 +55,11 @@ public: bool filter () const; bool required () const; - bool internal () const; + bool reserved () const; private: + void enquote (std::string&) const; + void dequote (std::string&) const; void encode (std::string&) const; void decode (std::string&) const; diff --git a/src/rewrite/Makefile b/src/rewrite/Makefile index fd26bdde4..d6518d60f 100644 --- a/src/rewrite/Makefile +++ b/src/rewrite/Makefile @@ -3,7 +3,8 @@ CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti -fstack-check LFLAGS = LIBS = OBJECTS = main.o Context.o TDB.o T.o Sequence.o Filter.o Att.o Keymap.o \ - Record.o ../util.o ../text.o ../Config.o ../Date.o + Record.o Mod.o StringTable.o ../util.o ../text.o ../Config.o \ + ../Date.o all: $(PROJECT) diff --git a/src/rewrite/Mod.cpp b/src/rewrite/Mod.cpp new file mode 100644 index 000000000..65e87be09 --- /dev/null +++ b/src/rewrite/Mod.cpp @@ -0,0 +1,49 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// + +#include "Mod.h" + +//////////////////////////////////////////////////////////////////////////////// +Mod::Mod () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +Mod::~Mod () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +bool Mod::isRecognized () +{ + if (*this == ".is") + return true; + + return false; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Mod.h b/src/rewrite/Mod.h new file mode 100644 index 000000000..c18ad8c2e --- /dev/null +++ b/src/rewrite/Mod.h @@ -0,0 +1,42 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_MOD +#define INCLUDED_MOD + +#include + +class Mod : public std::string +{ +public: + Mod (); // Default constructor + ~Mod (); // Destructor + + bool isRecognized (); +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/StringTable.cpp b/src/rewrite/StringTable.cpp new file mode 100644 index 000000000..b4dd01299 --- /dev/null +++ b/src/rewrite/StringTable.cpp @@ -0,0 +1,59 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// + +#include "StringTable.h" + +//////////////////////////////////////////////////////////////////////////////// +StringTable::StringTable () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +StringTable::StringTable (const StringTable& other) +{ + throw std::string ("unimplemented StringTable::StringTable"); + mMapping = other.mMapping; +} + +//////////////////////////////////////////////////////////////////////////////// +StringTable& StringTable::operator= (const StringTable& other) +{ + throw std::string ("unimplemented StringTable::operator="); + if (this != &other) + { + mMapping = other.mMapping; + } + + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// +StringTable::~StringTable () +{ +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/StringTable.h b/src/rewrite/StringTable.h new file mode 100644 index 000000000..3a608fed5 --- /dev/null +++ b/src/rewrite/StringTable.h @@ -0,0 +1,46 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDED_STRINGTABLE +#define INCLUDED_STRINGTABLE + +#include +#include + +class StringTable +{ +public: + StringTable (); // Default constructor + StringTable (const StringTable&); // Copy constructor + StringTable& operator= (const StringTable&); // Assignment operator + ~StringTable (); // Destructor + +private: + std::map mMapping; +}; + +#endif +//////////////////////////////////////////////////////////////////////////////// From 78e9b00a63dbfce39287c9b3633e6e8bf2611b8b Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 23 May 2009 00:49:31 -0400 Subject: [PATCH 15/18] Snapshot --- src/rewrite/StringTable.cpp | 25 +++++++++++++++++++++++++ src/rewrite/StringTable.h | 5 ++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/rewrite/StringTable.cpp b/src/rewrite/StringTable.cpp index b4dd01299..9dac4626f 100644 --- a/src/rewrite/StringTable.cpp +++ b/src/rewrite/StringTable.cpp @@ -25,6 +25,7 @@ // //////////////////////////////////////////////////////////////////////////////// +#include #include "StringTable.h" //////////////////////////////////////////////////////////////////////////////// @@ -57,3 +58,27 @@ StringTable::~StringTable () } //////////////////////////////////////////////////////////////////////////////// +// [data.location] / language . XX +// UTF-8 encoding +// +// 123 This is the string +// 124 This is another string +// ... +void StringTable::load (const std::string& file) +{ + // TODO Load the specified file. +} + +//////////////////////////////////////////////////////////////////////////////// +std::string StringTable::get (int id) +{ + // Return the right string. + if (mMapping.find (id) != mMapping.end ()) + return mMapping[id]; + + std::stringstream error; + error << "MISSING " << id; + return error.str (); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/StringTable.h b/src/rewrite/StringTable.h index 3a608fed5..ef0080d97 100644 --- a/src/rewrite/StringTable.h +++ b/src/rewrite/StringTable.h @@ -38,8 +38,11 @@ public: StringTable& operator= (const StringTable&); // Assignment operator ~StringTable (); // Destructor + void load (const std::string&); + std::string get (int); + private: - std::map mMapping; + std::map mMapping; }; #endif From 1ad23c7bdc153d19c133c188f9f9eb9c730d0909 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 23 May 2009 09:30:52 -0400 Subject: [PATCH 16/18] FF4 - Mod object to handle attribute modifiers - New Mod object responsible for evaluating a chain of attribute modifiers. --- src/rewrite/Mod.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++-- src/rewrite/Mod.h | 5 ++++- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/rewrite/Mod.cpp b/src/rewrite/Mod.cpp index 65e87be09..3bfea6c5e 100644 --- a/src/rewrite/Mod.cpp +++ b/src/rewrite/Mod.cpp @@ -38,12 +38,63 @@ Mod::~Mod () } //////////////////////////////////////////////////////////////////////////////// -bool Mod::isRecognized () +// before after +// not +// none any +// over under +// synth +// first last +// this +// next +// is isnt +// has hasnt +// startswith endswith +bool Mod::isValid () { - if (*this == ".is") + if (*this == "before" || *this == "after" || + *this == "not" || + *this == "none" || *this == "any" || + *this == "synth" || + *this == "under" || *this == "over" || + *this == "first" || *this == "last" || + *this == "this" || + *this == "next" || + *this == "is" || *this == "isnt" || + *this == "has" || *this == "hasnt" || + *this == "startswith" || *this == "endswith") return true; return false; } //////////////////////////////////////////////////////////////////////////////// +bool Mod::eval (const Mod& other) +{ + // before + // after + // non + // none + // any + // synth + // under + // over + // first + // last + // this + // next + + if (*this == ".is") + return *this == other ? true : false; + + if (*this == ".isnt") + return *this != other ? true : false; + + // has + // hasnt + // startswith + // endswith + + return false; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/rewrite/Mod.h b/src/rewrite/Mod.h index c18ad8c2e..4e7e6e669 100644 --- a/src/rewrite/Mod.h +++ b/src/rewrite/Mod.h @@ -29,13 +29,16 @@ #include +class Mod; + class Mod : public std::string { public: Mod (); // Default constructor ~Mod (); // Destructor - bool isRecognized (); + bool isValid (); + bool eval (const Mod&); }; #endif From a9d46a0714dd4ec771bf6c7035863682f031a6e7 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 23 May 2009 09:38:31 -0400 Subject: [PATCH 17/18] FF4 - Moved new objects into place - Moved Mod, Att, Record, StringTable into place, ready for unit tests. --- src/.gitignore | 1 + src/{rewrite => }/Att.cpp | 0 src/{rewrite => }/Att.h | 0 src/Makefile.am | 2 +- src/Makefile.in | 438 ------------------------------ src/{rewrite => }/Mod.cpp | 0 src/{rewrite => }/Mod.h | 0 src/{rewrite => }/Record.cpp | 0 src/{rewrite => }/Record.h | 0 src/{rewrite => }/StringTable.cpp | 0 src/{rewrite => }/StringTable.h | 0 11 files changed, 2 insertions(+), 439 deletions(-) rename src/{rewrite => }/Att.cpp (100%) rename src/{rewrite => }/Att.h (100%) delete mode 100644 src/Makefile.in rename src/{rewrite => }/Mod.cpp (100%) rename src/{rewrite => }/Mod.h (100%) rename src/{rewrite => }/Record.cpp (100%) rename src/{rewrite => }/Record.h (100%) rename src/{rewrite => }/StringTable.cpp (100%) rename src/{rewrite => }/StringTable.h (100%) diff --git a/src/.gitignore b/src/.gitignore index 5761abcfd..1e4ffeb31 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1 +1,2 @@ *.o +Makefile.in diff --git a/src/rewrite/Att.cpp b/src/Att.cpp similarity index 100% rename from src/rewrite/Att.cpp rename to src/Att.cpp diff --git a/src/rewrite/Att.h b/src/Att.h similarity index 100% rename from src/rewrite/Att.h rename to src/Att.h diff --git a/src/Makefile.am b/src/Makefile.am index baff7fbb1..98250b935 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,2 +1,2 @@ bin_PROGRAMS = task -task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp Grid.cpp Timer.cpp Duration.cpp color.cpp parse.cpp task.cpp command.cpp edit.cpp report.cpp util.cpp text.cpp rules.cpp import.cpp Config.h Date.h T.h TDB.h Table.h Grid.h Timer.h Duration.h color.h task.h +task_SOURCES = Config.cpp Date.cpp Record.cpp T.cpp TDB.cpp Att.cpp Mod.cpp Table.cpp Grid.cpp Timer.cpp Duration.cpp StringTable.cpp color.cpp parse.cpp task.cpp command.cpp edit.cpp report.cpp util.cpp text.cpp rules.cpp import.cpp Config.h Date.h Record.h T.h TDB.h Att.h Mod.h Table.h Grid.h Timer.h Duration.h StringTable.h color.h task.h diff --git a/src/Makefile.in b/src/Makefile.in deleted file mode 100644 index a883c69a0..000000000 --- a/src/Makefile.in +++ /dev/null @@ -1,438 +0,0 @@ -# Makefile.in generated by automake 1.10 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -bin_PROGRAMS = task$(EXEEXT) -subdir = src -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/auto.h -CONFIG_CLEAN_FILES = -am__installdirs = "$(DESTDIR)$(bindir)" -binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) -PROGRAMS = $(bin_PROGRAMS) -am_task_OBJECTS = Config.$(OBJEXT) Date.$(OBJEXT) T.$(OBJEXT) \ - TDB.$(OBJEXT) Table.$(OBJEXT) Grid.$(OBJEXT) Timer.$(OBJEXT) \ - Duration.$(OBJEXT) color.$(OBJEXT) parse.$(OBJEXT) \ - task.$(OBJEXT) command.$(OBJEXT) edit.$(OBJEXT) \ - report.$(OBJEXT) util.$(OBJEXT) text.$(OBJEXT) rules.$(OBJEXT) \ - import.$(OBJEXT) -task_OBJECTS = $(am_task_OBJECTS) -task_LDADD = $(LDADD) -DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@ -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -CXXLD = $(CXX) -CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ - -o $@ -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = $(task_SOURCES) -DIST_SOURCES = $(task_SOURCES) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MKDIR_P = @MKDIR_P@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp Grid.cpp Timer.cpp Duration.cpp color.cpp parse.cpp task.cpp command.cpp edit.cpp report.cpp util.cpp text.cpp rules.cpp import.cpp Config.h Date.h T.h TDB.h Table.h Grid.h Timer.h Duration.h color.h task.h -all: all-am - -.SUFFIXES: -.SUFFIXES: .cpp .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -install-binPROGRAMS: $(bin_PROGRAMS) - @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" - @list='$(bin_PROGRAMS)'; for p in $$list; do \ - p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ - if test -f $$p \ - ; then \ - f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ - $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ - else :; fi; \ - done - -uninstall-binPROGRAMS: - @$(NORMAL_UNINSTALL) - @list='$(bin_PROGRAMS)'; for p in $$list; do \ - f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ - rm -f "$(DESTDIR)$(bindir)/$$f"; \ - done - -clean-binPROGRAMS: - -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) -task$(EXEEXT): $(task_OBJECTS) $(task_DEPENDENCIES) - @rm -f task$(EXEEXT) - $(CXXLINK) $(task_OBJECTS) $(task_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Config.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Date.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Duration.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/T.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TDB.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Table.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Timer.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/color.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/command.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edit.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/import.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/report.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rules.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/task.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/text.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Po@am__quote@ - -.cpp.o: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< - -.cpp.obj: -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: - for dir in "$(DESTDIR)$(bindir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-binPROGRAMS clean-generic mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-exec-am: install-binPROGRAMS - -install-html: install-html-am - -install-info: install-info-am - -install-man: - -install-pdf: install-pdf-am - -install-ps: install-ps-am - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-binPROGRAMS - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ - clean-generic ctags distclean distclean-compile \ - distclean-generic distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-binPROGRAMS \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ - uninstall-am uninstall-binPROGRAMS - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/rewrite/Mod.cpp b/src/Mod.cpp similarity index 100% rename from src/rewrite/Mod.cpp rename to src/Mod.cpp diff --git a/src/rewrite/Mod.h b/src/Mod.h similarity index 100% rename from src/rewrite/Mod.h rename to src/Mod.h diff --git a/src/rewrite/Record.cpp b/src/Record.cpp similarity index 100% rename from src/rewrite/Record.cpp rename to src/Record.cpp diff --git a/src/rewrite/Record.h b/src/Record.h similarity index 100% rename from src/rewrite/Record.h rename to src/Record.h diff --git a/src/rewrite/StringTable.cpp b/src/StringTable.cpp similarity index 100% rename from src/rewrite/StringTable.cpp rename to src/StringTable.cpp diff --git a/src/rewrite/StringTable.h b/src/StringTable.h similarity index 100% rename from src/rewrite/StringTable.h rename to src/StringTable.h From dd8b181081cac5ce8671529861886dc4707a2015 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 23 May 2009 09:42:52 -0400 Subject: [PATCH 18/18] FF4 - Renamed directory to 'objects' - Better name for new object directory. --- src/{rewrite => objects}/.gitignore | 0 src/{rewrite => objects}/Context.cpp | 0 src/{rewrite => objects}/Context.h | 0 src/{rewrite => objects}/Filter.cpp | 0 src/{rewrite => objects}/Filter.h | 0 src/{rewrite => objects}/Keymap.cpp | 0 src/{rewrite => objects}/Keymap.h | 0 src/{rewrite => objects}/Sequence.cpp | 0 src/{rewrite => objects}/Sequence.h | 0 src/{rewrite => objects}/T.cpp | 0 src/{rewrite => objects}/T.h | 0 src/{rewrite => objects}/TDB.cpp | 0 src/{rewrite => objects}/TDB.h | 0 src/{rewrite => objects}/main.cpp | 0 src/rewrite/Makefile | 25 ------------------------- 15 files changed, 25 deletions(-) rename src/{rewrite => objects}/.gitignore (100%) rename src/{rewrite => objects}/Context.cpp (100%) rename src/{rewrite => objects}/Context.h (100%) rename src/{rewrite => objects}/Filter.cpp (100%) rename src/{rewrite => objects}/Filter.h (100%) rename src/{rewrite => objects}/Keymap.cpp (100%) rename src/{rewrite => objects}/Keymap.h (100%) rename src/{rewrite => objects}/Sequence.cpp (100%) rename src/{rewrite => objects}/Sequence.h (100%) rename src/{rewrite => objects}/T.cpp (100%) rename src/{rewrite => objects}/T.h (100%) rename src/{rewrite => objects}/TDB.cpp (100%) rename src/{rewrite => objects}/TDB.h (100%) rename src/{rewrite => objects}/main.cpp (100%) delete mode 100644 src/rewrite/Makefile diff --git a/src/rewrite/.gitignore b/src/objects/.gitignore similarity index 100% rename from src/rewrite/.gitignore rename to src/objects/.gitignore diff --git a/src/rewrite/Context.cpp b/src/objects/Context.cpp similarity index 100% rename from src/rewrite/Context.cpp rename to src/objects/Context.cpp diff --git a/src/rewrite/Context.h b/src/objects/Context.h similarity index 100% rename from src/rewrite/Context.h rename to src/objects/Context.h diff --git a/src/rewrite/Filter.cpp b/src/objects/Filter.cpp similarity index 100% rename from src/rewrite/Filter.cpp rename to src/objects/Filter.cpp diff --git a/src/rewrite/Filter.h b/src/objects/Filter.h similarity index 100% rename from src/rewrite/Filter.h rename to src/objects/Filter.h diff --git a/src/rewrite/Keymap.cpp b/src/objects/Keymap.cpp similarity index 100% rename from src/rewrite/Keymap.cpp rename to src/objects/Keymap.cpp diff --git a/src/rewrite/Keymap.h b/src/objects/Keymap.h similarity index 100% rename from src/rewrite/Keymap.h rename to src/objects/Keymap.h diff --git a/src/rewrite/Sequence.cpp b/src/objects/Sequence.cpp similarity index 100% rename from src/rewrite/Sequence.cpp rename to src/objects/Sequence.cpp diff --git a/src/rewrite/Sequence.h b/src/objects/Sequence.h similarity index 100% rename from src/rewrite/Sequence.h rename to src/objects/Sequence.h diff --git a/src/rewrite/T.cpp b/src/objects/T.cpp similarity index 100% rename from src/rewrite/T.cpp rename to src/objects/T.cpp diff --git a/src/rewrite/T.h b/src/objects/T.h similarity index 100% rename from src/rewrite/T.h rename to src/objects/T.h diff --git a/src/rewrite/TDB.cpp b/src/objects/TDB.cpp similarity index 100% rename from src/rewrite/TDB.cpp rename to src/objects/TDB.cpp diff --git a/src/rewrite/TDB.h b/src/objects/TDB.h similarity index 100% rename from src/rewrite/TDB.h rename to src/objects/TDB.h diff --git a/src/rewrite/main.cpp b/src/objects/main.cpp similarity index 100% rename from src/rewrite/main.cpp rename to src/objects/main.cpp diff --git a/src/rewrite/Makefile b/src/rewrite/Makefile deleted file mode 100644 index d6518d60f..000000000 --- a/src/rewrite/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -PROJECT = 1.8 -CFLAGS = -I. -I.. -Wall -pedantic -ggdb3 -fno-rtti -fstack-check -LFLAGS = -LIBS = -OBJECTS = main.o Context.o TDB.o T.o Sequence.o Filter.o Att.o Keymap.o \ - Record.o Mod.o StringTable.o ../util.o ../text.o ../Config.o \ - ../Date.o - -all: $(PROJECT) - -install: $(PROJECT) - @echo unimplemented - -test: $(PROJECT) - @echo unimplemented - -clean: - -rm *.o $(PROJECT) - -.cpp.o: $(INCLUDE) - g++ -c $(CFLAGS) $< - -$(PROJECT): $(OBJECTS) - g++ $(OBJECTS) $(LFLAGS) $(LIBS) -o $(PROJECT) -