aboutsummaryrefslogtreecommitdiff
path: root/xml
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2014-05-09 16:24:44 -0700
committerBoris Kolpackov <boris@codesynthesis.com>2014-05-09 16:24:44 -0700
commit41569646f9b5e70e53769e24d5e8efe45c2d24b4 (patch)
treeac973b8eedc7341793675746c67381d742b7cf36 /xml
parent850aca7f66a32f3301795c207926beef5165c45a (diff)
Move content model enum out of parser and into xml namespace
Diffstat (limited to 'xml')
-rw-r--r--xml/content.hxx35
-rw-r--r--xml/parser.cxx18
-rw-r--r--xml/parser.hxx14
-rw-r--r--xml/parser.ixx2
4 files changed, 49 insertions, 20 deletions
diff --git a/xml/content.hxx b/xml/content.hxx
new file mode 100644
index 0000000..575ef1d
--- /dev/null
+++ b/xml/content.hxx
@@ -0,0 +1,35 @@
+// file : xml/content.hxx
+// copyright : Copyright (c) 2013-2014 Code Synthesis Tools CC
+// license : MIT; see accompanying LICENSE file
+
+#ifndef XML_CONTENT_HXX
+#define XML_CONTENT_HXX
+
+#include <xml/details/pre.hxx>
+
+namespace xml
+{
+ // XML content model. C++11 enum class emulated for C++98.
+ //
+ struct content
+ {
+ enum value
+ {
+ // element characters whitespaces notes
+ empty, // no no ignored
+ simple, // no yes preserved content accumulated
+ complex, // yes no ignored
+ mixed // yes yes preserved
+ };
+
+ content (value v): v_ (v) {};
+ operator value () const {return v_;}
+
+ private:
+ value v_;
+ };
+}
+
+#include <xml/details/post.hxx>
+
+#endif // XML_CONTENT_HXX
diff --git a/xml/parser.cxx b/xml/parser.cxx
index ef5683f..28a17ce 100644
--- a/xml/parser.cxx
+++ b/xml/parser.cxx
@@ -147,11 +147,11 @@ namespace xml
//
switch (content ())
{
- case empty:
+ case content_type::empty:
throw parsing (*this, "character in empty content");
- case simple:
+ case content_type::simple:
throw parsing (*this, "element in simple content");
- case complex:
+ case content_type::complex:
throw parsing (*this, "character in complex content");
default:
assert (false);
@@ -321,7 +321,7 @@ namespace xml
string parser::
element ()
{
- content (simple);
+ content (content_type::simple);
string r;
// The content of the element can be empty in which case there
@@ -435,9 +435,9 @@ namespace xml
{
switch (e->content)
{
- case empty:
+ case content_type::empty:
throw parsing (*this, "element in empty content");
- case simple:
+ case content_type::simple:
throw parsing (*this, "element in simple content");
default:
break;
@@ -865,8 +865,8 @@ namespace xml
//
switch (cont)
{
- case empty:
- case complex:
+ case content_type::empty:
+ case content_type::complex:
{
for (int i (0); i != n; ++i)
{
@@ -909,7 +909,7 @@ namespace xml
// into a single event. To do this we will let the parser run
// until we reach the end of the element.
//
- if (cont == simple)
+ if (cont == content_type::simple)
p.accumulate_ = true;
else
XML_StopParser (p.p_, true);
diff --git a/xml/parser.hxx b/xml/parser.hxx
index cd33588..1d45e8c 100644
--- a/xml/parser.hxx
+++ b/xml/parser.hxx
@@ -29,6 +29,7 @@
#include <xml/forward.hxx>
#include <xml/qname.hxx>
+#include <xml/content.hxx>
#include <xml/exception.hxx>
#include <xml/details/export.hxx>
@@ -80,6 +81,8 @@ namespace xml
{
public:
typedef xml::qname qname_type;
+ typedef xml::content content_type;
+
typedef unsigned short feature_type;
// If both receive_attributes_event and receive_attributes_map are
@@ -246,15 +249,6 @@ namespace xml
// Optional content processing.
//
public:
- enum content_type
- {
- // element characters whitespaces notes
- empty, // no no ignored
- simple, // no yes preserved content accumulated
- complex, // yes no ignored
- mixed // yes yes preserved
- };
-
// Note that you cannot get/set content while peeking.
//
void
@@ -434,7 +428,7 @@ namespace xml
//
struct element_entry
{
- element_entry (std::size_t d, content_type c = mixed)
+ element_entry (std::size_t d, content_type c = content_type::mixed)
: depth (d), content (c), attr_unhandled_ (0) {}
std::size_t depth;
diff --git a/xml/parser.ixx b/xml/parser.ixx
index 49d9c89..e5656d4 100644
--- a/xml/parser.ixx
+++ b/xml/parser.ixx
@@ -205,7 +205,7 @@ namespace xml
return
!element_state_.empty () && element_state_.back ().depth == depth_
? element_state_.back ().content
- : mixed;
+ : content_type (content_type::mixed);
}
inline const parser::element_entry* parser::