summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2016-11-12 15:01:47 -0800
committerJohn Wiegley <johnw@newartisans.com>2016-11-12 15:01:47 -0800
commit221c37a202c82f7c8f2d471b9776130a938cf459 (patch)
treee62a03d43fab0721ae5ac3d2127baf831a3eba26 /src
parentfaf6804b4c45c42554099d664c769fb5aed2eff5 (diff)
downloadfork-ledger-221c37a202c82f7c8f2d471b9776130a938cf459.tar.gz
fork-ledger-221c37a202c82f7c8f2d471b9776130a938cf459.tar.bz2
fork-ledger-221c37a202c82f7c8f2d471b9776130a938cf459.zip
Add new reporting function quoted_rfc4180
Diffstat (limited to 'src')
-rw-r--r--src/report.cc19
-rw-r--r--src/report.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/src/report.cc b/src/report.cc
index b2162034..09cae692 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -759,6 +759,23 @@ value_t report_t::fn_quoted(call_scope_t& args)
return string_value(out.str());
}
+value_t report_t::fn_quoted_rfc4180(call_scope_t& args)
+{
+ std::ostringstream out;
+
+ out << '"';
+ string arg(args.get<string>(0));
+ foreach (const char ch, arg) {
+ if (ch == '"')
+ out << '"' << '"';
+ else
+ out << ch;
+ }
+ out << '"';
+
+ return string_value(out.str());
+}
+
value_t report_t::fn_join(call_scope_t& args)
{
std::ostringstream out;
@@ -1442,6 +1459,8 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind,
case 'q':
if (is_eq(p, "quoted"))
return MAKE_FUNCTOR(report_t::fn_quoted);
+ else if (is_eq(p, "quoted_rfc4180"))
+ return MAKE_FUNCTOR(report_t::fn_quoted_rfc4180);
else if (is_eq(p, "quantity"))
return MAKE_FUNCTOR(report_t::fn_quantity);
break;
diff --git a/src/report.h b/src/report.h
index e943de1d..6bd3ca73 100644
--- a/src/report.h
+++ b/src/report.h
@@ -181,6 +181,7 @@ public:
value_t fn_abs(call_scope_t& scope);
value_t fn_justify(call_scope_t& scope);
value_t fn_quoted(call_scope_t& scope);
+ value_t fn_quoted_rfc4180(call_scope_t& scope);
value_t fn_join(call_scope_t& scope);
value_t fn_format_date(call_scope_t& scope);
value_t fn_format_datetime(call_scope_t& scope);