diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-03-18 22:17:49 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-03-27 17:28:44 +0300 |
commit | 35359f038f571dc46de3d14af72a2bc911fb0a24 (patch) | |
tree | de3e89d678e78b9efc4d395274fd7ccc68f4a213 /web/xhtml/fragment.hxx | |
parent | 8ad672cc7211952716ffe1fbf76c179b4f1149e3 (diff) |
Implement brep-monitor
Diffstat (limited to 'web/xhtml/fragment.hxx')
-rw-r--r-- | web/xhtml/fragment.hxx | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/web/xhtml/fragment.hxx b/web/xhtml/fragment.hxx new file mode 100644 index 0000000..eab4335 --- /dev/null +++ b/web/xhtml/fragment.hxx @@ -0,0 +1,52 @@ +// file : web/xhtml/fragment.hxx -*- C++ -*- +// license : MIT; see accompanying LICENSE file + +#ifndef WEB_XHTML_FRAGMENT_HXX +#define WEB_XHTML_FRAGMENT_HXX + +#include <string> +#include <vector> +#include <utility> // pair + +#include <libstudxml/parser.hxx> +#include <libstudxml/forward.hxx> + +namespace web +{ + namespace xhtml + { + // A parsed (via xml::parser) XHTML fragment that can later be serialized + // to xml::serializer. + // + class fragment + { + public: + bool truncated = false; + + public: + fragment () = default; + + // Parse string as an XHTML document fragment, truncating it if + // requested. The fragment should be complete, in the sense that all + // elements should have closing tags. Elements and attributes are + // considered to be in the namespace of the entire XHTML document, so no + // namespace should be specified for them. Do not validate against XHTML + // vocabulary. Can throw xml::parsing exception. + // + fragment (const std::string& xhtml, + const std::string& input_name, + size_t length = 0); + + void + operator() (xml::serializer&) const; + + bool + empty () const {return events_.empty ();} + + private: + std::vector<std::pair<xml::parser::event_type, std::string>> events_; + }; + } +} + +#endif // WEB_XHTML_FRAGMENT_HXX |