From 221c37a202c82f7c8f2d471b9776130a938cf459 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 12 Nov 2016 15:01:47 -0800 Subject: Add new reporting function quoted_rfc4180 --- src/report.cc | 19 +++++++++++++++++++ src/report.h | 1 + 2 files changed, 20 insertions(+) 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(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); -- cgit v1.2.3