summaryrefslogtreecommitdiff
path: root/libs/pbd/pbd
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-09-17 17:16:05 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2015-09-17 17:16:23 -0400
commitc1d6a2fd92fb2e68335c03940684c27ac3ec6680 (patch)
tree4bdab30cdedfba62073e79729d6698189ad25c18 /libs/pbd/pbd
parentf3a1ac21cbe0793f830143ccbad77a0cf7ef16fe (diff)
add string_compose argument specializations so that empty std::string and empty C strings are handled as intended
Diffstat (limited to 'libs/pbd/pbd')
-rw-r--r--libs/pbd/pbd/compose.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/libs/pbd/pbd/compose.h b/libs/pbd/pbd/compose.h
index cb4182699f..b3b6ea21d1 100644
--- a/libs/pbd/pbd/compose.h
+++ b/libs/pbd/pbd/compose.h
@@ -54,6 +54,10 @@ namespace StringPrivate
template <typename T>
Composition &arg(const T &obj);
+ // specialization to catch strings (C++ and C)
+ Composition &arg(const std::string &str);
+ Composition &arg(char const * const cstr);
+
// compose and return string
std::string str() const;
@@ -138,6 +142,42 @@ namespace StringPrivate
return *this;
}
+ inline Composition &Composition::arg(const std::string &str)
+ {
+ /* specialization to ensure that empty strings show up
+ * in the output
+ */
+ for (specification_map::const_iterator i = specs.lower_bound(arg_no),
+ end = specs.upper_bound(arg_no); i != end; ++i) {
+ output_list::iterator pos = i->second;
+ ++pos;
+
+ output.insert(pos, str);
+ }
+
+ ++arg_no;
+
+ return *this;
+ }
+
+ inline Composition &Composition::arg(char const * const cstr)
+ {
+ /* specialization to ensure that empty C strings show up
+ * in the output
+ */
+ for (specification_map::const_iterator i = specs.lower_bound(arg_no),
+ end = specs.upper_bound(arg_no); i != end; ++i) {
+ output_list::iterator pos = i->second;
+ ++pos;
+
+ output.insert(pos, std::string (cstr));
+ }
+
+ ++arg_no;
+
+ return *this;
+ }
+
inline Composition::Composition(std::string fmt)
: arg_no(1)
{