From 648b616c86e05c74b9ad25ad2bb5e5adf4172619 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 28 Jan 2016 07:24:22 +0200 Subject: Add support for file expansion in prologue/epilogue files This is similar to variable expansion ($name$) except here we detect if the name starts with ./ or ../ and treat it as a path relative to the prologue/ epilogue file. --- cli/context.hxx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'cli/context.hxx') diff --git a/cli/context.hxx b/cli/context.hxx index f16f8c2..cdc0aa5 100644 --- a/cli/context.hxx +++ b/cli/context.hxx @@ -13,6 +13,7 @@ #include // std::size_t #include +#include #include "options.hxx" #include "semantics.hxx" @@ -44,6 +45,9 @@ public: typedef std::size_t size_t; typedef std::string string; + typedef cutl::fs::path path; + typedef cutl::fs::invalid_path invalid_path; + typedef ::options options_type; typedef ::usage usage_type; typedef ::class_doc class_doc_type; @@ -111,13 +115,19 @@ public: void format_line (output_type, string&, const char*, size_t); - // Substitute doc variable expansions ($var$). + // Substitute doc variable expansions ($var$). Var must be a C identifier. + // If the path is not NULL, then also recognize names that start with either + // ./ or ../ and treat them as files relative to path. Such file expansions + // are substituted with the files' contents. // static string - substitute (const string&, semantics::cli_unit&); + substitute (const string&, semantics::cli_unit&, const path* = 0); string - substitute (const string& s) {return substitute (s, unit);} + substitute (const string& s, const path* p = 0) + { + return substitute (s, unit, p); + } public: static string const& -- cgit v1.1