aboutsummaryrefslogtreecommitdiff
path: root/load/types-parsers.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'load/types-parsers.cxx')
-rw-r--r--load/types-parsers.cxx43
1 files changed, 43 insertions, 0 deletions
diff --git a/load/types-parsers.cxx b/load/types-parsers.cxx
new file mode 100644
index 0000000..6c61daf
--- /dev/null
+++ b/load/types-parsers.cxx
@@ -0,0 +1,43 @@
+// file : load/types-parsers.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#include <load/types-parsers>
+
+#include <load/load-options> // cli namespace
+
+using 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<path>::
+ parse (path& x, bool& xs, scanner& s)
+ {
+ xs = true;
+ parse_path (x, s);
+ }
+}