/*
- * Copyright 2001-2007 Internet2
+ * Copyright 2001-2010 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
using namespace xercesc;
using namespace std;
+PropertySet::PropertySet()
+{
+}
+
+PropertySet::~PropertySet()
+{
+}
+
+DOMPropertySet::DOMPropertySet() : m_parent(nullptr), m_root(nullptr)
+{
+}
+
DOMPropertySet::~DOMPropertySet()
{
for (map<string,pair<char*,const XMLCh*> >::iterator i=m_map.begin(); i!=m_map.end(); i++)
for_each(m_nested.begin(),m_nested.end(),cleanup_pair<string,DOMPropertySet>());
}
+const PropertySet* DOMPropertySet::getParent() const
+{
+ return m_parent;
+}
+
+void DOMPropertySet::setParent(const PropertySet* parent)
+{
+ m_parent = parent;
+}
+
+const DOMElement* DOMPropertySet::getElement() const
+{
+ return m_root;
+}
+
void DOMPropertySet::load(
const DOMElement* e,
Category* log,
if (remapper) {
remap=remapper->find(realname);
if (remap!=remapper->end()) {
- log->warn("remapping property (%s) to (%s)",realname,remap->second.c_str());
+ log->warn("deprecation - remapping property (%s) to (%s)",realname,remap->second.c_str());
realname=remap->second.c_str();
}
}
if (remapper) {
remap=remapper->find(realname);
if (remap!=remapper->end()) {
- log->warn("remapping property set (%s) to (%s)",realname,remap->second.c_str());
+ log->warn("deprecation - remapping nested property set (%s) to (%s)",realname,remap->second.c_str());
realname=remap->second.c_str();
}
}
pair<bool,const char*> DOMPropertySet::getString(const char* name, const char* ns) const
{
- pair<bool,const char*> ret(false,NULL);
+ pair<bool,const char*> ret(false,nullptr);
map<string,pair<char*,const XMLCh*> >::const_iterator i;
if (ns)
return pair<bool,const char*>(true,i->second.first);
else if (m_parent)
return m_parent->getString(name,ns);
- return pair<bool,const char*>(false,NULL);
+ return pair<bool,const char*>(false,nullptr);
}
pair<bool,const XMLCh*> DOMPropertySet::getXMLString(const char* name, const char* ns) const
return make_pair(true,i->second.second);
else if (m_parent)
return m_parent->getXMLString(name,ns);
- return pair<bool,const XMLCh*>(false,NULL);
+ return pair<bool,const XMLCh*>(false,nullptr);
}
pair<bool,unsigned int> DOMPropertySet::getUnsignedInt(const char* name, const char* ns) const
i=m_map.find(name);
if (i!=m_map.end())
- return pair<bool,unsigned int>(true,strtol(i->second.first,NULL,10));
+ return pair<bool,unsigned int>(true,strtol(i->second.first,nullptr,10));
else if (m_parent)
return m_parent->getUnsignedInt(name,ns);
return pair<bool,unsigned int>(false,0);
else
i=m_nested.find(name);
- return (i!=m_nested.end()) ? i->second : (m_parent ? m_parent->getPropertySet(name,ns) : NULL);
+ return (i!=m_nested.end()) ? i->second : (m_parent ? m_parent->getPropertySet(name,ns) : nullptr);
+}
+
+bool DOMPropertySet::setProperty(const char* name, const char* val, const char* ns)
+{
+ string propname = ns ? (string("{") + ns + "}" + name) : name;
+
+ // Erase existing property.
+ if (m_map.count(propname) > 0) {
+ XMLString::release(&m_map[propname].first);
+ m_map.erase(propname);
+ }
+
+ char* dup = XMLString::replicate(val);
+ auto_ptr_XMLCh widedup(val);
+ m_injected.push_back(widedup.get());
+ m_map[propname] = make_pair(dup, m_injected.back().c_str());
+
+ return true;
}