mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-poco.git
synced 2025-10-29 17:52:44 +00:00
merge some changes from develop branch; modernize and clean-up code; remove support for compiling without POCO_WIN32_UTF8
This commit is contained in:
@@ -65,15 +65,15 @@ public:
|
||||
DOMException(const DOMException& exc);
|
||||
/// Creates a DOMException by copying another one.
|
||||
|
||||
~DOMException() throw();
|
||||
~DOMException() noexcept;
|
||||
/// Destroys the DOMException.
|
||||
|
||||
DOMException& operator = (const DOMException& exc);
|
||||
|
||||
const char* name() const throw();
|
||||
const char* name() const noexcept;
|
||||
/// Returns a static string describing the exception.
|
||||
|
||||
const char* className() const throw();
|
||||
const char* className() const noexcept;
|
||||
/// Returns the name of the exception class.
|
||||
|
||||
Poco::Exception* clone() const;
|
||||
|
||||
@@ -58,7 +58,7 @@ class XML_API Document: public AbstractContainerNode, public DocumentEvent
|
||||
/// context they were created.
|
||||
{
|
||||
public:
|
||||
typedef Poco::AutoReleasePool<DOMObject> AutoReleasePool;
|
||||
using AutoReleasePool = Poco::AutoReleasePool<DOMObject>;
|
||||
|
||||
explicit Document(NamePool* pNamePool = 0);
|
||||
/// Creates a new document. If pNamePool == 0, the document
|
||||
|
||||
@@ -44,15 +44,15 @@ public:
|
||||
EventException(const EventException& exc);
|
||||
/// Creates an EventException by copying another one.
|
||||
|
||||
~EventException() throw();
|
||||
~EventException() noexcept;
|
||||
/// Destroys the EventException.
|
||||
|
||||
EventException& operator = (const EventException& exc);
|
||||
|
||||
const char* name() const throw();
|
||||
const char* name() const noexcept;
|
||||
/// Returns a static string describing the exception.
|
||||
|
||||
const char* className() const throw();
|
||||
const char* className() const noexcept;
|
||||
/// Returns the name of the exception class.
|
||||
|
||||
unsigned short code() const;
|
||||
|
||||
@@ -208,7 +208,7 @@ public:
|
||||
/// Returns whether this node (if it is an element) has any attributes.
|
||||
|
||||
// Extensions
|
||||
typedef Poco::XML::NamespaceSupport NSMap;
|
||||
using NSMap = Poco::XML::NamespaceSupport;
|
||||
|
||||
virtual XMLString innerText() const = 0;
|
||||
/// Returns a string containing the concatenated values of the node
|
||||
|
||||
@@ -45,8 +45,8 @@ public:
|
||||
XMLString type;
|
||||
bool specified;
|
||||
};
|
||||
typedef std::vector<Attribute> AttributeVec;
|
||||
typedef AttributeVec::const_iterator iterator;
|
||||
using AttributeVec = std::vector<Attribute>;
|
||||
using iterator = AttributeVec::const_iterator;
|
||||
|
||||
AttributesImpl();
|
||||
/// Creates the AttributesImpl.
|
||||
@@ -57,12 +57,18 @@ public:
|
||||
AttributesImpl(const AttributesImpl& attributes);
|
||||
/// Creates the AttributesImpl by copying another one.
|
||||
|
||||
AttributesImpl(AttributesImpl&& attributes) noexcept;
|
||||
/// Creates the AttributesImpl by copying another one.
|
||||
|
||||
~AttributesImpl();
|
||||
/// Destroys the AttributesImpl.
|
||||
|
||||
AttributesImpl& operator = (const AttributesImpl& attributes);
|
||||
/// Assignment operator.
|
||||
|
||||
AttributesImpl& operator = (AttributesImpl&& attributes) noexcept;
|
||||
/// Assignment operator.
|
||||
|
||||
int getIndex(const XMLString& name) const;
|
||||
int getIndex(const XMLString& namespaceURI, const XMLString& localName) const;
|
||||
int getLength() const;
|
||||
@@ -154,9 +160,14 @@ protected:
|
||||
Attribute* find(const XMLString& qname) const;
|
||||
Attribute* find(const XMLString& namespaceURI, const XMLString& localName) const;
|
||||
|
||||
struct EmptyAttribute: Attribute
|
||||
{
|
||||
EmptyAttribute();
|
||||
};
|
||||
|
||||
private:
|
||||
AttributeVec _attributes;
|
||||
Attribute _empty;
|
||||
static EmptyAttribute _empty;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class XML_API NamespaceSupport
|
||||
/// must be invoked between each session.
|
||||
{
|
||||
public:
|
||||
typedef std::set<XMLString> PrefixSet;
|
||||
using PrefixSet = std::set<XMLString>;
|
||||
|
||||
NamespaceSupport();
|
||||
/// Creates a NamespaceSupport object.
|
||||
|
||||
@@ -98,16 +98,16 @@ public:
|
||||
SAXParseException(const SAXParseException& exc);
|
||||
/// Creates a new SAXParseException from another one.
|
||||
|
||||
~SAXParseException() throw();
|
||||
~SAXParseException() noexcept;
|
||||
/// Destroy the exception.
|
||||
|
||||
SAXParseException& operator = (const SAXParseException& exc);
|
||||
/// Assignment operator.
|
||||
|
||||
const char* name() const throw();
|
||||
const char* name() const noexcept;
|
||||
/// Returns a static string describing the exception.
|
||||
|
||||
const char* className() const throw();
|
||||
const char* className() const noexcept;
|
||||
/// Returns the name of the exception class.
|
||||
|
||||
Poco::Exception* clone() const;
|
||||
|
||||
@@ -46,12 +46,18 @@ public:
|
||||
|
||||
Name(const Name& name);
|
||||
/// Copy constructor.
|
||||
|
||||
Name(Name&& name) noexcept;
|
||||
/// Move constructor.
|
||||
|
||||
~Name();
|
||||
/// Destroys the name.
|
||||
|
||||
Name& operator = (const Name& name);
|
||||
/// Assignment operator.
|
||||
|
||||
Name& operator = (Name&& name) noexcept;
|
||||
/// Move assignment.
|
||||
|
||||
void swap(Name& name);
|
||||
/// Swaps the name with another one.
|
||||
|
||||
@@ -42,6 +42,12 @@ public:
|
||||
QName(const std::string& name);
|
||||
QName(const std::string& ns, const std::string& name);
|
||||
QName(const std::string& ns, const std::string& name, const std::string& prefix);
|
||||
QName(const QName& qname);
|
||||
QName(QName&& qname) noexcept;
|
||||
|
||||
QName& operator = (const QName& qname);
|
||||
QName& operator = (QName&& qname) noexcept;
|
||||
void swap(QName& qname);
|
||||
|
||||
const std::string& namespaceURI() const;
|
||||
/// Returns the namespace URI part of the name.
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace XML {
|
||||
|
||||
|
||||
// The byte input stream is always a narrow stream.
|
||||
typedef std::istream XMLByteInputStream;
|
||||
typedef std::ostream XMLByteOutputStream;
|
||||
using XMLByteInputStream = std::istream;
|
||||
using XMLByteOutputStream = std::ostream;
|
||||
|
||||
|
||||
//
|
||||
@@ -49,8 +49,8 @@ typedef std::ostream XMLByteOutputStream;
|
||||
#if defined(XML_UNICODE_WCHAR_T)
|
||||
|
||||
// Unicode - use wide streams
|
||||
typedef std::wistream XMLCharInputStream;
|
||||
typedef std::wostream XMLCharOutputStream;
|
||||
using XMLCharInputStream = std::wistream;
|
||||
using XMLCharOutputStream = std::wostream;
|
||||
|
||||
#elif defined(XML_UNICODE)
|
||||
|
||||
@@ -59,8 +59,8 @@ typedef std::ostream XMLByteOutputStream;
|
||||
#else
|
||||
|
||||
// Characters are UTF-8 encoded
|
||||
typedef std::istream XMLCharInputStream;
|
||||
typedef std::ostream XMLCharOutputStream;
|
||||
using XMLCharInputStream = std::istream;
|
||||
using XMLCharOutputStream = std::ostream;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
EV_EOF
|
||||
};
|
||||
|
||||
typedef unsigned short FeatureType;
|
||||
using FeatureType = unsigned short;
|
||||
/// If both receive_attributes_event and RECEIVE_ATTRIBUTE_MAP are
|
||||
/// specified, then RECEIVE_ATTRIBUTES_EVENT is assumed.
|
||||
|
||||
@@ -116,20 +116,20 @@ public:
|
||||
static const FeatureType RECEIVE_NAMESPACE_DECLS = 0x0010;
|
||||
static const FeatureType RECEIVE_DEFAULT = RECEIVE_ELEMENTS | RECEIVE_CHARACTERS | RECEIVE_ATTRIBUTE_MAP;
|
||||
|
||||
struct XML_API AttributeValueType
|
||||
struct AttributeValueType
|
||||
{
|
||||
std::string value;
|
||||
mutable bool handled;
|
||||
};
|
||||
|
||||
typedef std::map<QName, AttributeValueType> AttributeMapType;
|
||||
using AttributeMapType = std::map<QName, AttributeValueType>;
|
||||
|
||||
struct XML_API Iterator
|
||||
// C++11 range-based for support. Generally, the iterator interface
|
||||
// doesn't make much sense for the XMLStreamParser so for now we have an
|
||||
// implementation that is just enough to the range-based for.
|
||||
{
|
||||
typedef EventType value_type;
|
||||
using value_type = EventType;
|
||||
|
||||
Iterator(XMLStreamParser* p = 0, EventType e = EV_EOF):
|
||||
_parser(p),
|
||||
@@ -575,7 +575,7 @@ inline void XMLStreamParser::content(Content c)
|
||||
if (!_elementState.empty() && _elementState.back().depth == _depth)
|
||||
_elementState.back().content = c;
|
||||
else
|
||||
_elementState.push_back(ElementEntry(_depth, c));
|
||||
_elementState.emplace_back(_depth, c);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
XMLStreamParserException(const XMLStreamParser&, const std::string& description);
|
||||
virtual ~XMLStreamParserException() throw ();
|
||||
|
||||
const char* name() const throw();
|
||||
const char* name() const noexcept;
|
||||
Poco::UInt64 line() const;
|
||||
Poco::UInt64 column() const;
|
||||
const std::string& description() const;
|
||||
|
||||
@@ -43,8 +43,8 @@ namespace XML {
|
||||
#if defined(XML_UNICODE_WCHAR_T)
|
||||
|
||||
// Unicode - use wchar_t
|
||||
typedef wchar_t XMLChar;
|
||||
typedef std::wstring XMLString;
|
||||
using XMLChar = wchar_t;
|
||||
using XMLString = std::wstring;
|
||||
|
||||
std::string fromXMLString(const XMLString& str);
|
||||
/// Converts an XMLString into an UTF-8 encoded
|
||||
@@ -63,8 +63,8 @@ namespace XML {
|
||||
#else
|
||||
|
||||
// Characters are UTF-8 encoded
|
||||
typedef char XMLChar;
|
||||
typedef std::string XMLString;
|
||||
using XMLChar = char;
|
||||
using XMLString = std::string;
|
||||
|
||||
inline const std::string& fromXMLString(const XMLString& str)
|
||||
{
|
||||
|
||||
@@ -280,7 +280,7 @@ public:
|
||||
|
||||
protected:
|
||||
typedef std::map<XMLString, XMLString> AttributeMap;
|
||||
typedef std::map<XMLString, std::pair<XMLString, XMLString> > CanonicalAttributeMap;
|
||||
typedef std::map<XMLString, std::pair<XMLString, XMLString>> CanonicalAttributeMap;
|
||||
|
||||
void writeStartElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes);
|
||||
void writeCanonicalStartElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes);
|
||||
|
||||
@@ -19,24 +19,35 @@ namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
AttributesImpl::EmptyAttribute::EmptyAttribute()
|
||||
{
|
||||
specified = false;
|
||||
type = XML_LIT("CDATA");
|
||||
}
|
||||
|
||||
|
||||
AttributesImpl::EmptyAttribute AttributesImpl::_empty;
|
||||
|
||||
|
||||
AttributesImpl::AttributesImpl()
|
||||
{
|
||||
_empty.specified = false;
|
||||
_empty.type = XML_LIT("CDATA");
|
||||
}
|
||||
|
||||
|
||||
AttributesImpl::AttributesImpl(const Attributes& attributes)
|
||||
{
|
||||
_empty.specified = false;
|
||||
_empty.type = XML_LIT("CDATA");
|
||||
setAttributes(attributes);
|
||||
}
|
||||
|
||||
|
||||
AttributesImpl::AttributesImpl(const AttributesImpl& attributes):
|
||||
_attributes(attributes._attributes),
|
||||
_empty(attributes._empty)
|
||||
_attributes(attributes._attributes)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AttributesImpl::AttributesImpl(AttributesImpl&& attributes) noexcept:
|
||||
_attributes(std::move(attributes._attributes))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -56,6 +67,14 @@ AttributesImpl& AttributesImpl::operator = (const AttributesImpl& attributes)
|
||||
}
|
||||
|
||||
|
||||
AttributesImpl& AttributesImpl::operator = (AttributesImpl&& attributes) noexcept
|
||||
{
|
||||
_attributes = std::move(attributes._attributes);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
int AttributesImpl::getIndex(const XMLString& qname) const
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
@@ -192,9 +192,9 @@ void DOMBuilder::startElement(const XMLString& uri, const XMLString& localName,
|
||||
|
||||
const AttributesImpl& attrs = dynamic_cast<const AttributesImpl&>(attributes);
|
||||
Attr* pPrevAttr = 0;
|
||||
for (AttributesImpl::iterator it = attrs.begin(); it != attrs.end(); ++it)
|
||||
for (const auto& attr: attrs)
|
||||
{
|
||||
AutoPtr<Attr> pAttr = new Attr(_pDocument, 0, it->namespaceURI, it->localName, it->qname, it->value, it->specified);
|
||||
AutoPtr<Attr> pAttr = new Attr(_pDocument, 0, attr.namespaceURI, attr.localName, attr.qname, attr.value, attr.specified);
|
||||
pPrevAttr = pElem->addAttributeNodeNP(pPrevAttr, pAttr);
|
||||
}
|
||||
appendNode(pElem);
|
||||
|
||||
@@ -55,7 +55,7 @@ DOMException::DOMException(const DOMException& exc):
|
||||
}
|
||||
|
||||
|
||||
DOMException::~DOMException() throw()
|
||||
DOMException::~DOMException() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
@@ -71,13 +71,13 @@ DOMException& DOMException::operator = (const DOMException& exc)
|
||||
}
|
||||
|
||||
|
||||
const char* DOMException::name() const throw()
|
||||
const char* DOMException::name() const noexcept
|
||||
{
|
||||
return "DOMException";
|
||||
}
|
||||
|
||||
|
||||
const char* DOMException::className() const throw()
|
||||
const char* DOMException::className() const noexcept
|
||||
{
|
||||
return typeid(*this).name();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ EventException::EventException(const EventException& exc):
|
||||
}
|
||||
|
||||
|
||||
EventException::~EventException() throw()
|
||||
EventException::~EventException() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
@@ -44,13 +44,13 @@ EventException& EventException::operator = (const EventException& exc)
|
||||
}
|
||||
|
||||
|
||||
const char* EventException::name() const throw()
|
||||
const char* EventException::name() const noexcept
|
||||
{
|
||||
return "EventException";
|
||||
}
|
||||
|
||||
|
||||
const char* EventException::className() const throw()
|
||||
const char* EventException::className() const noexcept
|
||||
{
|
||||
return typeid(*this).name();
|
||||
}
|
||||
|
||||
@@ -57,6 +57,14 @@ Name::Name(const Name& name):
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Name::Name(Name&& name) noexcept:
|
||||
_qname(std::move(name._qname)),
|
||||
_namespaceURI(std::move(name._namespaceURI)),
|
||||
_localName(std::move(name._localName))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Name::~Name()
|
||||
{
|
||||
@@ -75,6 +83,16 @@ Name& Name::operator = (const Name& name)
|
||||
}
|
||||
|
||||
|
||||
Name& Name::operator = (Name&& name) noexcept
|
||||
{
|
||||
_qname = std::move(name._qname);
|
||||
_namespaceURI = std::move(name._namespaceURI);
|
||||
_localName = std::move(name._localName);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void Name::swap(Name& name)
|
||||
{
|
||||
std::swap(_qname, name._qname);
|
||||
|
||||
@@ -71,8 +71,8 @@ void NamespaceSupport::getDeclaredPrefixes(PrefixSet& prefixes) const
|
||||
{
|
||||
prefixes.clear();
|
||||
const Context& ctx = _contexts.back();
|
||||
for (Context::const_iterator it = ctx.begin(); it != ctx.end(); ++it)
|
||||
prefixes.insert(it->first);
|
||||
for (const auto& p: ctx)
|
||||
prefixes.insert(p.first);
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ const XMLString& NamespaceSupport::getURI(const XMLString& prefix) const
|
||||
|
||||
void NamespaceSupport::pushContext()
|
||||
{
|
||||
_contexts.push_back(Context());
|
||||
_contexts.emplace_back();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -603,9 +603,9 @@ void ParserEngine::popContext()
|
||||
|
||||
void ParserEngine::resetContext()
|
||||
{
|
||||
for (ContextStack::iterator it = _context.begin(); it != _context.end(); ++it)
|
||||
for (auto p: _context)
|
||||
{
|
||||
delete *it;
|
||||
delete p;
|
||||
}
|
||||
_context.clear();
|
||||
}
|
||||
|
||||
@@ -49,6 +49,48 @@ QName::QName(const std::string& ns, const std::string& name, const std::string&
|
||||
}
|
||||
|
||||
|
||||
QName::QName(const QName& qname):
|
||||
_ns(qname._ns),
|
||||
_name(qname._name),
|
||||
_prefix(qname._prefix)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QName::QName(QName&& qname) noexcept:
|
||||
_ns(std::move(qname._ns)),
|
||||
_name(std::move(qname._name)),
|
||||
_prefix(std::move(qname._prefix))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QName& QName::operator = (const QName& qname)
|
||||
{
|
||||
QName tmp(qname);
|
||||
swap(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
QName& QName::operator = (QName&& qname) noexcept
|
||||
{
|
||||
_ns = std::move(qname._ns);
|
||||
_name = std::move(qname._name);
|
||||
_prefix = std::move(qname._prefix);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void QName::swap(QName& qname)
|
||||
{
|
||||
std::swap(_ns, qname._ns);
|
||||
std::swap(_name, qname._name);
|
||||
std::swap(_prefix, qname._prefix);
|
||||
}
|
||||
|
||||
|
||||
std::string QName::toString() const
|
||||
{
|
||||
std::string r;
|
||||
|
||||
@@ -77,7 +77,7 @@ SAXParseException::SAXParseException(const SAXParseException& exc):
|
||||
}
|
||||
|
||||
|
||||
SAXParseException::~SAXParseException() throw()
|
||||
SAXParseException::~SAXParseException() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
@@ -96,13 +96,13 @@ SAXParseException& SAXParseException::operator = (const SAXParseException& exc)
|
||||
}
|
||||
|
||||
|
||||
const char* SAXParseException::name() const throw()
|
||||
const char* SAXParseException::name() const noexcept
|
||||
{
|
||||
return "SAXParseException";
|
||||
}
|
||||
|
||||
|
||||
const char* SAXParseException::className() const throw()
|
||||
const char* SAXParseException::className() const noexcept
|
||||
{
|
||||
return typeid(*this).name();
|
||||
}
|
||||
|
||||
@@ -367,10 +367,10 @@ void XMLStreamParser::popElement()
|
||||
{
|
||||
// Find the first unhandled attribute and report it.
|
||||
//
|
||||
for (AttributeMapType::const_iterator i(e.attributeMap.begin()); i != e.attributeMap.end(); ++i)
|
||||
for (const auto& p: e.attributeMap)
|
||||
{
|
||||
if (!i->second.handled)
|
||||
throw XMLStreamParserException(*this, "unexpected attribute '" + i->first.toString() + "'");
|
||||
if (!p.second.handled)
|
||||
throw XMLStreamParserException(*this, "unexpected attribute '" + p.first.toString() + "'");
|
||||
}
|
||||
poco_assert(false);
|
||||
}
|
||||
@@ -755,7 +755,7 @@ void XMLCALL XMLStreamParser::handleStartElement(void* v, const XML_Char* name,
|
||||
ElementEntry* pe(0);
|
||||
if (am)
|
||||
{
|
||||
p._elementState.push_back(ElementEntry(p._depth + 1));
|
||||
p._elementState.emplace_back(p._depth + 1);
|
||||
pe = &p._elementState.back();
|
||||
}
|
||||
|
||||
@@ -774,7 +774,7 @@ void XMLCALL XMLStreamParser::handleStartElement(void* v, const XML_Char* name,
|
||||
}
|
||||
else
|
||||
{
|
||||
p._attributes.push_back(AttributeType());
|
||||
p._attributes.emplace_back();
|
||||
splitName(*atts, p._attributes.back().qname);
|
||||
p._attributes.back().value = *(atts + 1);
|
||||
}
|
||||
@@ -912,7 +912,7 @@ void XMLCALL XMLStreamParser::handleStartNamespaceDecl(void* v, const XML_Char*
|
||||
if (ps.parsing == XML_FINISHED)
|
||||
return;
|
||||
|
||||
p._startNamespace.push_back(QName());
|
||||
p._startNamespace.emplace_back();
|
||||
p._startNamespace.back().prefix() = (prefix != 0 ? prefix : "");
|
||||
p._startNamespace.back().namespaceURI() = (ns != 0 ? ns : "");
|
||||
}
|
||||
@@ -931,7 +931,7 @@ void XMLCALL XMLStreamParser::handleEndNamespaceDecl(void* v, const XML_Char* pr
|
||||
if (ps.parsing == XML_FINISHED)
|
||||
return;
|
||||
|
||||
p._endNamespace.push_back(QName());
|
||||
p._endNamespace.emplace_back();
|
||||
p._endNamespace.back().prefix() = (prefix != 0 ? prefix : "");
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ void XMLStreamParserException::init()
|
||||
}
|
||||
|
||||
|
||||
const char* XMLStreamParserException::name() const throw()
|
||||
const char* XMLStreamParserException::name() const noexcept
|
||||
{
|
||||
return _name.c_str();
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ std::string fromXMLString(const XMLString& str)
|
||||
std::string result;
|
||||
result.reserve(str.size());
|
||||
|
||||
for (XMLString::const_iterator it = str.begin(); it != str.end(); ++it)
|
||||
for (auto xc: str)
|
||||
{
|
||||
char c;
|
||||
wctomb(&c, *it);
|
||||
wctomb(&c, xc);
|
||||
result += c;
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -259,7 +259,7 @@ void XMLWriter::startElement(const XMLString& namespaceURI, const XMLString& loc
|
||||
writeCanonicalStartElement(namespaceURI, localName, qname, attributes);
|
||||
else
|
||||
writeStartElement(namespaceURI, localName, qname, attributes);
|
||||
_elementStack.push_back(Name(qname, namespaceURI, localName));
|
||||
_elementStack.emplace_back(qname, namespaceURI, localName);
|
||||
_contentWritten = false;
|
||||
++_depth;
|
||||
}
|
||||
@@ -706,7 +706,7 @@ void XMLWriter::closeStartTag()
|
||||
|
||||
void XMLWriter::declareNamespaces(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes)
|
||||
{
|
||||
std::map<XMLString, std::set<XMLString> > usedNamespaces;
|
||||
std::map<XMLString, std::set<XMLString>> usedNamespaces;
|
||||
bool defaultNameSpaceUsed = false;
|
||||
XMLString defaultNamespaceURI = _namespaces.getURI(XMLString());
|
||||
XMLString local;
|
||||
@@ -738,32 +738,32 @@ void XMLWriter::declareNamespaces(const XMLString& namespaceURI, const XMLString
|
||||
defaultNameSpaceUsed = defaultNameSpaceUsed || (!defaultNamespaceURI.empty() && attributeNamespaceURI == defaultNamespaceURI);
|
||||
}
|
||||
}
|
||||
for (std::map<XMLString, std::set<XMLString> >::const_iterator it = usedNamespaces.begin(); it != usedNamespaces.end(); ++it)
|
||||
for (const auto& p: usedNamespaces)
|
||||
{
|
||||
const std::set<XMLString> namespaceURIs = it->second;
|
||||
for (std::set<XMLString>::const_iterator itURI = namespaceURIs.begin(); itURI != namespaceURIs.end(); ++itURI)
|
||||
const std::set<XMLString> namespaceURIs = p.second;
|
||||
for (const auto& nsURI: namespaceURIs)
|
||||
{
|
||||
XMLString prefix = it->first;
|
||||
XMLString prefix = p.first;
|
||||
if (prefix.empty())
|
||||
prefix = _namespaces.getPrefix(*itURI);
|
||||
if (prefix.empty() && !_namespaces.isMapped(*itURI))
|
||||
prefix = _namespaces.getPrefix(nsURI);
|
||||
if (prefix.empty() && !_namespaces.isMapped(nsURI))
|
||||
{
|
||||
if (defaultNameSpaceUsed)
|
||||
{
|
||||
if (*itURI != defaultNamespaceURI)
|
||||
if (nsURI != defaultNamespaceURI)
|
||||
prefix = uniquePrefix();
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultNamespaceURI = *itURI;
|
||||
defaultNamespaceURI = nsURI;
|
||||
defaultNameSpaceUsed = true;
|
||||
}
|
||||
|
||||
}
|
||||
const XMLString& uri = _namespaces.getURI(prefix);
|
||||
if ((uri.empty() || uri != *itURI) && !itURI->empty())
|
||||
if ((uri.empty() || uri != nsURI) && !nsURI.empty())
|
||||
{
|
||||
_namespaces.declarePrefix(prefix, *itURI);
|
||||
_namespaces.declarePrefix(prefix, nsURI);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -803,11 +803,10 @@ void XMLWriter::addNamespaceAttributes(AttributeMap& attributeMap)
|
||||
{
|
||||
NamespaceSupport::PrefixSet prefixes;
|
||||
_namespaces.getDeclaredPrefixes(prefixes);
|
||||
for (NamespaceSupport::PrefixSet::const_iterator it = prefixes.begin(); it != prefixes.end(); ++it)
|
||||
for (const auto& prefix: prefixes)
|
||||
{
|
||||
XMLString prefix = *it;
|
||||
XMLString uri = _namespaces.getURI(prefix);
|
||||
XMLString qname = NamespaceSupport::XMLNS_NAMESPACE_PREFIX;
|
||||
XMLString uri = _namespaces.getURI(prefix);
|
||||
XMLString qname = NamespaceSupport::XMLNS_NAMESPACE_PREFIX;
|
||||
|
||||
if (!prefix.empty())
|
||||
{
|
||||
@@ -823,11 +822,10 @@ void XMLWriter::addNamespaceAttributes(CanonicalAttributeMap& attributeMap)
|
||||
{
|
||||
NamespaceSupport::PrefixSet prefixes;
|
||||
_namespaces.getDeclaredPrefixes(prefixes);
|
||||
for (NamespaceSupport::PrefixSet::const_iterator it = prefixes.begin(); it != prefixes.end(); ++it)
|
||||
for (const auto& prefix: prefixes)
|
||||
{
|
||||
XMLString prefix = *it;
|
||||
XMLString uri = _namespaces.getURI(prefix);
|
||||
XMLString qname = NamespaceSupport::XMLNS_NAMESPACE_PREFIX;
|
||||
XMLString uri = _namespaces.getURI(prefix);
|
||||
XMLString qname = NamespaceSupport::XMLNS_NAMESPACE_PREFIX;
|
||||
|
||||
if (!prefix.empty())
|
||||
{
|
||||
@@ -898,7 +896,7 @@ void XMLWriter::addAttributes(CanonicalAttributeMap& attributeMap, const Attribu
|
||||
|
||||
void XMLWriter::writeAttributes(const AttributeMap& attributeMap)
|
||||
{
|
||||
for (AttributeMap::const_iterator it = attributeMap.begin(); it != attributeMap.end(); ++it)
|
||||
for (const auto& ap: attributeMap)
|
||||
{
|
||||
if ((_options & PRETTY_PRINT) && (_options & PRETTY_PRINT_ATTRIBUTES))
|
||||
{
|
||||
@@ -909,11 +907,10 @@ void XMLWriter::writeAttributes(const AttributeMap& attributeMap)
|
||||
{
|
||||
writeMarkup(MARKUP_SPACE);
|
||||
}
|
||||
writeXML(it->first);
|
||||
writeXML(ap.first);
|
||||
writeMarkup(MARKUP_EQQUOT);
|
||||
for (XMLString::const_iterator itc = it->second.begin(); itc != it->second.end(); ++itc)
|
||||
for (auto c: ap.second)
|
||||
{
|
||||
XMLChar c = *itc;
|
||||
switch (c)
|
||||
{
|
||||
case '"': writeMarkup(MARKUP_QUOTENC); break;
|
||||
@@ -937,7 +934,7 @@ void XMLWriter::writeAttributes(const AttributeMap& attributeMap)
|
||||
|
||||
void XMLWriter::writeAttributes(const CanonicalAttributeMap& attributeMap)
|
||||
{
|
||||
for (CanonicalAttributeMap::const_iterator it = attributeMap.begin(); it != attributeMap.end(); ++it)
|
||||
for (const auto& ap: attributeMap)
|
||||
{
|
||||
if ((_options & PRETTY_PRINT) && (_options & PRETTY_PRINT_ATTRIBUTES))
|
||||
{
|
||||
@@ -948,11 +945,10 @@ void XMLWriter::writeAttributes(const CanonicalAttributeMap& attributeMap)
|
||||
{
|
||||
writeMarkup(MARKUP_SPACE);
|
||||
}
|
||||
writeXML(it->second.first);
|
||||
writeXML(ap.second.first);
|
||||
writeMarkup(MARKUP_EQQUOT);
|
||||
for (XMLString::const_iterator itc = it->second.second.begin(); itc != it->second.second.end(); ++itc)
|
||||
for (auto c: ap.second.second)
|
||||
{
|
||||
XMLChar c = *itc;
|
||||
switch (c)
|
||||
{
|
||||
case '"': writeMarkup(MARKUP_QUOTENC); break;
|
||||
|
||||
Reference in New Issue
Block a user