Code Cleanup
- Assorted minor edits. - Snapshot before E9 work.
This commit is contained in:
@@ -1059,6 +1059,7 @@ bool Arguments::is_symbol_operator (const std::string& input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Canonicalize attribute names.
|
||||||
bool Arguments::is_attribute (const std::string& input, std::string& canonical)
|
bool Arguments::is_attribute (const std::string& input, std::string& canonical)
|
||||||
{
|
{
|
||||||
// Guess at the full attribute name.
|
// Guess at the full attribute name.
|
||||||
|
|||||||
28
src/DOM.cpp
28
src/DOM.cpp
@@ -27,10 +27,12 @@
|
|||||||
|
|
||||||
#define L10N // Localization complete.
|
#define L10N // Localization complete.
|
||||||
|
|
||||||
//#include <iostream> // TODO Remove
|
#include <iostream> // TODO Remove
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <Nibbler.h>
|
#include <Nibbler.h>
|
||||||
|
#include <Date.h>
|
||||||
|
#include <Duration.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
#include <DOM.h>
|
#include <DOM.h>
|
||||||
@@ -64,7 +66,6 @@ DOM::~DOM ()
|
|||||||
// context.width
|
// context.width
|
||||||
// context.height
|
// context.height
|
||||||
//
|
//
|
||||||
// TODO report.<name>. <-- context.reports
|
|
||||||
// TODO stats.<name> <-- context.stats
|
// TODO stats.<name> <-- context.stats
|
||||||
//
|
//
|
||||||
// system.version
|
// system.version
|
||||||
@@ -102,9 +103,7 @@ const std::string DOM::get (const std::string& name)
|
|||||||
|
|
||||||
else if (name == "context.args")
|
else if (name == "context.args")
|
||||||
{
|
{
|
||||||
std::string combined;
|
return /*_cache[name] =*/ context.args.combine ();
|
||||||
join (combined, " ", context.args.list ());
|
|
||||||
return /*_cache[name] =*/ combined;
|
|
||||||
}
|
}
|
||||||
else if (name == "context.width")
|
else if (name == "context.width")
|
||||||
{
|
{
|
||||||
@@ -123,7 +122,6 @@ const std::string DOM::get (const std::string& name)
|
|||||||
throw format (STRING_DOM_UNREC, name);
|
throw format (STRING_DOM_UNREC, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO report.
|
|
||||||
// TODO stats.<name>
|
// TODO stats.<name>
|
||||||
|
|
||||||
// system. --> Implement locally.
|
// system. --> Implement locally.
|
||||||
@@ -226,8 +224,6 @@ const std::string DOM::get (const std::string& name, const Task& task)
|
|||||||
if (n.skip ('.'))
|
if (n.skip ('.'))
|
||||||
{
|
{
|
||||||
// TODO Obtain task 'id' from TDB2.
|
// TODO Obtain task 'id' from TDB2.
|
||||||
// std::cout << "# DOM::get " << name << "\n";
|
|
||||||
|
|
||||||
std::string attr;
|
std::string attr;
|
||||||
n.getUntilEOS (attr);
|
n.getUntilEOS (attr);
|
||||||
|
|
||||||
@@ -243,8 +239,6 @@ const std::string DOM::get (const std::string& name, const Task& task)
|
|||||||
if (n.skip ('.'))
|
if (n.skip ('.'))
|
||||||
{
|
{
|
||||||
// TODO Obtain task 'uuid' from TDB2.
|
// TODO Obtain task 'uuid' from TDB2.
|
||||||
// std::cout << "# DOM::get name\n";
|
|
||||||
|
|
||||||
std::string attr;
|
std::string attr;
|
||||||
n.getUntilEOS (attr);
|
n.getUntilEOS (attr);
|
||||||
|
|
||||||
@@ -255,14 +249,11 @@ const std::string DOM::get (const std::string& name, const Task& task)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// [<task>.] <name>
|
// [<task>.] <name>
|
||||||
// std::cout << "# DOM::get " << name << "\n";
|
|
||||||
|
|
||||||
if (name == "id") return format (task.id);
|
if (name == "id") return format (task.id);
|
||||||
else if (name == "urgency") return format (task.urgency_c (), 4, 3);
|
else if (name == "urgency") return format (task.urgency_c (), 4, 3);
|
||||||
else return task.get (name);
|
else return task.get (name);
|
||||||
|
|
||||||
// Delegate to the context-free version of DOM::get.
|
// Delegate to the context-free version of DOM::get.
|
||||||
// std::cout << "# DOM::get delegate...\n";
|
|
||||||
return this->get (name);
|
return this->get (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,9 +281,15 @@ bool DOM::is_primitive (const std::string& input)
|
|||||||
double d;
|
double d;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// TODO Date?
|
// Date?
|
||||||
|
if (Date::valid (input, context.config.get ("dateformat")))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Duration?
|
||||||
|
if (Duration::valid (input))
|
||||||
|
return true;
|
||||||
|
|
||||||
// TODO Quoted Date?
|
// TODO Quoted Date?
|
||||||
// TODO Duration?
|
|
||||||
// TODO Quoted Duration?
|
// TODO Quoted Duration?
|
||||||
|
|
||||||
// String?
|
// String?
|
||||||
@@ -312,6 +309,7 @@ bool DOM::is_primitive (const std::string& input)
|
|||||||
if (n.getInt (i) && n.depleted ())
|
if (n.getInt (i) && n.depleted ())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
std::cout << "# DOM::is_primitive '" << input << "' --> unknown\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -446,7 +446,7 @@ void Expression::create_variant (
|
|||||||
variant = Variant (unquoteText (value));
|
variant = Variant (unquoteText (value));
|
||||||
|
|
||||||
else
|
else
|
||||||
throw std::string ("Unrecognized operand '") + + "'.";
|
throw std::string ("Unrecognized operand '") + type + "'.";
|
||||||
|
|
||||||
variant._raw = value;
|
variant._raw = value;
|
||||||
variant._raw_type = type;
|
variant._raw_type = type;
|
||||||
|
|||||||
@@ -112,16 +112,15 @@ sub report
|
|||||||
|
|
||||||
# Generate output for benchmark2 chart.
|
# Generate output for benchmark2 chart.
|
||||||
chomp (my $version = qx{../src/task _version});
|
chomp (my $version = qx{../src/task _version});
|
||||||
my $out = sprintf "%s %s %f,%f,%f,%f,%f,%f,%f",
|
my $out = sprintf "%s %s %f,%f,%f,%f,%f,%f",
|
||||||
$label,
|
$label,
|
||||||
$version,
|
$version,
|
||||||
$data{'Context::initialize'},
|
$data{'Context::initialize'},
|
||||||
$data{'Context::parse'},
|
$data{'TDB2::loadPending'},
|
||||||
$data{'TDB::loadPending'},
|
$data{'TDB2::loadCompleted'} || 0,
|
||||||
$data{'TDB::loadCompleted'} || 0,
|
$data{'TDB2::gc'},
|
||||||
$data{'TDB::gc'},
|
$data{'TDB2::commit'},
|
||||||
$data{'TDB::commit'},
|
$data{'ViewTask::render'};
|
||||||
$data{'View::render'};
|
|
||||||
|
|
||||||
diag ($out);
|
diag ($out);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user