aboutsummaryrefslogtreecommitdiff
path: root/bpkg/types-parsers.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-09-25 07:04:14 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-09-25 07:04:14 +0200
commit5ab55b3efa7be536af146c778ebe457462a886a6 (patch)
treecf7d3353025ce20840abf6c1d1d7c2d36e80f22a /bpkg/types-parsers.cxx
parent79f46e26a38414eadb701cc925d195d67371518e (diff)
Add support for cli-parsing path in addition to dir_path
Diffstat (limited to 'bpkg/types-parsers.cxx')
-rw-r--r--bpkg/types-parsers.cxx22
1 files changed, 18 insertions, 4 deletions
diff --git a/bpkg/types-parsers.cxx b/bpkg/types-parsers.cxx
index 544908c..1c8409a 100644
--- a/bpkg/types-parsers.cxx
+++ b/bpkg/types-parsers.cxx
@@ -10,10 +10,10 @@ namespace bpkg
{
namespace cli
{
- void parser<dir_path>::
- parse (dir_path& x, bool& xs, scanner& s)
+ template <typename T>
+ static void
+ parse_path (T& x, scanner& s)
{
- xs = true;
const char* o (s.next ());
if (!s.more ())
@@ -23,7 +23,7 @@ namespace bpkg
try
{
- x = dir_path (v);
+ x = T (v);
if (x.empty ())
throw invalid_value (o, v);
@@ -33,5 +33,19 @@ namespace bpkg
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);
+ }
}
}