summaryrefslogtreecommitdiff
path: root/main.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-19 20:31:46 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:28 -0400
commit0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c (patch)
tree0a2c2aca7100d045f491b03f0a5bda92378d3ef9 /main.cc
parent176b3044e355398a0c31e0c42a3cd7b8a2e3f3e5 (diff)
downloadfork-ledger-0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c.tar.gz
fork-ledger-0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c.tar.bz2
fork-ledger-0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c.zip
Made the amount/balance/value interface a bit more rational; added
back a useless version of the register command (just to prove the command sequence); and added smart XML semantics to the XPath implementation so that nodes can be coerced to values.
Diffstat (limited to 'main.cc')
-rw-r--r--main.cc36
1 files changed, 15 insertions, 21 deletions
diff --git a/main.cc b/main.cc
index b8e25813..473ff5fa 100644
--- a/main.cc
+++ b/main.cc
@@ -28,16 +28,6 @@
using namespace ledger;
-static inline
-const std::string& either_or(const std::string& first,
- const std::string& second)
-{
- if (first.empty())
- return second;
- else
- return first;
-}
-
#if 0
class print_addr : public repitem_t::select_callback_t {
virtual void operator()(repitem_t * item) {
@@ -107,15 +97,16 @@ static int read_and_report(report_t * report, int argc, char * argv[],
xml::xpath_t::functor_t * command = NULL;
- if (false) {
- ;
- }
-#if 0
if (verb == "register" || verb == "reg" || verb == "r") {
+#if 1
+ command = new register_command;
+#else
command = new format_command
("register", either_or(report->format_string,
report->session->register_format));
+#endif
}
+#if 0
else if (verb == "balance" || verb == "bal" || verb == "b") {
if (! report->raw_mode) {
report->transforms.push_back(new accounts_transform);
@@ -311,14 +302,10 @@ static int read_and_report(report_t * report, int argc, char * argv[],
locals->args.push_back(journal->document);
if (command->wants_args) {
-#if 1
- locals->args.push_back(&args);
-#else
for (strings_list::iterator i = args.begin();
i != args.end();
i++)
locals->args.push_back(*i);
-#endif
} else {
std::string regexps[4];
@@ -367,9 +354,16 @@ static int read_and_report(report_t * report, int argc, char * argv[],
#endif
}
-#if 0
- report->apply_transforms(items.get());
-#endif
+ xml::document_t * xml_doc = new xml::document_t;
+ xml::journal_node_t * journal_node = new xml::journal_node_t(xml_doc, journal);
+
+ xml_doc->set_top(journal_node);
+
+ assert(xml_doc->top == journal_node);
+ assert(journal_node->document == xml_doc);
+ assert(journal_node->document->top == journal_node);
+
+ report->apply_transforms(xml_doc);
value_t temp;
(*command)(temp, locals);