diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-03-07 15:22:51 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-03-07 15:22:51 +0200 |
commit | 1c36adab776a900adc7325f412b1c8dd61b1a346 (patch) | |
tree | 0227b8c5697d24a862aedd59b9bfe28cc84e91b4 /bdep/types-parsers.cxx | |
parent | 2e2c3a81b47c650334f5767ddb4ebb2746ef98f1 (diff) |
Setup compilation, command line handling
Diffstat (limited to 'bdep/types-parsers.cxx')
-rw-r--r-- | bdep/types-parsers.cxx | 51 |
1 files changed, 51 insertions, 0 deletions
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 <bdep/types-parsers.hxx> + +#include <bdep/common-options.hxx> // bdep::cli namespace + +namespace bdep +{ + namespace cli + { + template <typename T> + 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<path>:: + parse (path& x, bool& xs, scanner& s) + { + xs = true; + parse_path (x, s); + } + + void parser<dir_path>:: + parse (dir_path& x, bool& xs, scanner& s) + { + xs = true; + parse_path (x, s); + } + } +} |