aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/name.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-10-18 15:20:49 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-10-18 15:20:49 +0200
commit0e0842330d1ef11f9ac6fa70d9f84bdb16084c45 (patch)
treeade516cf85cfa50b88b1b6105fc6364204275183 /libbuild2/name.hxx
parent0d6f835ffb582296d24a8d1dd479e2703e075ee3 (diff)
Add $quote() function for quoting values
This can be useful if we want to pass a value on the command line, for example, in a testscript: $* config.cxx=$quote($recall($cxx.path) $cxx.mode, true)
Diffstat (limited to 'libbuild2/name.hxx')
-rw-r--r--libbuild2/name.hxx16
1 files changed, 14 insertions, 2 deletions
diff --git a/libbuild2/name.hxx b/libbuild2/name.hxx
index 1ce073a..738645d 100644
--- a/libbuild2/name.hxx
+++ b/libbuild2/name.hxx
@@ -129,11 +129,19 @@ namespace build2
//
// \$("
//
+ // If escape is true, then escape (with a backslash) the quote characters
+ // being added (this is useful if the result will be re-parsed, for example
+ // as a Testscript command line).
+ //
// Note that in the quoted mode empty unqualified name is printed as '',
// not {}.
//
LIBBUILD2_SYMEXPORT ostream&
- to_stream (ostream&, const name&, bool quote, char pair = '\0');
+ to_stream (ostream&,
+ const name&,
+ bool quote,
+ char pair = '\0',
+ bool escape = false);
inline ostream&
operator<< (ostream& os, const name& n) {return to_stream (os, n, false);}
@@ -153,7 +161,11 @@ namespace build2
// The same semantics as to_stream(name).
//
LIBBUILD2_SYMEXPORT ostream&
- to_stream (ostream&, const names_view&, bool quote, char pair = '\0');
+ to_stream (ostream&,
+ const names_view&,
+ bool quote,
+ char pair = '\0',
+ bool escape = false);
inline ostream&
operator<< (ostream& os, const names_view& ns) {