From 42ae47c3033a8c9ce70f1e6fb4c88ed70ac679fb Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 23 Dec 2017 19:05:22 +0300 Subject: Add repository type detection --- bpkg/types-parsers.cxx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'bpkg/types-parsers.cxx') diff --git a/bpkg/types-parsers.cxx b/bpkg/types-parsers.cxx index 6da395c..41b231f 100644 --- a/bpkg/types-parsers.cxx +++ b/bpkg/types-parsers.cxx @@ -67,5 +67,26 @@ namespace bpkg else throw invalid_value (o, v); } + + void parser:: + parse (repository_type& x, bool& xs, scanner& s) + { + xs = true; + const char* o (s.next ()); + + if (!s.more ()) + throw missing_value (o); + + const string v (s.next ()); + + try + { + x = to_repository_type(v); + } + catch (const invalid_argument&) + { + throw invalid_value (o, v); + } + } } } -- cgit v1.1