aboutsummaryrefslogtreecommitdiff
path: root/brep/types-parsers.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-11-14 16:29:22 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-11-16 16:42:35 +0200
commit03905bcf1bcfd9e7932fcac4283c5817058a25ce (patch)
treeb643d3bedf436bfcd8956b25133d5674b6b18e36 /brep/types-parsers.cxx
parent96281a6c4f818311a6df90c0d8b8f537a61e1090 (diff)
Invent root path web interface configuration option
Diffstat (limited to 'brep/types-parsers.cxx')
-rw-r--r--brep/types-parsers.cxx47
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);
+ }
+ }
+}