From a133e7b03bd67c992cfb240bd300967ffab31ba2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 1 Apr 2017 16:46:03 +0200 Subject: Setup build infra --- bbot/types-parsers.cxx | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 bbot/types-parsers.cxx (limited to 'bbot/types-parsers.cxx') diff --git a/bbot/types-parsers.cxx b/bbot/types-parsers.cxx new file mode 100644 index 0000000..6a0e899 --- /dev/null +++ b/bbot/types-parsers.cxx @@ -0,0 +1,51 @@ +// file : bbot/types-parsers.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include + +#include // bbot::cli namespace + +namespace bbot +{ + namespace cli + { + template + static void + parse_path (T& x, scanner& s) + { + const char* o (s.next ()); + + if (!s.more ()) + throw missing_value (o); + + const char* v (s.next ()); + + try + { + x = T (v); + + if (x.empty ()) + throw invalid_value (o, v); + } + catch (const invalid_path&) + { + throw invalid_value (o, v); + } + } + + void parser:: + parse (path& x, bool& xs, scanner& s) + { + xs = true; + parse_path (x, s); + } + + void parser:: + parse (dir_path& x, bool& xs, scanner& s) + { + xs = true; + parse_path (x, s); + } + } +} -- cgit v1.1