diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-01 18:35:44 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-01 18:35:44 -0400 |
commit | 66b097bda722a9f6582043f806da71f2af8deaa3 (patch) | |
tree | f6fb15e32cc97360e7040b5b8b50d573a331cb1d /src/report.cc | |
parent | 59a080cdb6bafa6ab20cb20c1bf1f007ea64de84 (diff) | |
download | fork-ledger-66b097bda722a9f6582043f806da71f2af8deaa3.tar.gz fork-ledger-66b097bda722a9f6582043f806da71f2af8deaa3.tar.bz2 fork-ledger-66b097bda722a9f6582043f806da71f2af8deaa3.zip |
Moved the args_to_predicate function to predicate.cc.
Diffstat (limited to 'src/report.cc')
-rw-r--r-- | src/report.cc | 124 |
1 files changed, 2 insertions, 122 deletions
diff --git a/src/report.cc b/src/report.cc index d0760a03..a9f4f96b 100644 --- a/src/report.cc +++ b/src/report.cc @@ -135,126 +135,6 @@ namespace { return string_value(out.str()); } - string args_to_predicate(value_t::sequence_t::const_iterator begin, - value_t::sequence_t::const_iterator end) - { - std::ostringstream expr; - bool append_and = false; - bool only_parenthesis; - - while (begin != end) { - const string& arg((*begin).as_string()); - const char * p = arg.c_str(); - - bool parse_argument = true; - - if (arg == "not" || arg == "NOT") { - expr << " ! "; - parse_argument = false; - append_and = false; - } - else if (arg == "and" || arg == "AND") { - expr << " & "; - parse_argument = false; - append_and = false; - } - else if (arg == "or" || arg == "OR") { - expr << " | "; - parse_argument = false; - append_and = false; - } - else if (append_and) { - if (! only_parenthesis) - expr << " & "; - } - else { - append_and = true; - } - - if (parse_argument) { - bool in_prefix = true; - bool in_suffix = false; - bool found_specifier = false; - bool saw_tag_char = false; - - only_parenthesis = true; - - for (const char * c = p; *c != '\0'; c++) { - bool consumed = false; - - if (*c != '(' && *c != ')') - only_parenthesis = false; - - if (in_prefix) { - switch (*c) { - case '(': - break; - case '@': - expr << "(payee =~ /"; - found_specifier = true; - consumed = true; - break; - case '=': - expr << "(note =~ /"; - found_specifier = true; - consumed = true; - break; - case '%': - expr << "(note =~ /:"; - found_specifier = true; - saw_tag_char = true; - consumed = true; - break; - case '/': - case '_': - default: - if (! found_specifier) { - expr << "(account =~ /"; - found_specifier = true; - } - in_prefix = false; - break; - } - } else { - switch (*c) { - case ')': - if (! in_suffix) { - if (found_specifier) { - if (saw_tag_char) - expr << ':'; - expr << "/)"; - } - in_suffix = true; - } - break; - default: - if (in_suffix) - throw_(parse_error, "Invalid text in specification argument"); - break; - } - } - - if (! consumed) - expr << *c; - } - - if (! in_suffix) { - if (found_specifier) { - if (saw_tag_char) - expr << ':'; - expr << "/)"; - } - } - } - - begin++; - } - - DEBUG("report.predicate", "Regexp predicate expression = " << expr.str()); - - return expr.str(); - } - template <class Type = xact_t, class handler_ptr = xact_handler_ptr, void (report_t::*report_method)(handler_ptr) = @@ -273,8 +153,8 @@ namespace { if (args.value().size() > 0) report.append_predicate - (args_to_predicate(args.value().as_sequence().begin(), - args.value().as_sequence().end())); + (args_to_predicate_expr(args.value().as_sequence().begin(), + args.value().as_sequence().end())); (report.*report_method)(handler_ptr(handler)); |