mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-24 17:18:32 +02:00
Formattingt fixes
This commit is contained in:
parent
5865c9f383
commit
0887b56cad
@ -298,22 +298,22 @@ private:
|
|||||||
std::istream* is;
|
std::istream* is;
|
||||||
const void* buf;
|
const void* buf;
|
||||||
}
|
}
|
||||||
data_;
|
_data;
|
||||||
|
|
||||||
std::size_t size_;
|
std::size_t _size;
|
||||||
|
|
||||||
const std::string iname_;
|
const std::string _inputName;
|
||||||
FeatureType feature_;
|
FeatureType feature_;
|
||||||
|
|
||||||
XML_Parser p_;
|
XML_Parser p_;
|
||||||
std::size_t depth_;
|
std::size_t depth_;
|
||||||
bool accumulate_; // Whether we are accumulating character content.
|
bool _accumulateContent; // Whether we are accumulating character content.
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
state_next, state_peek
|
state_next, state_peek
|
||||||
}
|
}
|
||||||
state_;
|
_parserState;
|
||||||
EventType event_;
|
EventType _currentEvent;
|
||||||
EventType queue_;
|
EventType queue_;
|
||||||
|
|
||||||
QName qname_;
|
QName qname_;
|
||||||
@ -322,11 +322,11 @@ private:
|
|||||||
// These are used to avoid copying when we are handling attributes
|
// These are used to avoid copying when we are handling attributes
|
||||||
// and namespace decls.
|
// and namespace decls.
|
||||||
//
|
//
|
||||||
const QName* pqname_;
|
const QName* _qualifiedName;
|
||||||
std::string* pvalue_;
|
std::string* pvalue_;
|
||||||
|
|
||||||
Poco::UInt64 line_;
|
Poco::UInt64 _line;
|
||||||
Poco::UInt64 column_;
|
Poco::UInt64 _column;
|
||||||
|
|
||||||
// Attributes as events.
|
// Attributes as events.
|
||||||
//
|
//
|
||||||
@ -338,8 +338,8 @@ private:
|
|||||||
|
|
||||||
typedef std::vector<attribute_type> attributes;
|
typedef std::vector<attribute_type> attributes;
|
||||||
|
|
||||||
attributes attr_;
|
attributes _attributes;
|
||||||
attributes::size_type attr_i_; // Index of the current attribute.
|
attributes::size_type _currentAttributeIndex; // Index of the current attribute.
|
||||||
|
|
||||||
// Namespace declarations.
|
// Namespace declarations.
|
||||||
//
|
//
|
||||||
@ -356,24 +356,24 @@ private:
|
|||||||
struct ElementEntry
|
struct ElementEntry
|
||||||
{
|
{
|
||||||
ElementEntry(std::size_t d, Content c = Content::Mixed) :
|
ElementEntry(std::size_t d, Content c = Content::Mixed) :
|
||||||
depth(d),
|
depth(d),
|
||||||
content(c),
|
content(c),
|
||||||
attr_unhandled_(0)
|
attributesUnhandled_(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t depth;
|
std::size_t depth;
|
||||||
Content content;
|
Content content;
|
||||||
AttributeMapType attr_map_;
|
AttributeMapType attr_map_;
|
||||||
mutable AttributeMapType::size_type attr_unhandled_;
|
mutable AttributeMapType::size_type attributesUnhandled_;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<ElementEntry> ElementState;
|
typedef std::vector<ElementEntry> ElementState;
|
||||||
std::vector<ElementEntry> element_state_;
|
std::vector<ElementEntry> _elementState;
|
||||||
|
|
||||||
// Empty attribute map to return when an element has no attributes.
|
// Empty attribute map to return when an element has no attributes.
|
||||||
//
|
//
|
||||||
const AttributeMapType empty_attr_map_;
|
const AttributeMapType _emptyAttrMap;
|
||||||
|
|
||||||
// Return the element entry corresponding to the current depth, if
|
// Return the element entry corresponding to the current depth, if
|
||||||
// exists, and NULL otherwise.
|
// exists, and NULL otherwise.
|
||||||
@ -390,32 +390,32 @@ XML_API std::ostream& operator<<(std::ostream&, XMLStreamParser::EventType);
|
|||||||
inline XMLStreamParser::EventType XMLStreamParser::event()
|
inline XMLStreamParser::EventType XMLStreamParser::event()
|
||||||
// Return the even that was last returned by the call to next() or peek().
|
// Return the even that was last returned by the call to next() or peek().
|
||||||
{
|
{
|
||||||
return event_;
|
return _currentEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::string& XMLStreamParser::inputName() const
|
inline const std::string& XMLStreamParser::inputName() const
|
||||||
{
|
{
|
||||||
return iname_;
|
return _inputName;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QName& XMLStreamParser::getQName() const
|
inline const QName& XMLStreamParser::getQName() const
|
||||||
{
|
{
|
||||||
return *pqname_;
|
return *_qualifiedName;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::string& XMLStreamParser::namespace_() const
|
inline const std::string& XMLStreamParser::namespace_() const
|
||||||
{
|
{
|
||||||
return pqname_->namespace_();
|
return _qualifiedName->namespace_();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::string& XMLStreamParser::name() const
|
inline const std::string& XMLStreamParser::name() const
|
||||||
{
|
{
|
||||||
return pqname_->name();
|
return _qualifiedName->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::string& XMLStreamParser::prefix() const
|
inline const std::string& XMLStreamParser::prefix() const
|
||||||
{
|
{
|
||||||
return pqname_->prefix();
|
return _qualifiedName->prefix();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string& XMLStreamParser::value()
|
inline std::string& XMLStreamParser::value()
|
||||||
@ -431,22 +431,22 @@ inline const std::string& XMLStreamParser::value() const
|
|||||||
|
|
||||||
inline Poco::UInt64 XMLStreamParser::line() const
|
inline Poco::UInt64 XMLStreamParser::line() const
|
||||||
{
|
{
|
||||||
return line_;
|
return _line;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Poco::UInt64 XMLStreamParser::column() const
|
inline Poco::UInt64 XMLStreamParser::column() const
|
||||||
{
|
{
|
||||||
return column_;
|
return _column;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline XMLStreamParser::EventType XMLStreamParser::peek()
|
inline XMLStreamParser::EventType XMLStreamParser::peek()
|
||||||
{
|
{
|
||||||
if (state_ == state_peek)
|
if (_parserState == state_peek)
|
||||||
return event_;
|
return _currentEvent;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EventType e(next_(true));
|
EventType e(next_(true));
|
||||||
state_ = state_peek; // Set it after the call to next_().
|
_parserState = state_peek; // Set it after the call to next_().
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -494,11 +494,11 @@ inline const XMLStreamParser::AttributeMapType& XMLStreamParser::attributeMap()
|
|||||||
{
|
{
|
||||||
if (const ElementEntry* e = getElement())
|
if (const ElementEntry* e = getElement())
|
||||||
{
|
{
|
||||||
e->attr_unhandled_ = 0; // Assume all handled.
|
e->attributesUnhandled_ = 0; // Assume all handled.
|
||||||
return e->attr_map_;
|
return e->attr_map_;
|
||||||
}
|
}
|
||||||
|
|
||||||
return empty_attr_map_;
|
return _emptyAttrMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void XMLStreamParser::nextExpect(EventType e, const QName& qn)
|
inline void XMLStreamParser::nextExpect(EventType e, const QName& qn)
|
||||||
@ -575,24 +575,24 @@ inline T XMLStreamParser::element(const std::string& n, const T& dv)
|
|||||||
|
|
||||||
inline void XMLStreamParser::content(Content c)
|
inline void XMLStreamParser::content(Content c)
|
||||||
{
|
{
|
||||||
assert(state_ == state_next);
|
assert(_parserState == state_next);
|
||||||
|
|
||||||
if (!element_state_.empty() && element_state_.back().depth == depth_)
|
if (!_elementState.empty() && _elementState.back().depth == depth_)
|
||||||
element_state_.back().content = c;
|
_elementState.back().content = c;
|
||||||
else
|
else
|
||||||
element_state_.push_back(ElementEntry(depth_, c));
|
_elementState.push_back(ElementEntry(depth_, c));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Content XMLStreamParser::content() const
|
inline Content XMLStreamParser::content() const
|
||||||
{
|
{
|
||||||
assert(state_ == state_next);
|
assert(_parserState == state_next);
|
||||||
|
|
||||||
return !element_state_.empty() && element_state_.back().depth == depth_ ? element_state_.back().content : Content(Content::Mixed);
|
return !_elementState.empty() && _elementState.back().depth == depth_ ? _elementState.back().content : Content(Content::Mixed);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const XMLStreamParser::ElementEntry* XMLStreamParser::getElement() const
|
inline const XMLStreamParser::ElementEntry* XMLStreamParser::getElement() const
|
||||||
{
|
{
|
||||||
return element_state_.empty() ? 0 : get_element_();
|
return _elementState.empty() ? 0 : get_element_();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@ -607,7 +607,7 @@ T XMLStreamParser::attribute(const QName& qn, const T& dv) const
|
|||||||
if (!i->second.handled)
|
if (!i->second.handled)
|
||||||
{
|
{
|
||||||
i->second.handled = true;
|
i->second.handled = true;
|
||||||
e->attr_unhandled_--;
|
e->attributesUnhandled_--;
|
||||||
}
|
}
|
||||||
return ValueTraits < T > ::parse(i->second.value, *this);
|
return ValueTraits < T > ::parse(i->second.value, *this);
|
||||||
}
|
}
|
||||||
|
@ -92,19 +92,19 @@ ostream& operator<<(ostream& os, XMLStreamParser::EventType e)
|
|||||||
|
|
||||||
|
|
||||||
XMLStreamParser::XMLStreamParser(std::istream& is, const std::string& iname, FeatureType f)
|
XMLStreamParser::XMLStreamParser(std::istream& is, const std::string& iname, FeatureType f)
|
||||||
: size_(0), iname_(iname), feature_(f)
|
: _size(0), _inputName(iname), feature_(f)
|
||||||
{
|
{
|
||||||
data_.is = &is;
|
_data.is = &is;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XMLStreamParser::XMLStreamParser(const void* data, std::size_t size, const std::string& iname, FeatureType f)
|
XMLStreamParser::XMLStreamParser(const void* data, std::size_t size, const std::string& iname, FeatureType f)
|
||||||
: size_(size), iname_(iname), feature_(f)
|
: _size(size), _inputName(iname), feature_(f)
|
||||||
{
|
{
|
||||||
assert(data != 0 && size != 0);
|
assert(data != 0 && size != 0);
|
||||||
|
|
||||||
data_.buf = data;
|
_data.buf = data;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,17 +119,17 @@ XMLStreamParser::~XMLStreamParser()
|
|||||||
void XMLStreamParser::init()
|
void XMLStreamParser::init()
|
||||||
{
|
{
|
||||||
depth_ = 0;
|
depth_ = 0;
|
||||||
state_ = state_next;
|
_parserState = state_next;
|
||||||
event_ = Eof;
|
_currentEvent = Eof;
|
||||||
queue_ = Eof;
|
queue_ = Eof;
|
||||||
|
|
||||||
pqname_ = &qname_;
|
_qualifiedName = &qname_;
|
||||||
pvalue_ = &value_;
|
pvalue_ = &value_;
|
||||||
|
|
||||||
line_ = 0;
|
_line = 0;
|
||||||
column_ = 0;
|
_column = 0;
|
||||||
|
|
||||||
attr_i_ = 0;
|
_currentAttributeIndex = 0;
|
||||||
start_ns_i_ = 0;
|
start_ns_i_ = 0;
|
||||||
end_ns_i_ = 0;
|
end_ns_i_ = 0;
|
||||||
|
|
||||||
@ -188,24 +188,24 @@ void XMLStreamParser::handle_error()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw XMLStreamParserException(iname_, XML_GetCurrentLineNumber(p_), XML_GetCurrentColumnNumber(p_), XML_ErrorString(e));
|
throw XMLStreamParserException(_inputName, XML_GetCurrentLineNumber(p_), XML_GetCurrentColumnNumber(p_), XML_ErrorString(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XMLStreamParser::EventType XMLStreamParser::next()
|
XMLStreamParser::EventType XMLStreamParser::next()
|
||||||
{
|
{
|
||||||
if (state_ == state_next)
|
if (_parserState == state_next)
|
||||||
return next_(false);
|
return next_(false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If we previously peeked at start/end_element, then adjust
|
// If we previously peeked at start/end_element, then adjust
|
||||||
// state accordingly.
|
// state accordingly.
|
||||||
//
|
//
|
||||||
switch (event_)
|
switch (_currentEvent)
|
||||||
{
|
{
|
||||||
case EndElement:
|
case EndElement:
|
||||||
{
|
{
|
||||||
if (!element_state_.empty() && element_state_.back().depth == depth_)
|
if (!_elementState.empty() && _elementState.back().depth == depth_)
|
||||||
popElement();
|
popElement();
|
||||||
|
|
||||||
depth_--;
|
depth_--;
|
||||||
@ -220,8 +220,8 @@ XMLStreamParser::EventType XMLStreamParser::next()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
state_ = state_next;
|
_parserState = state_next;
|
||||||
return event_;
|
return _currentEvent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ const string& XMLStreamParser::attribute(const QName& qn) const
|
|||||||
if (!i->second.handled)
|
if (!i->second.handled)
|
||||||
{
|
{
|
||||||
i->second.handled = true;
|
i->second.handled = true;
|
||||||
e->attr_unhandled_--;
|
e->attributesUnhandled_--;
|
||||||
}
|
}
|
||||||
return i->second.value;
|
return i->second.value;
|
||||||
}
|
}
|
||||||
@ -258,7 +258,7 @@ string XMLStreamParser::attribute(const QName& qn, const string& dv) const
|
|||||||
if (!i->second.handled)
|
if (!i->second.handled)
|
||||||
{
|
{
|
||||||
i->second.handled = true;
|
i->second.handled = true;
|
||||||
e->attr_unhandled_--;
|
e->attributesUnhandled_--;
|
||||||
}
|
}
|
||||||
return i->second.value;
|
return i->second.value;
|
||||||
}
|
}
|
||||||
@ -279,7 +279,7 @@ bool XMLStreamParser::attributePresent(const QName& qn) const
|
|||||||
if (!i->second.handled)
|
if (!i->second.handled)
|
||||||
{
|
{
|
||||||
i->second.handled = true;
|
i->second.handled = true;
|
||||||
e->attr_unhandled_--;
|
e->attributesUnhandled_--;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -346,15 +346,15 @@ const XMLStreamParser::ElementEntry* XMLStreamParser::get_element_() const
|
|||||||
// one before it, if any.
|
// one before it, if any.
|
||||||
//
|
//
|
||||||
const ElementEntry* r(0);
|
const ElementEntry* r(0);
|
||||||
ElementState::size_type n(element_state_.size() - 1);
|
ElementState::size_type n(_elementState.size() - 1);
|
||||||
|
|
||||||
if (element_state_[n].depth == depth_)
|
if (_elementState[n].depth == depth_)
|
||||||
r = &element_state_[n];
|
r = &_elementState[n];
|
||||||
else if (n != 0 && element_state_[n].depth > depth_)
|
else if (n != 0 && _elementState[n].depth > depth_)
|
||||||
{
|
{
|
||||||
n--;
|
n--;
|
||||||
if (element_state_[n].depth == depth_)
|
if (_elementState[n].depth == depth_)
|
||||||
r = &element_state_[n];
|
r = &_elementState[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
@ -365,8 +365,8 @@ void XMLStreamParser::popElement()
|
|||||||
{
|
{
|
||||||
// Make sure there are no unhandled attributes left.
|
// Make sure there are no unhandled attributes left.
|
||||||
//
|
//
|
||||||
const ElementEntry& e(element_state_.back());
|
const ElementEntry& e(_elementState.back());
|
||||||
if (e.attr_unhandled_ != 0)
|
if (e.attributesUnhandled_ != 0)
|
||||||
{
|
{
|
||||||
// Find the first unhandled attribute and report it.
|
// Find the first unhandled attribute and report it.
|
||||||
//
|
//
|
||||||
@ -378,7 +378,7 @@ void XMLStreamParser::popElement()
|
|||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
element_state_.pop_back();
|
_elementState.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ XMLStreamParser::EventType XMLStreamParser::next_(bool peek)
|
|||||||
//
|
//
|
||||||
if (!peek)
|
if (!peek)
|
||||||
{
|
{
|
||||||
if (!element_state_.empty() && element_state_.back().depth == depth_)
|
if (!_elementState.empty() && _elementState.back().depth == depth_)
|
||||||
popElement();
|
popElement();
|
||||||
|
|
||||||
depth_--;
|
depth_--;
|
||||||
@ -448,7 +448,7 @@ XMLStreamParser::EventType XMLStreamParser::next_body()
|
|||||||
{
|
{
|
||||||
// Based on the previous event determine what's the next one must be.
|
// Based on the previous event determine what's the next one must be.
|
||||||
//
|
//
|
||||||
switch (event_)
|
switch (_currentEvent)
|
||||||
{
|
{
|
||||||
case StartNamespaceDecl:
|
case StartNamespaceDecl:
|
||||||
{
|
{
|
||||||
@ -456,51 +456,51 @@ XMLStreamParser::EventType XMLStreamParser::next_body()
|
|||||||
{
|
{
|
||||||
start_ns_i_ = 0;
|
start_ns_i_ = 0;
|
||||||
start_ns_.clear();
|
start_ns_.clear();
|
||||||
pqname_ = &qname_;
|
_qualifiedName = &qname_;
|
||||||
break; // No more declarations.
|
break; // No more declarations.
|
||||||
}
|
}
|
||||||
// Fall through.
|
// Fall through.
|
||||||
}
|
}
|
||||||
case StartElement:
|
case StartElement:
|
||||||
{
|
{
|
||||||
event_ = StartNamespaceDecl;
|
_currentEvent = StartNamespaceDecl;
|
||||||
pqname_ = &start_ns_[start_ns_i_];
|
_qualifiedName = &start_ns_[start_ns_i_];
|
||||||
return event_;
|
return _currentEvent;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
assert(false);
|
assert(false);
|
||||||
return event_ = Eof;
|
return _currentEvent = Eof;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if we have any attributes we need to return as events.
|
// See if we have any attributes we need to return as events.
|
||||||
//
|
//
|
||||||
if (attr_i_ < attr_.size())
|
if (_currentAttributeIndex < _attributes.size())
|
||||||
{
|
{
|
||||||
// Based on the previous event determine what's the next one must be.
|
// Based on the previous event determine what's the next one must be.
|
||||||
//
|
//
|
||||||
switch (event_)
|
switch (_currentEvent)
|
||||||
{
|
{
|
||||||
case StartAttribute:
|
case StartAttribute:
|
||||||
{
|
{
|
||||||
event_ = Characters;
|
_currentEvent = Characters;
|
||||||
pvalue_ = &attr_[attr_i_].value;
|
pvalue_ = &_attributes[_currentAttributeIndex].value;
|
||||||
return event_;
|
return _currentEvent;
|
||||||
}
|
}
|
||||||
case Characters:
|
case Characters:
|
||||||
{
|
{
|
||||||
event_ = EndAttribute; // Name is already set.
|
_currentEvent = EndAttribute; // Name is already set.
|
||||||
return event_;
|
return _currentEvent;
|
||||||
}
|
}
|
||||||
case EndAttribute:
|
case EndAttribute:
|
||||||
{
|
{
|
||||||
if (++attr_i_ == attr_.size())
|
if (++_currentAttributeIndex == _attributes.size())
|
||||||
{
|
{
|
||||||
attr_i_ = 0;
|
_currentAttributeIndex = 0;
|
||||||
attr_.clear();
|
_attributes.clear();
|
||||||
pqname_ = &qname_;
|
_qualifiedName = &qname_;
|
||||||
pvalue_ = &value_;
|
pvalue_ = &value_;
|
||||||
break; // No more attributes.
|
break; // No more attributes.
|
||||||
}
|
}
|
||||||
@ -509,14 +509,14 @@ XMLStreamParser::EventType XMLStreamParser::next_body()
|
|||||||
case StartElement:
|
case StartElement:
|
||||||
case StartNamespaceDecl:
|
case StartNamespaceDecl:
|
||||||
{
|
{
|
||||||
event_ = StartAttribute;
|
_currentEvent = StartAttribute;
|
||||||
pqname_ = &attr_[attr_i_].qname;
|
_qualifiedName = &_attributes[_currentAttributeIndex].qname;
|
||||||
return event_;
|
return _currentEvent;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
assert(false);
|
assert(false);
|
||||||
return event_ = Eof;
|
return _currentEvent = Eof;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -527,7 +527,7 @@ XMLStreamParser::EventType XMLStreamParser::next_body()
|
|||||||
{
|
{
|
||||||
// Based on the previous event determine what's the next one must be.
|
// Based on the previous event determine what's the next one must be.
|
||||||
//
|
//
|
||||||
switch (event_)
|
switch (_currentEvent)
|
||||||
{
|
{
|
||||||
case EndNamespaceDecl:
|
case EndNamespaceDecl:
|
||||||
{
|
{
|
||||||
@ -535,7 +535,7 @@ XMLStreamParser::EventType XMLStreamParser::next_body()
|
|||||||
{
|
{
|
||||||
end_ns_i_ = 0;
|
end_ns_i_ = 0;
|
||||||
end_ns_.clear();
|
end_ns_.clear();
|
||||||
pqname_ = &qname_;
|
_qualifiedName = &qname_;
|
||||||
break; // No more declarations.
|
break; // No more declarations.
|
||||||
}
|
}
|
||||||
// Fall through.
|
// Fall through.
|
||||||
@ -545,9 +545,9 @@ XMLStreamParser::EventType XMLStreamParser::next_body()
|
|||||||
//
|
//
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
event_ = EndNamespaceDecl;
|
_currentEvent = EndNamespaceDecl;
|
||||||
pqname_ = &end_ns_[end_ns_i_];
|
_qualifiedName = &end_ns_[end_ns_i_];
|
||||||
return event_;
|
return _currentEvent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -556,18 +556,18 @@ XMLStreamParser::EventType XMLStreamParser::next_body()
|
|||||||
//
|
//
|
||||||
if (queue_ != Eof)
|
if (queue_ != Eof)
|
||||||
{
|
{
|
||||||
event_ = queue_;
|
_currentEvent = queue_;
|
||||||
queue_ = Eof;
|
queue_ = Eof;
|
||||||
|
|
||||||
line_ = XML_GetCurrentLineNumber(p_);
|
_line = XML_GetCurrentLineNumber(p_);
|
||||||
column_ = XML_GetCurrentColumnNumber(p_);
|
_column = XML_GetCurrentColumnNumber(p_);
|
||||||
|
|
||||||
return event_;
|
return _currentEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the character accumulation flag.
|
// Reset the character accumulation flag.
|
||||||
//
|
//
|
||||||
accumulate_ = false;
|
_accumulateContent = false;
|
||||||
|
|
||||||
XML_ParsingStatus ps;
|
XML_ParsingStatus ps;
|
||||||
XML_GetParsingStatus(p_, &ps);
|
XML_GetParsingStatus(p_, &ps);
|
||||||
@ -582,11 +582,11 @@ XMLStreamParser::EventType XMLStreamParser::next_body()
|
|||||||
case XML_PARSING:
|
case XML_PARSING:
|
||||||
{
|
{
|
||||||
assert(false);
|
assert(false);
|
||||||
return event_ = Eof;
|
return _currentEvent = Eof;
|
||||||
}
|
}
|
||||||
case XML_FINISHED:
|
case XML_FINISHED:
|
||||||
{
|
{
|
||||||
return event_ = Eof;
|
return _currentEvent = Eof;
|
||||||
}
|
}
|
||||||
case XML_SUSPENDED:
|
case XML_SUSPENDED:
|
||||||
{
|
{
|
||||||
@ -597,7 +597,7 @@ XMLStreamParser::EventType XMLStreamParser::next_body()
|
|||||||
// If the XMLStreamParser is again in the suspended state, then
|
// If the XMLStreamParser is again in the suspended state, then
|
||||||
// that means we have the next event.
|
// that means we have the next event.
|
||||||
//
|
//
|
||||||
return event_;
|
return _currentEvent;
|
||||||
}
|
}
|
||||||
case XML_STATUS_OK:
|
case XML_STATUS_OK:
|
||||||
{
|
{
|
||||||
@ -605,7 +605,7 @@ XMLStreamParser::EventType XMLStreamParser::next_body()
|
|||||||
// unless this was the last chunk, in which case this is eof.
|
// unless this was the last chunk, in which case this is eof.
|
||||||
//
|
//
|
||||||
if (ps.finalBuffer)
|
if (ps.finalBuffer)
|
||||||
return event_ = Eof;
|
return _currentEvent = Eof;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -619,15 +619,15 @@ XMLStreamParser::EventType XMLStreamParser::next_body()
|
|||||||
// Get and parse the next chunk of data until we get the next event
|
// Get and parse the next chunk of data until we get the next event
|
||||||
// or reach eof.
|
// or reach eof.
|
||||||
//
|
//
|
||||||
if (!accumulate_)
|
if (!_accumulateContent)
|
||||||
event_ = Eof;
|
_currentEvent = Eof;
|
||||||
|
|
||||||
XML_Status s;
|
XML_Status s;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (size_ != 0)
|
if (_size != 0)
|
||||||
{
|
{
|
||||||
s = XML_Parse(p_, static_cast<const char*>(data_.buf), static_cast<int>(size_), true);
|
s = XML_Parse(p_, static_cast<const char*>(_data.buf), static_cast<int>(_size), true);
|
||||||
|
|
||||||
if (s == XML_STATUS_ERROR)
|
if (s == XML_STATUS_ERROR)
|
||||||
handle_error();
|
handle_error();
|
||||||
@ -645,7 +645,7 @@ XMLStreamParser::EventType XMLStreamParser::next_body()
|
|||||||
// Temporarily unset the exception failbit. Also clear the fail bit
|
// Temporarily unset the exception failbit. Also clear the fail bit
|
||||||
// when we reset the old state if it was caused by eof.
|
// when we reset the old state if it was caused by eof.
|
||||||
//
|
//
|
||||||
istream& is(*data_.is);
|
istream& is(*_data.is);
|
||||||
{
|
{
|
||||||
stream_exception_controller sec(is);
|
stream_exception_controller sec(is);
|
||||||
is.read(b, static_cast<streamsize>(cap));
|
is.read(b, static_cast<streamsize>(cap));
|
||||||
@ -669,7 +669,7 @@ XMLStreamParser::EventType XMLStreamParser::next_body()
|
|||||||
}
|
}
|
||||||
} while (s != XML_STATUS_SUSPENDED);
|
} while (s != XML_STATUS_SUSPENDED);
|
||||||
|
|
||||||
return event_;
|
return _currentEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -729,22 +729,22 @@ void XMLCALL XMLStreamParser::start_element_(void* v, const XML_Char* name, cons
|
|||||||
// see more characters or end element. Seeing start element is
|
// see more characters or end element. Seeing start element is
|
||||||
// possible but means violation of the content model.
|
// possible but means violation of the content model.
|
||||||
//
|
//
|
||||||
if (p.accumulate_)
|
if (p._accumulateContent)
|
||||||
{
|
{
|
||||||
// It would have been easier to throw the exception directly,
|
// It would have been easier to throw the exception directly,
|
||||||
// however, the Expat code is most likely not exception safe.
|
// however, the Expat code is most likely not exception safe.
|
||||||
//
|
//
|
||||||
p.line_ = XML_GetCurrentLineNumber(p.p_);
|
p._line = XML_GetCurrentLineNumber(p.p_);
|
||||||
p.column_ = XML_GetCurrentColumnNumber(p.p_);
|
p._column = XML_GetCurrentColumnNumber(p.p_);
|
||||||
XML_StopParser(p.p_, false);
|
XML_StopParser(p.p_, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.event_ = StartElement;
|
p._currentEvent = StartElement;
|
||||||
splitName(name, p.qname_);
|
splitName(name, p.qname_);
|
||||||
|
|
||||||
p.line_ = XML_GetCurrentLineNumber(p.p_);
|
p._line = XML_GetCurrentLineNumber(p.p_);
|
||||||
p.column_ = XML_GetCurrentColumnNumber(p.p_);
|
p._column = XML_GetCurrentColumnNumber(p.p_);
|
||||||
|
|
||||||
// Handle attributes.
|
// Handle attributes.
|
||||||
//
|
//
|
||||||
@ -758,8 +758,8 @@ void XMLCALL XMLStreamParser::start_element_(void* v, const XML_Char* name, cons
|
|||||||
ElementEntry* pe(0);
|
ElementEntry* pe(0);
|
||||||
if (am)
|
if (am)
|
||||||
{
|
{
|
||||||
p.element_state_.push_back(ElementEntry(p.depth_ + 1));
|
p._elementState.push_back(ElementEntry(p.depth_ + 1));
|
||||||
pe = &p.element_state_.back();
|
pe = &p._elementState.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (am || ae)
|
if (am || ae)
|
||||||
@ -777,14 +777,14 @@ void XMLCALL XMLStreamParser::start_element_(void* v, const XML_Char* name, cons
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p.attr_.push_back(attribute_type());
|
p._attributes.push_back(attribute_type());
|
||||||
splitName(*atts, p.attr_.back().qname);
|
splitName(*atts, p._attributes.back().qname);
|
||||||
p.attr_.back().value = *(atts + 1);
|
p._attributes.back().value = *(atts + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (am)
|
if (am)
|
||||||
pe->attr_unhandled_ = pe->attr_map_.size();
|
pe->attributesUnhandled_ = pe->attr_map_.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -816,14 +816,14 @@ void XMLCALL XMLStreamParser::end_element_(void* v, const XML_Char* name)
|
|||||||
|
|
||||||
// If we are accumulating characters, then queue this event.
|
// If we are accumulating characters, then queue this event.
|
||||||
//
|
//
|
||||||
if (p.accumulate_)
|
if (p._accumulateContent)
|
||||||
p.queue_ = EndElement;
|
p.queue_ = EndElement;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p.event_ = EndElement;
|
p._currentEvent = EndElement;
|
||||||
|
|
||||||
p.line_ = XML_GetCurrentLineNumber(p.p_);
|
p._line = XML_GetCurrentLineNumber(p.p_);
|
||||||
p.column_ = XML_GetCurrentColumnNumber(p.p_);
|
p._column = XML_GetCurrentColumnNumber(p.p_);
|
||||||
}
|
}
|
||||||
|
|
||||||
XML_StopParser(p.p_, true);
|
XML_StopParser(p.p_, true);
|
||||||
@ -862,8 +862,8 @@ void XMLCALL XMLStreamParser::characters_(void* v, const XML_Char* s, int n)
|
|||||||
// It would have been easier to throw the exception directly,
|
// It would have been easier to throw the exception directly,
|
||||||
// however, the Expat code is most likely not exception safe.
|
// however, the Expat code is most likely not exception safe.
|
||||||
//
|
//
|
||||||
p.line_ = XML_GetCurrentLineNumber(p.p_);
|
p._line = XML_GetCurrentLineNumber(p.p_);
|
||||||
p.column_ = XML_GetCurrentColumnNumber(p.p_);
|
p._column = XML_GetCurrentColumnNumber(p.p_);
|
||||||
XML_StopParser(p.p_, false);
|
XML_StopParser(p.p_, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -877,25 +877,25 @@ void XMLCALL XMLStreamParser::characters_(void* v, const XML_Char* s, int n)
|
|||||||
// followup event for another character event. In this case also
|
// followup event for another character event. In this case also
|
||||||
// append the data.
|
// append the data.
|
||||||
//
|
//
|
||||||
if (p.accumulate_ || ps.parsing != XML_PARSING)
|
if (p._accumulateContent || ps.parsing != XML_PARSING)
|
||||||
{
|
{
|
||||||
assert(p.event_ == Characters);
|
assert(p._currentEvent == Characters);
|
||||||
p.value_.append(s, n);
|
p.value_.append(s, n);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p.event_ = Characters;
|
p._currentEvent = Characters;
|
||||||
p.value_.assign(s, n);
|
p.value_.assign(s, n);
|
||||||
|
|
||||||
p.line_ = XML_GetCurrentLineNumber(p.p_);
|
p._line = XML_GetCurrentLineNumber(p.p_);
|
||||||
p.column_ = XML_GetCurrentColumnNumber(p.p_);
|
p._column = XML_GetCurrentColumnNumber(p.p_);
|
||||||
|
|
||||||
// In simple content we need to accumulate all the characters
|
// In simple content we need to accumulate all the characters
|
||||||
// into a single event. To do this we will let the XMLStreamParser run
|
// into a single event. To do this we will let the XMLStreamParser run
|
||||||
// until we reach the end of the element.
|
// until we reach the end of the element.
|
||||||
//
|
//
|
||||||
if (cont == Content::Simple)
|
if (cont == Content::Simple)
|
||||||
p.accumulate_ = true;
|
p._accumulateContent = true;
|
||||||
else
|
else
|
||||||
XML_StopParser(p.p_, true);
|
XML_StopParser(p.p_, true);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user