aboutsummaryrefslogtreecommitdiff
path: root/cutl/xml/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-03-14 10:45:12 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-03-14 10:45:12 +0200
commitce298ad2e8dbc3601d180c178bee9d606b8edab2 (patch)
tree983545115dcb2d73cf56c3fc2e2f6be5d297eb43 /cutl/xml/parser.cxx
parent17ad2a3fd8933aa49bff4c8ea49963d15cc0db92 (diff)
Add convenience constructors to XML parsing and serialization exceptions
Diffstat (limited to 'cutl/xml/parser.cxx')
-rw-r--r--cutl/xml/parser.cxx36
1 files changed, 26 insertions, 10 deletions
diff --git a/cutl/xml/parser.cxx b/cutl/xml/parser.cxx
index 5724794..ca20edd 100644
--- a/cutl/xml/parser.cxx
+++ b/cutl/xml/parser.cxx
@@ -29,10 +29,26 @@ namespace cutl
const string& d)
: name_ (n), line_ (l), column_ (c), description_ (d)
{
+ init ();
+ }
+
+ parsing::
+ parsing (const parser& p, const std::string& d)
+ : name_ (p.input_name ()),
+ line_ (p.line ()),
+ column_ (p.column ()),
+ description_ (d)
+ {
+ init ();
+ }
+
+ void parsing::
+ init ()
+ {
ostringstream os;
- if (!n.empty ())
- os << n << ':';
- os << l << ':' << c << ": error: " << d;
+ if (!name_.empty ())
+ os << name_ << ':';
+ os << line_ << ':' << column_ << ": error: " << description_;
what_ = os.str ();
}
@@ -52,8 +68,8 @@ namespace cutl
}
parser::
- parser (istream& is, const string& name, feature_type f)
- : is_ (is), name_ (name), feature_ (f),
+ parser (istream& is, const string& iname, feature_type f)
+ : is_ (is), iname_ (iname), feature_ (f),
depth_ (0), state_ (state_next), event_ (eof), queue_ (eof),
pqname_ (&qname_), pvalue_ (&value_),
attr_i_ (0), start_ns_i_ (0), end_ns_i_ (0)
@@ -101,15 +117,15 @@ namespace cutl
switch (content ())
{
case empty:
- throw parsing (name_, line_, column_, "character in empty content");
+ throw parsing (iname_, line_, column_, "character in empty content");
case complex:
- throw parsing (name_, line_, column_, "character in complex content");
+ throw parsing (iname_, line_, column_, "character in complex content");
default:
assert (false);
}
}
else
- throw parsing (name_,
+ throw parsing (iname_,
XML_GetCurrentLineNumber (p_),
XML_GetCurrentColumnNumber (p_),
XML_ErrorString (e));
@@ -174,9 +190,9 @@ namespace cutl
switch (content ())
{
case empty:
- throw parsing (name_, line_, column_, "element in empty content");
+ throw parsing (iname_, line_, column_, "element in empty content");
case simple:
- throw parsing (name_, line_, column_, "element in simple content");
+ throw parsing (iname_, line_, column_, "element in simple content");
default:
break;
}