diff options
Diffstat (limited to 'brep/types-parsers.cxx')
-rw-r--r-- | brep/types-parsers.cxx | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/brep/types-parsers.cxx b/brep/types-parsers.cxx new file mode 100644 index 0000000..f7c2f11 --- /dev/null +++ b/brep/types-parsers.cxx @@ -0,0 +1,47 @@ +// file : brep/types-parsers.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include <brep/types-parsers> + +#include <butl/path> + +#include <brep/options> + +using namespace butl; + +namespace brep +{ + 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<dir_path>:: + parse (dir_path& x, scanner& s) + { + parse_path (x, s); + } + } +} |