From 1c36adab776a900adc7325f412b1c8dd61b1a346 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 7 Mar 2018 15:22:51 +0200 Subject: Setup compilation, command line handling --- bdep/types-parsers.cxx | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 bdep/types-parsers.cxx (limited to 'bdep/types-parsers.cxx') diff --git a/bdep/types-parsers.cxx b/bdep/types-parsers.cxx new file mode 100644 index 0000000..5d0fa34 --- /dev/null +++ b/bdep/types-parsers.cxx @@ -0,0 +1,51 @@ +// file : bdep/types-parsers.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include + +#include // bdep::cli namespace + +namespace bdep +{ + 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