diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-02-28 16:49:17 +0200 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2016-03-02 17:34:10 +0300 |
commit | 4fec7e73201ed50e4a4157cb1ea1f1c63566dd89 (patch) | |
tree | 93ca4fc57d2ba8bf077ac021cf96fa6335c8bfcc /brep/types-parsers.cxx | |
parent | cfdbf0f9c52288efaa57eba3a9c913790f034cf2 (diff) |
Menu customization
Diffstat (limited to 'brep/types-parsers.cxx')
-rw-r--r-- | brep/types-parsers.cxx | 51 |
1 files changed, 51 insertions, 0 deletions
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 <brep/options> 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<page_menu>:: + 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<fragment>:: + 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); + } + } } } |