mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Merge branch 'ff4' into 1.8.0
This commit is contained in:
commit
df3fc9b723
46 changed files with 2164 additions and 173 deletions
|
@ -13,6 +13,7 @@ included.
|
|||
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.
|
||||
|
|
1
src/.gitignore
vendored
1
src/.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
*.o
|
||||
Makefile.in
|
||||
|
|
238
src/Att.cpp
Normal file
238
src/Att.cpp
Normal file
|
@ -0,0 +1,238 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 ()
|
||||
: mName ("")
|
||||
, mValue ("")
|
||||
{
|
||||
mMods.clear ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Att::Att (const std::string& name, const std::string& value)
|
||||
{
|
||||
throw std::string ("unimplemented Att::Att");
|
||||
mName = name;
|
||||
mValue = value;
|
||||
|
||||
mMods.clear ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Att::Att (const Att& other)
|
||||
{
|
||||
throw std::string ("unimplemented Att::Att");
|
||||
mName = other.mName;
|
||||
mValue = other.mValue;
|
||||
mMods = other.mMods;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Att& Att::operator= (const Att& other)
|
||||
{
|
||||
throw std::string ("unimplemented Att::operator=");
|
||||
if (this != &other)
|
||||
{
|
||||
mName = other.mName;
|
||||
mValue = other.mValue;
|
||||
mMods = other.mMods;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Att::~Att ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Parse the following forms:
|
||||
// name [[.mod] ...] : [value]
|
||||
void Att::parse (const std::string& input)
|
||||
{
|
||||
throw std::string ("unimplemented Att::parse");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// name : " value "
|
||||
std::string Att::composeF4 () const
|
||||
{
|
||||
std::string value = mValue;
|
||||
encode (value);
|
||||
enquote (value);
|
||||
|
||||
return mName + ":" + value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Att::addMod (const std::string&)
|
||||
{
|
||||
throw std::string ("unimplemented Att::addMod");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
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 Att::value_int");
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Att::value_int (int)
|
||||
{
|
||||
throw std::string ("unimplemented Att::value_int");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Att::filter () const
|
||||
{
|
||||
throw std::string ("unimplemented filter");
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Att::required () const
|
||||
{
|
||||
throw std::string ("unimplemented Att::required");
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Att::reserved () const
|
||||
{
|
||||
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;
|
||||
// " -> "
|
||||
// , -> ,
|
||||
// [ -> &open;
|
||||
// ] -> &close;
|
||||
// : -> :
|
||||
void Att::encode (std::string& value) const
|
||||
{
|
||||
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, ":");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Decode values after parse.
|
||||
// \t <- &tab;
|
||||
// " <- "
|
||||
// , <- ,
|
||||
// [ <- &open;
|
||||
// ] <- &close;
|
||||
// : <- :
|
||||
void Att::decode (std::string& value) const
|
||||
{
|
||||
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, ":");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
73
src/Att.h
Normal file
73
src/Att.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Att
|
||||
{
|
||||
public:
|
||||
Att (); // Default constructor
|
||||
Att (const std::string&, const std::string&); // Simple constructor
|
||||
Att (const Att&); // Copy constructor
|
||||
Att& operator= (const Att&); // Assignment operator
|
||||
~Att (); // Destructor
|
||||
|
||||
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 reserved () const;
|
||||
|
||||
private:
|
||||
void enquote (std::string&) const;
|
||||
void dequote (std::string&) const;
|
||||
void encode (std::string&) const;
|
||||
void decode (std::string&) const;
|
||||
|
||||
private:
|
||||
std::string mName;
|
||||
std::string mValue;
|
||||
std::vector <std::string> mMods;
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -32,8 +32,9 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <pwd.h>
|
||||
#include "task.h"
|
||||
#include "Config.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// These are default (but overridable) reports. These entries are necessary
|
||||
|
|
|
@ -28,8 +28,9 @@
|
|||
#include <time.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include "task.h"
|
||||
#include "Date.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Defaults to "now".
|
||||
|
|
160
src/Duration.cpp
Normal file
160
src/Duration.cpp
Normal file
|
@ -0,0 +1,160 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <vector>
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
#include "Duration.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration::Duration ()
|
||||
: mDays (0)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration::Duration (const Duration& other)
|
||||
{
|
||||
throw std::string ("unimplemented Duration::Duration");
|
||||
mDays = other.mDays;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration::Duration (const std::string& input)
|
||||
{
|
||||
parse (input);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration& Duration::operator= (const Duration& other)
|
||||
{
|
||||
throw std::string ("unimplemented Duration::operator=");
|
||||
if (this != &other)
|
||||
{
|
||||
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 ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Duration::parse (const std::string& input)
|
||||
{
|
||||
std::string lower_input = lowerCase (input);
|
||||
|
||||
std::vector <std::string> 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 <std::string> 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.";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
54
src/Duration.h
Normal file
54
src/Duration.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
|
||||
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:
|
||||
time_t mDays;
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -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 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
|
||||
|
|
100
src/Mod.cpp
Normal file
100
src/Mod.cpp
Normal file
|
@ -0,0 +1,100 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// before after
|
||||
// not
|
||||
// none any
|
||||
// over under
|
||||
// synth
|
||||
// first last
|
||||
// this
|
||||
// next
|
||||
// is isnt
|
||||
// has hasnt
|
||||
// startswith endswith
|
||||
bool Mod::isValid ()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
45
src/Mod.h
Normal file
45
src/Mod.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <string>
|
||||
|
||||
class Mod;
|
||||
|
||||
class Mod : public std::string
|
||||
{
|
||||
public:
|
||||
Mod (); // Default constructor
|
||||
~Mod (); // Destructor
|
||||
|
||||
bool isValid ();
|
||||
bool eval (const Mod&);
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
65
src/Record.cpp
Normal file
65
src/Record.cpp
Normal file
|
@ -0,0 +1,65 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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)
|
||||
{
|
||||
throw std::string ("unimplemented Record::Record");
|
||||
mAtts = other.mAtts;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Record& Record::operator= (const Record& other)
|
||||
{
|
||||
throw std::string ("unimplemented Record:operator=");
|
||||
if (this != &other)
|
||||
{
|
||||
mAtts = other.mAtts;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Record::~Record ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Record::parse (const std::string& input)
|
||||
{
|
||||
throw std::string ("unimplemented Record::parse");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
50
src/Record.h
Normal file
50
src/Record.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
|
||||
#include <vector>
|
||||
#include "Att.h"
|
||||
|
||||
class Record
|
||||
{
|
||||
public:
|
||||
Record (); // Default constructor
|
||||
Record (const Record&); // Copy constructor
|
||||
Record& operator= (const Record&); // Assignment operator
|
||||
virtual ~Record (); // Destructor
|
||||
|
||||
virtual std::string composeF4 () = 0;
|
||||
virtual std::string composeCSV () = 0;
|
||||
void parse (const std::string&);
|
||||
|
||||
private:
|
||||
std::vector <Att> mAtts;
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
84
src/StringTable.cpp
Normal file
84
src/StringTable.cpp
Normal file
|
@ -0,0 +1,84 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <sstream>
|
||||
#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 ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// [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 ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
49
src/StringTable.h
Normal file
49
src/StringTable.h
Normal file
|
@ -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_STRINGTABLE
|
||||
#define INCLUDED_STRINGTABLE
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
class StringTable
|
||||
{
|
||||
public:
|
||||
StringTable (); // Default constructor
|
||||
StringTable (const StringTable&); // Copy constructor
|
||||
StringTable& operator= (const StringTable&); // Assignment operator
|
||||
~StringTable (); // Destructor
|
||||
|
||||
void load (const std::string&);
|
||||
std::string get (int);
|
||||
|
||||
private:
|
||||
std::map <int, std::string> mMapping;
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -27,8 +27,9 @@
|
|||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include "task.h"
|
||||
#include "T.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Default
|
||||
|
|
|
@ -31,8 +31,9 @@
|
|||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "task.h"
|
||||
#include "T.h"
|
||||
#include "TDB.h"
|
||||
#include "util.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
TDB::TDB ()
|
||||
|
|
|
@ -48,7 +48,9 @@
|
|||
#include <assert.h>
|
||||
#include <Table.h>
|
||||
#include <Date.h>
|
||||
#include <task.h>
|
||||
#include <Duration.h>
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Table::Table ()
|
||||
|
@ -989,7 +991,7 @@ void Table::sort (std::vector <int>& 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 +1000,7 @@ void Table::sort (std::vector <int>& 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;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
#include <pwd.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "T.h"
|
||||
#include "TDB.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
#include "task.h"
|
||||
|
||||
#ifdef HAVE_LIBNCURSES
|
||||
|
|
|
@ -33,6 +33,11 @@
|
|||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include "T.h"
|
||||
#include "TDB.h"
|
||||
#include "Date.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
#include "task.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "Date.h"
|
||||
#include "T.h"
|
||||
#include "TDB.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
#include "task.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
1
src/objects/.gitignore
vendored
Normal file
1
src/objects/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
1.8
|
151
src/objects/Context.cpp
Normal file
151
src/objects/Context.cpp
Normal file
|
@ -0,0 +1,151 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <pwd.h>
|
||||
#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
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Context::Context (const Context& other)
|
||||
{
|
||||
throw std::string ("unimplemented Context::Context");
|
||||
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 Context::operator=");
|
||||
if (this != &other)
|
||||
{
|
||||
config = other.config;
|
||||
filter = other.filter;
|
||||
keymap = other.keymap;
|
||||
sequence = other.sequence;
|
||||
task = other.task;
|
||||
tdb = other.tdb;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Context::~Context ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Context::initialize (int argc, char** argv)
|
||||
{
|
||||
// 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.
|
||||
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 <std::string> all;
|
||||
split (all, location, ',');
|
||||
foreach (path, all)
|
||||
tdb.location (expandPath (*path));
|
||||
|
||||
// Allow user override of file locking. Solaris/NFS machines may want this.
|
||||
tdb.lock (config.get ("locking", true));
|
||||
|
||||
// TODO Load pending.data.
|
||||
// TODO Load completed.data.
|
||||
// TODO Load deleted.data.
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int 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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
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);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
64
src/objects/Context.h
Normal file
64
src/objects/Context.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 "T.h"
|
||||
#include "TDB.h"
|
||||
|
||||
|
||||
class Context
|
||||
{
|
||||
public:
|
||||
Context (); // Default constructor
|
||||
Context (const Context&); // Copy constructor
|
||||
Context& operator= (const Context&); // Assignment operator
|
||||
~Context (); // Destructor
|
||||
|
||||
void initialize (int, char**);
|
||||
int run ();
|
||||
|
||||
private:
|
||||
void loadCorrectConfigFile (int, char**);
|
||||
|
||||
public:
|
||||
Config config;
|
||||
Filter filter;
|
||||
Keymap keymap;
|
||||
Sequence sequence;
|
||||
T task;
|
||||
TDB tdb;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
78
src/objects/Filter.cpp
Normal file
78
src/objects/Filter.cpp
Normal file
|
@ -0,0 +1,78 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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)
|
||||
{
|
||||
throw std::string ("unimplemented Filter::Filter");
|
||||
mAtts = other.mAtts;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Filter& Filter::operator= (const Filter& other)
|
||||
{
|
||||
throw std::string ("unimplemented Filter::operator=");
|
||||
if (this != &other)
|
||||
{
|
||||
mAtts = other.mAtts;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Filter::~Filter ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Filter::add (Att& att)
|
||||
{
|
||||
mAtts.push_back (att);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Filter::pass (Record& record)
|
||||
{
|
||||
throw std::string ("unimplemented Filter::pass");
|
||||
/*
|
||||
foreach (att, mAtts)
|
||||
if (! att->match (record))
|
||||
return false;
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
50
src/objects/Filter.h
Normal file
50
src/objects/Filter.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
|
||||
#include <vector>
|
||||
#include "Att.h"
|
||||
#include "Record.h"
|
||||
|
||||
class Filter
|
||||
{
|
||||
public:
|
||||
Filter (); // Default constructor
|
||||
Filter (const Filter&); // Copy constructor
|
||||
Filter& operator= (const Filter&); // Assignment operator
|
||||
~Filter (); // Destructor
|
||||
|
||||
void add (Att&);
|
||||
bool pass (Record&);
|
||||
|
||||
private:
|
||||
std::vector <Att> mAtts;
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
66
src/objects/Keymap.cpp
Normal file
66
src/objects/Keymap.cpp
Normal file
|
@ -0,0 +1,66 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <string>
|
||||
#include "Keymap.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Keymap::Keymap ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Keymap::Keymap (const Keymap& other)
|
||||
{
|
||||
throw std::string ("unimplemented Keymap::Keymap");
|
||||
// mOne = other.mOne;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Keymap& Keymap::operator= (const Keymap& other)
|
||||
{
|
||||
throw std::string ("unimplemented Keymap::operator=");
|
||||
if (this != &other)
|
||||
{
|
||||
// mOne = other.mOne;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Keymap::~Keymap ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Keymap::load (const std::string& file)
|
||||
{
|
||||
throw std::string ("unimplemented Keymap::load");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
51
src/objects/Keymap.h
Normal file
51
src/objects/Keymap.h
Normal file
|
@ -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_KEYMAP
|
||||
#define INCLUDED_KEYMAP
|
||||
|
||||
#include <string>
|
||||
|
||||
class Keymap
|
||||
{
|
||||
public:
|
||||
Keymap (); // Default constructor
|
||||
Keymap (const Keymap&); // Copy constructor
|
||||
Keymap& operator= (const Keymap&); // Assignment operator
|
||||
~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
|
||||
////////////////////////////////////////////////////////////////////////////////
|
64
src/objects/Sequence.cpp
Normal file
64
src/objects/Sequence.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <string>
|
||||
#include "Sequence.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Sequence::Sequence ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Sequence::Sequence (const Sequence& other)
|
||||
{
|
||||
throw std::string ("unimplemented Sequence::Sequence");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Sequence& Sequence::operator= (const Sequence& other)
|
||||
{
|
||||
throw std::string ("unimplemented Sequence::operator=");
|
||||
if (this != &other)
|
||||
{
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Sequence::~Sequence ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Sequence::parse (const std::string& input)
|
||||
{
|
||||
throw std::string ("unimplemented Sequence::parse");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
45
src/objects/Sequence.h
Normal file
45
src/objects/Sequence.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class Sequence : public std::vector <int>
|
||||
{
|
||||
public:
|
||||
Sequence (); // Default constructor
|
||||
Sequence (const Sequence&); // Copy constructor
|
||||
Sequence& operator= (const Sequence&); // Assignment operator
|
||||
~Sequence (); // Destructor
|
||||
|
||||
void parse (const std::string&);
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
74
src/objects/T.cpp
Normal file
74
src/objects/T.cpp
Normal file
|
@ -0,0 +1,74 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <string>
|
||||
#include "T.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
T::T ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
T::T (const std::string& input)
|
||||
{
|
||||
throw std::string ("unimplemented T::T");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
T& T::operator= (const T& other)
|
||||
{
|
||||
throw std::string ("unimplemented T::operator=");
|
||||
if (this != &other)
|
||||
{
|
||||
// mOne = other.mOne;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
T::~T ()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// [name:value, name:"value",name:[name:value,name:value]]
|
||||
std::string T::composeF4 ()
|
||||
{
|
||||
throw std::string ("unimplemented T::composeF4");
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string T::composeCSV ()
|
||||
{
|
||||
throw std::string ("unimplemented T::composeCSV");
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
48
src/objects/T.h
Normal file
48
src/objects/T.h
Normal file
|
@ -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_T
|
||||
#define INCLUDED_T
|
||||
|
||||
#include <string>
|
||||
#include "Record.h"
|
||||
|
||||
class T : public Record
|
||||
{
|
||||
public:
|
||||
T (); // Default constructor
|
||||
T (const std::string&); // Parse
|
||||
T& operator= (const T&); // Assignment operator
|
||||
~T (); // Destructor
|
||||
|
||||
std::string composeF4 ();
|
||||
std::string composeCSV ();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
232
src/objects/TDB.cpp
Normal file
232
src/objects/TDB.cpp
Normal file
|
@ -0,0 +1,232 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <string>
|
||||
#include <sys/file.h>
|
||||
#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)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
TDB::TDB (const TDB& other)
|
||||
{
|
||||
throw std::string ("unimplemented TDB::TDB");
|
||||
mLocations = other.mLocations;
|
||||
mLock = other.mLock;
|
||||
mAllOpenAndLocked = false; // Deliberately so.
|
||||
|
||||
// Set all to NULL.
|
||||
foreach (location, mLocations)
|
||||
mLocations[location->first] = NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
TDB& TDB::operator= (const TDB& other)
|
||||
{
|
||||
throw std::string ("unimplemented TDB::operator=");
|
||||
if (this != &other)
|
||||
{
|
||||
mLocations = other.mLocations;
|
||||
mLock = other.mLock;
|
||||
mAllOpenAndLocked = false; // Deliberately so.
|
||||
|
||||
// Set all to NULL.
|
||||
foreach (location, mLocations)
|
||||
mLocations[location->first] = NULL;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
TDB::~TDB ()
|
||||
{
|
||||
if (mAllOpenAndLocked)
|
||||
unlock ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TDB::location (const std::string& path)
|
||||
{
|
||||
if (access (expandPath (path).c_str (), F_OK))
|
||||
throw std::string ("Data location '") +
|
||||
path +
|
||||
"' does not exist, or is not readable and writable.";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TODO Returns number of filtered tasks.
|
||||
int TDB::load (std::vector <T>& 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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TODO Write to transaction log.
|
||||
void TDB::add (T& after)
|
||||
{
|
||||
throw std::string ("unimplemented TDB::add");
|
||||
|
||||
// TODO Seek to end of pending.
|
||||
// TODO write after.composeFF4 ().
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TODO Write to transaction log.
|
||||
void TDB::update (T& before, T& after)
|
||||
{
|
||||
throw std::string ("unimplemented TDB::update");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TODO writes all, including comments
|
||||
int TDB::commit ()
|
||||
{
|
||||
throw std::string ("unimplemented TDB::commit");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TODO -> FF4
|
||||
void TDB::upgrade ()
|
||||
{
|
||||
throw std::string ("unimplemented TDB::upgrade");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TDB::getPendingFiles (std::vector <std::string> files)
|
||||
{
|
||||
files.clear ();
|
||||
|
||||
foreach (location, mLocations)
|
||||
files.push_back (location->first + "/pending.data");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TDB::getCompletedFiles (std::vector <std::string> files)
|
||||
{
|
||||
files.clear ();
|
||||
|
||||
foreach (location, mLocations)
|
||||
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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
69
src/objects/TDB.h
Normal file
69
src/objects/TDB.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "Filter.h"
|
||||
#include "T.h"
|
||||
|
||||
class TDB
|
||||
{
|
||||
public:
|
||||
TDB (); // Default constructor
|
||||
TDB (const TDB&); // Copy constructor
|
||||
TDB& operator= (const TDB&); // Assignment operator
|
||||
~TDB (); // Destructor
|
||||
|
||||
void location (const std::string&);
|
||||
|
||||
void lock (bool lockFile = true);
|
||||
void unlock ();
|
||||
|
||||
int load (std::vector <T>&, Filter&);
|
||||
void add (T&);
|
||||
void update (T&, T&);
|
||||
int commit ();
|
||||
void upgrade ();
|
||||
|
||||
private:
|
||||
void getPendingFiles (std::vector <std::string>);
|
||||
void getCompletedFiles (std::vector <std::string>);
|
||||
FILE* openAndLock (const std::string&);
|
||||
|
||||
private:
|
||||
std::map <std::string, FILE*> mLocations;
|
||||
bool mLock;
|
||||
bool mAllOpenAndLocked;
|
||||
|
||||
// TODO Need cache of raw file contents.
|
||||
};
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
30
src/objects/main.cpp
Normal file
30
src/objects/main.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "Context.h"
|
||||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
try
|
||||
{
|
||||
Context c;
|
||||
c.initialize (argc, argv);
|
||||
c.run ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
catch (std::string e)
|
||||
{
|
||||
std::cerr << e << std::endl;
|
||||
}
|
||||
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "task internal error." << std::endl;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -31,8 +31,10 @@
|
|||
#include <map>
|
||||
|
||||
#include "Date.h"
|
||||
#include "task.h"
|
||||
#include "Duration.h"
|
||||
#include "T.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// NOTE: These are static arrays only because there is no initializer list for
|
||||
|
@ -445,7 +447,9 @@ static bool validSubstitution (
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool validDuration (std::string& input)
|
||||
{
|
||||
return (convertDuration (input) != 0) ? true : false;
|
||||
try { Duration (input); }
|
||||
catch (...) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <std::string, Text::color> gsFg;
|
||||
static std::map <std::string, Text::color> gsBg;
|
||||
|
|
|
@ -38,9 +38,12 @@
|
|||
|
||||
#include "Config.h"
|
||||
#include "Date.h"
|
||||
#include "Duration.h"
|
||||
#include "Table.h"
|
||||
#include "TDB.h"
|
||||
#include "T.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
#include "task.h"
|
||||
|
||||
#ifdef HAVE_LIBNCURSES
|
||||
|
@ -717,7 +720,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);
|
||||
}
|
||||
|
||||
|
|
56
src/task.h
56
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>&, 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 <std::string>&);
|
||||
void validSortColumns (const std::vector <std::string>&, const std::vector <std::string>&);
|
||||
|
||||
// text.cpp
|
||||
void wrapText (std::vector <std::string>&, 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<std::string>&, const std::string&, const char);
|
||||
void split (std::vector<std::string>&, const std::string&, const std::string&);
|
||||
void join (std::string&, const std::string&, const std::vector<std::string>&);
|
||||
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::string>&, std::vector<std::string>&);
|
||||
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 <std::string>&, 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&);
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -25,9 +25,8 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include <Date.h>
|
||||
#include <Duration.h>
|
||||
#include <test.h>
|
||||
#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;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "task.h"
|
||||
#include "Config.h"
|
||||
#include "util.h"
|
||||
#include "text.h"
|
||||
|
||||
static const char* newline = "\n";
|
||||
static const char* noline = "";
|
||||
|
|
51
src/text.h
Normal file
51
src/text.h
Normal file
|
@ -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 <string>
|
||||
#include <vector>
|
||||
#include "Config.h"
|
||||
#include "../auto.h"
|
||||
|
||||
// text.cpp
|
||||
void wrapText (std::vector <std::string>&, 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<std::string>&, const std::string&, const char);
|
||||
void split (std::vector<std::string>&, const std::string&, const std::string&);
|
||||
void join (std::string&, const std::string&, const std::vector<std::string>&);
|
||||
std::string commify (const std::string&);
|
||||
std::string lowerCase (const std::string&);
|
||||
std::string upperCase (const std::string&);
|
||||
const char* optionalBlankLine (Config&);
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
71
src/util.cpp
71
src/util.cpp
|
@ -38,6 +38,9 @@
|
|||
#include <errno.h>
|
||||
#include "Date.h"
|
||||
#include "Table.h"
|
||||
#include "T.h"
|
||||
#include "TDB.h"
|
||||
#include "text.h"
|
||||
#include "task.h"
|
||||
#include "../auto.h"
|
||||
|
||||
|
@ -280,74 +283,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 <std::string> 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 <std::string> 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)
|
||||
{
|
||||
|
|
76
src/util.h
Normal file
76
src/util.h
Normal file
|
@ -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 <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sys/types.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)
|
||||
|
||||
// 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::string>&, std::vector<std::string>&);
|
||||
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 <std::string>&, bool trimLines = false);
|
||||
bool slurp (const std::string&, std::string&, bool trimLines = false);
|
||||
void spit (const std::string&, const std::string&);
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
Loading…
Add table
Add a link
Reference in a new issue