diff options
-rw-r--r-- | bpkg/types-parsers | 7 | ||||
-rw-r--r-- | bpkg/types-parsers.cxx | 22 |
2 files changed, 25 insertions, 4 deletions
diff --git a/bpkg/types-parsers b/bpkg/types-parsers index 8aacd09..4e85c84 100644 --- a/bpkg/types-parsers +++ b/bpkg/types-parsers @@ -20,6 +20,13 @@ namespace bpkg struct parser; template <> + struct parser<path> + { + static void + parse (path&, bool&, scanner&); + }; + + template <> struct parser<dir_path> { static void 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); + } } } |