From 4fec7e73201ed50e4a4157cb1ea1f1c63566dd89 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 28 Feb 2016 16:49:17 +0200 Subject: Menu customization --- brep/types-parsers.cxx | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'brep/types-parsers.cxx') diff --git a/brep/types-parsers.cxx b/brep/types-parsers.cxx index d46ea18..67f4812 100644 --- a/brep/types-parsers.cxx +++ b/brep/types-parsers.cxx @@ -7,6 +7,7 @@ #include using namespace std; +using namespace web::xhtml; namespace brep { @@ -59,5 +60,55 @@ namespace brep else throw invalid_value (o, v); } + + // Parse page_menu. + // + void parser:: + parse (page_menu& x, scanner& s) + { + const char* o (s.next ()); + + if (!s.more ()) + throw missing_value (o); + + const string v (s.next ()); + + auto p (v.find ('=')); + if (p != string::npos) + { + string label (v, 0, p); + string link (v, p + 1); + + if (!label.empty ()) + { + x = page_menu (move (label), move (link)); + return; + } + } + + throw invalid_value (o, v); + } + + // Parse web::xhtml::fragment. + // + void parser:: + parse (fragment& x, scanner& s) + { + const char* o (s.next ()); + + if (!s.more ()) + throw missing_value (o); + + const char* v (s.next ()); + + try + { + x = fragment (v, o); + } + catch (const xml::parsing&) + { + throw invalid_value (o, v); + } + } } } -- cgit v1.1