From 5ab55b3efa7be536af146c778ebe457462a886a6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 25 Sep 2015 07:04:14 +0200 Subject: Add support for cli-parsing path in addition to dir_path --- bpkg/types-parsers.cxx | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'bpkg/types-parsers.cxx') 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:: - parse (dir_path& x, bool& xs, scanner& s) + template + 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:: + parse (path& x, bool& xs, scanner& s) + { + xs = true; + parse_path (x, s); + } + + void parser:: + parse (dir_path& x, bool& xs, scanner& s) + { + xs = true; + parse_path (x, s); + } } } -- cgit v1.1