aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/fmt.hh
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2020-06-24 12:52:09 -0400
committerMatthew Bauer <mjbauer95@gmail.com>2020-06-24 12:52:09 -0400
commitbcf8582091ac578a8b167f0eeb33d3db2f7b5f98 (patch)
treeef611303dfee4bde491f05d7ac54393be214d32b /src/libutil/fmt.hh
parent66a62b3189c8c9b0965850e6b3c9b0fda0b50fd8 (diff)
parent3c50e84387e51858f10c540e721a938592f30949 (diff)
Merge remote-tracking branch 'origin/master' into substitute-other-storedir
Diffstat (limited to 'src/libutil/fmt.hh')
-rw-r--r--src/libutil/fmt.hh17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/libutil/fmt.hh b/src/libutil/fmt.hh
index 12ab9c407..a39de041f 100644
--- a/src/libutil/fmt.hh
+++ b/src/libutil/fmt.hh
@@ -1,6 +1,7 @@
#pragma once
#include <boost/format.hpp>
+#include <boost/algorithm/string/replace.hpp>
#include <string>
#include "ansicolor.hh"
@@ -103,7 +104,9 @@ class hintformat
public:
hintformat(const string &format) :fmt(format)
{
- fmt.exceptions(boost::io::all_error_bits ^ boost::io::too_many_args_bit);
+ fmt.exceptions(boost::io::all_error_bits ^
+ boost::io::too_many_args_bit ^
+ boost::io::too_few_args_bit);
}
hintformat(const hintformat &hf)
@@ -117,6 +120,13 @@ public:
return *this;
}
+ template<class T>
+ hintformat& operator%(const normaltxt<T> &value)
+ {
+ fmt % value.value;
+ return *this;
+ }
+
std::string str() const
{
return fmt.str();
@@ -136,4 +146,9 @@ inline hintformat hintfmt(const std::string & fs, const Args & ... args)
return f;
}
+inline hintformat hintfmt(std::string plain_string)
+{
+ // we won't be receiving any args in this case, so just print the original string
+ return hintfmt("%s", normaltxt(plain_string));
+}
}