summaryrefslogtreecommitdiff
path: root/src/string.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2016-08-06 09:05:50 +0100
committerMaxime Coste <frrrwww@gmail.com>2016-08-06 09:05:50 +0100
commitf73e89a716db7f71382f3716d2141c170a57ca2e (patch)
treef0e080deaea48e2589c26ec32d1507a0de4b72a5 /src/string.hh
parentf1a93a0e613e46121039f8aa1415bb8f02946cf9 (diff)
Add information of types of options
Diffstat (limited to 'src/string.hh')
-rw-r--r--src/string.hh5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/string.hh b/src/string.hh
index d7e0e56c..74fbb51a 100644
--- a/src/string.hh
+++ b/src/string.hh
@@ -128,6 +128,7 @@ public:
void resize(ByteCount size, char c);
static const String ms_empty;
+ static constexpr const char* option_type_name = "str";
union Data
{
@@ -305,6 +306,10 @@ inline String operator"" _str(const char* str, size_t)
int str_to_int(StringView str); // throws on error
Optional<int> str_to_int_ifp(StringView str);
+inline String option_to_string(StringView opt) { return opt.str(); }
+inline void option_from_string(StringView str, String& opt) { opt = str.str(); }
+inline bool option_add(String& opt, StringView val) { opt += val; return not val.empty(); }
+
template<size_t N>
struct InplaceString
{