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 | 7 +++++++ 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 + { + static void + parse (path&, bool&, scanner&); + }; + + template <> struct parser { 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:: - 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