ColProject: Special ::modify handling for 'project'

This commit is contained in:
Paul Beckingham 2016-02-01 23:38:32 -05:00
parent 7ae5e4657d
commit 575433542f
2 changed files with 36 additions and 0 deletions

View file

@ -27,12 +27,18 @@
#include <cmake.h> #include <cmake.h>
#include <ColProject.h> #include <ColProject.h>
#include <Context.h> #include <Context.h>
#include <Eval.h>
#include <Variant.h>
#include <Lexer.h>
#include <Filter.h>
#include <Dates.h>
#include <text.h> #include <text.h>
#include <utf8.h> #include <utf8.h>
#include <util.h> #include <util.h>
#include <i18n.h> #include <i18n.h>
extern Context context; extern Context context;
extern Task& contextTask;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ColumnProject::ColumnProject () ColumnProject::ColumnProject ()
@ -107,3 +113,32 @@ void ColumnProject::render (
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void ColumnProject::modify (Task& task, const std::string& value)
{
std::string label = " MODIFICATION ";
// Only if it's a DOM ref, eval it first.
Lexer lexer (value);
std::string domRef;
Lexer::Type type;
if (lexer.token (domRef, type) &&
type == Lexer::Type::dom)
{
Eval e;
e.addSource (domSource);
e.addSource (namedDates);
contextTask = task;
Variant v;
e.evaluateInfixExpression (value, v);
task.set (_name, (std::string) v);
context.debug (label + _name + " <-- '" + (std::string) v + "' <-- '" + value + "'");
}
else
{
task.set (_name, value);
context.debug (label + _name + " <-- '" + value + "'");
}
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -35,6 +35,7 @@ public:
ColumnProject (); ColumnProject ();
void measure (Task&, unsigned int&, unsigned int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
void modify (Task&, const std::string&);
private: private:
bool _hyphenate; bool _hyphenate;