-/*
- * Copyright 2001-2008 Internet2
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * UCAID licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the
+ * License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
*/
/**
* @file xmltooling/base.h
*
- * Base header file definitions
- * Must be included prior to including any other header
+ * Base header file definitions.
+ * Must be included prior to including any other header.
*/
#ifndef __xmltooling_base_h__
# define XMLTOOLING_NO_XMLSEC 1
#endif
+#ifndef HAVE_NULLPTR
+# define nullptr 0
+#endif
+
#if defined(XMLTOOLING_NO_XMLSEC) || !defined(HAVE_XSECSIZE_T)
# ifdef XMLTOOLING_XERCESC_64BITSAFE
# include <xercesc/util/XercesDefs.hpp>
XMLCh* m_##proper; \
public: \
pair<bool,int> get##proper() const { \
- return make_pair((m_##proper!=NULL),(m_##proper!=NULL ? xercesc::XMLString::parseInt(m_##proper): 0)); \
+ return make_pair((m_##proper!=nullptr),(m_##proper!=nullptr ? xercesc::XMLString::parseInt(m_##proper): 0)); \
} \
void set##proper(const XMLCh* proper) { \
m_##proper = prepareForAssignment(m_##proper,proper); \
} \
void set##proper(int proper) { \
char buf##proper[64]; \
- sprintf(buf##proper,"%d",proper); \
- auto_ptr_XMLCh wide##proper(buf##proper); \
+ std::sprintf(buf##proper,"%d",proper); \
+ xmltooling::auto_ptr_XMLCh wide##proper(buf##proper); \
set##proper(wide##proper.get()); \
}
} \
void set##proper(const type* proper) { \
m_##proper = prepareForAssignment(m_##proper,proper); \
- XMLString::release(&m_##proper##Prefix); \
- m_##proper##Prefix = NULL; \
+ xercesc::XMLString::release(&m_##proper##Prefix); \
+ m_##proper##Prefix = nullptr; \
}
/**
*/
#define MARSHALL_QNAME_ATTRIB(proper,ucase,namespaceURI) \
if (m_##proper) { \
- auto_ptr_XMLCh qstr(m_##proper->toString().c_str()); \
+ xmltooling::auto_ptr_XMLCh qstr(m_##proper->toString().c_str()); \
domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, qstr.get()); \
}
*/
#define PROC_QNAME_ATTRIB(proper,ucase,namespaceURI) \
if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
- set##proper(XMLHelper::getAttributeValueAsQName(attribute)); \
+ std::auto_ptr<xmltooling::QName> q(xmltooling::XMLHelper::getAttributeValueAsQName(attribute)); \
+ set##proper(q.get()); \
return; \
}
#define DECL_INTEGER_CONTENT(proper) \
XMLTOOLING_DOXYGEN(Returns proper in integer form after a NULL indicator.) \
std::pair<bool,int> get##proper() const { \
- return std::make_pair((getTextContent()!=NULL), (getTextContent()!=NULL ? xercesc::XMLString::parseInt(getTextContent()) : 0)); \
+ return std::make_pair((getTextContent()!=nullptr), (getTextContent()!=nullptr ? xercesc::XMLString::parseInt(getTextContent()) : 0)); \
} \
XMLTOOLING_DOXYGEN(Sets proper.) \
void set##proper(int proper) { \
char buf[64]; \
- sprintf(buf,"%d",proper); \
+ std::sprintf(buf,"%d",proper); \
xmltooling::auto_ptr_XMLCh widebuf(buf); \
setTextContent(widebuf.get()); \
} \
/**
* Implements cloning methods for an XMLObject specialization implementation class.
*
- * @param cname the name of the XMLObject specialization
+ * @param cname the name of the XMLObject specialization
*/
#define IMPL_XMLOBJECT_CLONE(cname) \
cname* clone##cname() const { \
}
/**
+ * Implements cloning methods for an XMLObject specialization implementation class
+ * that must override a base class clone method.
+ *
+ * @param cname the name of the XMLObject specialization
+ * @param base name of base type.
+ */
+#define IMPL_XMLOBJECT_CLONE2(cname,base) \
+ cname* clone##cname() const { \
+ return dynamic_cast<cname*>(clone()); \
+ } \
+ base* clone##base() const { \
+ return dynamic_cast<base*>(clone()); \
+ } \
+ xmltooling::XMLObject* clone() const { \
+ std::auto_ptr<xmltooling::XMLObject> domClone(xmltooling::AbstractDOMCachingXMLObject::clone()); \
+ cname##Impl* ret=dynamic_cast<cname##Impl*>(domClone.get()); \
+ if (ret) { \
+ domClone.release(); \
+ return ret; \
+ } \
+ return new cname##Impl(*this); \
+ }
+
+/**
+ * Implements cloning methods for an XMLObject specialization implementation class that
+ * needs two stage duplication to avoid invoking virtual methods during construction.
+ *
+ * @param cname the name of the XMLObject specialization
+ */
+#define IMPL_XMLOBJECT_CLONE_EX(cname) \
+ cname* clone##cname() const { \
+ return dynamic_cast<cname*>(clone()); \
+ } \
+ xmltooling::XMLObject* clone() const { \
+ std::auto_ptr<xmltooling::XMLObject> domClone(xmltooling::AbstractDOMCachingXMLObject::clone()); \
+ cname##Impl* ret=dynamic_cast<cname##Impl*>(domClone.get()); \
+ if (ret) { \
+ domClone.release(); \
+ return ret; \
+ } \
+ std::auto_ptr<cname##Impl> ret2(new cname##Impl(*this)); \
+ ret2->_clone(*this); \
+ return ret2.release(); \
+ }
+
+/**
+ * Implements cloning methods for an XMLObject specialization implementation class that
+ * needs two stage duplication to avoid invoking virtual methods during construction,
+ * and must override a base class clone method.
+ *
+ * @param cname the name of the XMLObject specialization
+ * @param base name of base type
+ */
+#define IMPL_XMLOBJECT_CLONE_EX2(cname,base) \
+ cname* clone##cname() const { \
+ return dynamic_cast<cname*>(clone()); \
+ } \
+ base* clone##base() const { \
+ return dynamic_cast<base*>(clone()); \
+ } \
+ xmltooling::XMLObject* clone() const { \
+ std::auto_ptr<xmltooling::XMLObject> domClone(xmltooling::AbstractDOMCachingXMLObject::clone()); \
+ cname##Impl* ret=dynamic_cast<cname##Impl*>(domClone.get()); \
+ if (ret) { \
+ domClone.release(); \
+ return ret; \
+ } \
+ std::auto_ptr<cname##Impl> ret2(new cname##Impl(*this)); \
+ ret2->_clone(*this); \
+ return ret2.release(); \
+ }
+
+/**
* Declares an XMLObject specialization with a simple content model and type,
* handling it as string data.
*
} \
XMLTOOLING_DOXYGEN(Builder that allows element/type override.) \
virtual cname* buildObject( \
- const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL \
+ const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const xmltooling::QName* schemaType=nullptr \
) const
/**
} \
XMLTOOLING_DOXYGEN(Builder that allows element/type override.) \
virtual xmltooling::XMLObject* buildObject( \
- const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL \
+ const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const xmltooling::QName* schemaType=nullptr \
) const
/**
*/
#define XMLOBJECTVALIDATOR_ONLYONEOF3(cname,proper1,proper2,proper3) \
int c##proper1##proper2##proper3=0; \
- if (ptr->get##proper1()!=NULL) \
+ if (ptr->get##proper1()!=nullptr) \
c##proper1##proper2##proper3++; \
- if (ptr->get##proper2()!=NULL) \
+ if (ptr->get##proper2()!=nullptr) \
c##proper1##proper2##proper3++; \
- if (ptr->get##proper3()!=NULL) \
+ if (ptr->get##proper3()!=nullptr) \
c##proper1##proper2##proper3++; \
if (c##proper1##proper2##proper3 != 1) \
throw xmltooling::ValidationException(#cname" must have only one of "#proper1", "#proper2", or "#proper3".")