From 6ccee38f43493f8f6e87bab549e9ef952244f39a Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 13 Mar 2021 16:09:48 +0300 Subject: Add support for interactive CI mode --- mod/types-parsers.cxx | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'mod/types-parsers.cxx') diff --git a/mod/types-parsers.cxx b/mod/types-parsers.cxx index dc21e97..422b353 100644 --- a/mod/types-parsers.cxx +++ b/mod/types-parsers.cxx @@ -3,11 +3,15 @@ #include +#include + +#include #include // from_string() #include using namespace std; +using namespace butl; using namespace bpkg; using namespace web::xhtml; @@ -75,9 +79,9 @@ namespace brep string t ("1970-01-01 "); t += v; - x = butl::from_string (t.c_str (), - "%Y-%m-%d %H:%M", - false /* local */).time_since_epoch (); + x = from_string (t.c_str (), + "%Y-%m-%d %H:%M", + false /* local */).time_since_epoch (); return; } catch (const invalid_argument&) {} @@ -181,5 +185,37 @@ namespace brep throw invalid_value (o, v); } } + + // Parse the '/regex/replacement/' string into the regex/replacement pair. + // + void parser>:: + parse (pair& x, bool& xs, scanner& s) + { + xs = true; + const char* o (s.next ()); + + if (!s.more ()) + throw missing_value (o); + + const char* v (s.next ()); + + try + { + x = regex_replace_parse (v); + } + catch (const invalid_argument& e) + { + throw invalid_value (o, v, e.what ()); + } + catch (const regex_error& e) + { + // Sanitize the description. + // + ostringstream os; + os << e; + + throw invalid_value (o, v, os.str ()); + } + } } } -- cgit v1.1