From e58957d6491a08ec212958457c29a14eec787279 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 11 Mar 2016 16:24:37 +0200 Subject: Implement --config-{guess,sub} options --- build2/types-parsers.cxx | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 build2/types-parsers.cxx (limited to 'build2/types-parsers.cxx') diff --git a/build2/types-parsers.cxx b/build2/types-parsers.cxx new file mode 100644 index 0000000..46fb8a1 --- /dev/null +++ b/build2/types-parsers.cxx @@ -0,0 +1,51 @@ +// file : build2/types-parsers.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include + +#include // build2::cl namespace + +namespace build2 +{ + namespace cl + { + 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