diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2014-04-30 19:51:27 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2014-04-30 19:51:27 +0200 |
commit | 387fbf589e73d96af9050afa121ef8b5e5370c4e (patch) | |
tree | ac558bc7a0a5895f29ed62a1dd6599a40c6f1d69 /xml/parser.ixx | |
parent | d6eec702f8e9e5e3e9983c5922638f33e8404dfa (diff) |
Add support for parsing memory buffer directly
Diffstat (limited to 'xml/parser.ixx')
-rw-r--r-- | xml/parser.ixx | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/xml/parser.ixx b/xml/parser.ixx index ac27b46..9041b0c 100644 --- a/xml/parser.ixx +++ b/xml/parser.ixx @@ -2,10 +2,33 @@ // copyright : Copyright (c) 2013-2014 Code Synthesis Tools CC // license : MIT; see accompanying LICENSE file +#include <cassert> + #include <xml/value-traits.hxx> namespace xml { + inline parser:: + parser (std::istream& is, const std::string& iname, feature_type f) + : size_ (0), iname_ (iname), feature_ (f) + { + data_.is = &is; + init (); + } + + inline parser:: + parser (const void* data, + std::size_t size, + const std::string& iname, + feature_type f) + : size_ (size), iname_ (iname), feature_ (f) + { + assert (data != 0 && size != 0); + + data_.buf = data; + init (); + } + template <typename T> inline T parser:: value () const @@ -75,4 +98,10 @@ namespace xml { return next_expect (e, std::string (), n); } + + inline const parser::element_entry* parser:: + get_element () const + { + return element_state_.empty () ? 0 : get_element_ (); + } } |