Code Cleanup

- Integrated Context.config.
- Eliminated Config& as a function argument.
- Added extern references to Context where needed.
This commit is contained in:
Paul Beckingham
2009-06-03 02:03:49 -04:00
parent 98978c7c00
commit 66bd5fc3c0
29 changed files with 1115 additions and 451 deletions

View File

@@ -30,12 +30,15 @@
#include <vector>
#include <map>
#include "Context.h"
#include "Date.h"
#include "Duration.h"
#include "T.h"
#include "text.h"
#include "util.h"
extern Context context;
////////////////////////////////////////////////////////////////////////////////
// NOTE: These are static arrays only because there is no initializer list for
// std::vector.
@@ -220,9 +223,9 @@ static bool isCommand (const std::string& candidate)
}
////////////////////////////////////////////////////////////////////////////////
bool validDate (std::string& date, Config& conf)
bool validDate (std::string& date)
{
Date test (date, conf.get ("dateformat", "m/d/Y"));
Date test (date, context.config.get ("dateformat", "m/d/Y"));
char epoch[16];
sprintf (epoch, "%d", (int) test.toEpoch ());
@@ -248,8 +251,7 @@ bool validPriority (const std::string& input)
////////////////////////////////////////////////////////////////////////////////
static bool validAttribute (
std::string& name,
std::string& value,
Config& conf)
std::string& value)
{
guess ("attribute", attributes, name);
if (name != "")
@@ -258,10 +260,10 @@ static bool validAttribute (
guess ("color", colors, value);
else if (name == "due" && value != "")
validDate (value, conf);
validDate (value);
else if (name == "until" && value != "")
validDate (value, conf);
validDate (value);
else if (name == "priority")
{
@@ -456,8 +458,7 @@ bool validDuration (std::string& input)
void parse (
std::vector <std::string>& args,
std::string& command,
T& task,
Config& conf)
T& task)
{
command = "";
@@ -518,7 +519,7 @@ void parse (
std::string name = lowerCase (arg.substr (0, colon));
std::string value = arg.substr (colon + 1, std::string::npos);
if (validAttribute (name, value, conf))
if (validAttribute (name, value))
{
if (name != "recur" || validDuration (value))
task.setAttribute (name, value);
@@ -589,10 +590,10 @@ void parse (
}
////////////////////////////////////////////////////////////////////////////////
void loadCustomReports (Config& conf)
void loadCustomReports ()
{
std::vector <std::string> all;
conf.all (all);
context.config.all (all);
foreach (i, all)
{