*/
#define BEGIN_XMLOBJECT(linkage,cname,base,desc) \
XMLTOOLING_DOXYGEN(desc) \
- class linkage cname : public virtual base, public virtual xmltooling::ValidatingXMLObject { \
+ class linkage cname : public virtual base { \
protected: \
cname() {} \
public: \
*/
#define BEGIN_XMLOBJECT2(linkage,cname,base,base2,desc) \
XMLTOOLING_DOXYGEN(desc) \
- class linkage cname : public virtual base, public virtual base2, public virtual xmltooling::ValidatingXMLObject { \
+ class linkage cname : public virtual base, public virtual base2 { \
+ protected: \
+ cname() {} \
+ public: \
+ virtual ~cname() {} \
+ XMLTOOLING_DOXYGEN(Type-specific clone method.) \
+ virtual cname* clone##cname() const=0; \
+ XMLTOOLING_DOXYGEN(Element local name) \
+ static const XMLCh LOCAL_NAME[]
+
+/**
+ * Begins the declaration of an XMLObject specialization with three base classes.
+ * Basic boilerplate includes a protected constructor, empty virtual destructor,
+ * and Unicode constants for the default associated element's name and prefix.
+ *
+ * @param linkage linkage specifier for the class
+ * @param cname the name of the class to declare
+ * @param base the first base class to derive from using public virtual inheritance
+ * @param base2 the second base class to derive from using public virtual inheritance
+ * @param base3 the third base class to derive from using public virtual inheritance
+ * @param desc documentation comment for class
+ */
+#define BEGIN_XMLOBJECT3(linkage,cname,base,base2,base3,desc) \
+ XMLTOOLING_DOXYGEN(desc) \
+ class linkage cname : public virtual base, public virtual base2, public virtual base3 { \
+ protected: \
+ cname() {} \
+ public: \
+ virtual ~cname() {} \
+ XMLTOOLING_DOXYGEN(Type-specific clone method.) \
+ virtual cname* clone##cname() const=0; \
+ XMLTOOLING_DOXYGEN(Element local name) \
+ static const XMLCh LOCAL_NAME[]
+
+/**
+ * Begins the declaration of an XMLObject specialization with four base classes.
+ * Basic boilerplate includes a protected constructor, empty virtual destructor,
+ * and Unicode constants for the default associated element's name and prefix.
+ *
+ * @param linkage linkage specifier for the class
+ * @param cname the name of the class to declare
+ * @param base the first base class to derive from using public virtual inheritance
+ * @param base2 the second base class to derive from using public virtual inheritance
+ * @param base3 the third base class to derive from using public virtual inheritance
+ * @param base4 the fourth base class to derive from using public virtual inheritance
+ * @param desc documentation comment for class
+ */
+#define BEGIN_XMLOBJECT4(linkage,cname,base,base2,base3,base4,desc) \
+ XMLTOOLING_DOXYGEN(desc) \
+ class linkage cname : public virtual base, public virtual base2, public virtual base3, public virtual base4 { \
protected: \
cname() {} \
public: \
*/
#define DECL_DATETIME_ATTRIB(proper,upcased) \
DECL_XMLOBJECT_ATTRIB(proper,upcased,xmltooling::DateTime); \
+ XMLTOOLING_DOXYGEN(Returns the proper attribute in epoch form.) \
+ virtual time_t get##proper##Epoch() const=0; \
XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
virtual void set##proper(time_t proper)=0; \
XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
*
* @param proper the proper name of the attribute
* @param upcased the upcased name of the attribute
+ * @param def the default/presumed value, if no explicit value has been set
*/
-#define DECL_BOOLEAN_ATTRIB(proper,upcased) \
+#define DECL_BOOLEAN_ATTRIB(proper,upcased,def) \
public: \
XMLTOOLING_DOXYGEN(proper attribute name) \
static const XMLCh upcased##_ATTRIB_NAME[]; \
- XMLTOOLING_DOXYGEN(Returns the proper attribute after a NULL indicator.) \
- virtual std::pair<bool,bool> proper() const=0; \
+ XMLTOOLING_DOXYGEN(Returns the proper attribute or def if not set.) \
+ bool proper() const { \
+ switch (get##proper()) { \
+ case xmltooling::XMLConstants::XML_BOOL_TRUE: \
+ case xmltooling::XMLConstants::XML_BOOL_ONE: \
+ return true; \
+ case xmltooling::XMLConstants::XML_BOOL_FALSE: \
+ case xmltooling::XMLConstants::XML_BOOL_ZERO: \
+ return false; \
+ default: \
+ return def; \
+ } \
+ } \
+ XMLTOOLING_DOXYGEN(Returns the proper attribute as an explicit enumerated value.) \
+ virtual xmltooling::XMLConstants::xmltooling_bool_t get##proper() const=0; \
XMLTOOLING_DOXYGEN(Sets the proper attribute using an enumerated value.) \
virtual void proper(xmltooling::XMLConstants::xmltooling_bool_t value)=0; \
XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
IMPL_XMLOBJECT_ATTRIB(proper,XMLCh)
/**
- * Implements get/set methods and a private member for a DateTime XML attribute.
+ * Implements get/set methods and a private member for a string XML attribute,
+ * plus a getXMLID override.
*
* @param proper the proper name of the attribute
*/
-#define IMPL_DATETIME_ATTRIB(proper) \
- IMPL_XMLOBJECT_ATTRIB(proper,xmltooling::DateTime); \
- void set##proper(time_t proper) { \
- m_##proper = prepareForAssignment(m_##proper,proper); \
- } \
- void set##proper(const XMLCh* proper) { \
- m_##proper = prepareForAssignment(m_##proper,proper); \
+#define IMPL_ID_ATTRIB(proper) \
+ IMPL_XMLOBJECT_ATTRIB(proper,XMLCh) \
+ const XMLCh* getXMLID() const { \
+ return m_##proper; \
}
/**
+ * Implements get/set methods and a private member for a DateTime XML attribute.
+ *
+ * @param proper the proper name of the attribute
+ * @param fallback epoch to return when attribute is NULL
+ */
+#define IMPL_DATETIME_ATTRIB(proper,fallback) \
+ protected: \
+ DateTime* m_##proper; \
+ time_t m_##proper##Epoch; \
+ public: \
+ const DateTime* get##proper() const { \
+ return m_##proper; \
+ } \
+ time_t get##proper##Epoch() const { \
+ return m_##proper ? m_##proper##Epoch : fallback; \
+ } \
+ void set##proper(const DateTime* proper) { \
+ m_##proper = prepareForAssignment(m_##proper,proper); \
+ if (m_##proper) \
+ m_##proper##Epoch=m_##proper->getEpoch(); \
+ } \
+ void set##proper(time_t proper) { \
+ m_##proper = prepareForAssignment(m_##proper,proper); \
+ m_##proper##Epoch = proper; \
+ } \
+ void set##proper(const XMLCh* proper) { \
+ m_##proper = prepareForAssignment(m_##proper,proper); \
+ if (m_##proper) \
+ m_##proper##Epoch=m_##proper->getEpoch(); \
+ }
+
+/**
* Implements get/set methods and a private member for an integer XML attribute.
*
* @param proper the proper name of the attribute
XMLCh* m_##proper; \
public: \
pair<bool,int> get##proper() const { \
- return make_pair((m_##proper!=NULL),XMLString::parseInt(m_##proper)); \
+ return make_pair((m_##proper!=NULL),(m_##proper!=NULL ? XMLString::parseInt(m_##proper): 0)); \
} \
void set##proper(const XMLCh* proper) { \
m_##proper = prepareForAssignment(m_##proper,proper); \
protected: \
XMLConstants::xmltooling_bool_t m_##proper; \
public: \
- pair<bool,bool> proper() const { \
- return make_pair( \
- (m_##proper!=XMLConstants::XML_BOOL_NULL), \
- (m_##proper==XMLConstants::XML_BOOL_TRUE || m_##proper==XMLConstants::XML_BOOL_ONE) \
- ); \
+ XMLConstants::xmltooling_bool_t get##proper() const { \
+ return m_##proper; \
} \
void proper(XMLConstants::xmltooling_bool_t value) { \
if (m_##proper != value) { \
case XMLConstants::XML_BOOL_ZERO: \
domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, XMLConstants::XML_ZERO); \
break; \
+ case XMLConstants::XML_BOOL_NULL: \
+ break; \
}
/**
}
/**
- * Declares aliased get/set methods for named XML element content.
+ * Declares aliased get/set methods for named XML element simple content.
*
* @param proper the proper name to label the element's content
*/
-#define DECL_XMLOBJECT_CONTENT(proper) \
+#define DECL_SIMPLE_CONTENT(proper) \
XMLTOOLING_DOXYGEN(Returns proper.) \
const XMLCh* get##proper() const { \
return getTextContent(); \
#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), XMLString::parseInt(getTextContent())); \
+ return std::make_pair((getTextContent()!=NULL), (getTextContent()!=NULL ? XMLString::parseInt(getTextContent()) : NULL)); \
} \
XMLTOOLING_DOXYGEN(Sets proper.) \
void set##proper(int proper) { \
}
/**
- * Implements marshalling/unmarshalling for element content.
- */
-#define IMPL_XMLOBJECT_CONTENT \
- protected: \
- void marshallElementContent(DOMElement* domElement) const { \
- if(getTextContent()) { \
- domElement->appendChild(domElement->getOwnerDocument()->createTextNode(getTextContent())); \
- } \
- } \
- void processElementContent(const XMLCh* elementContent) { \
- setTextContent(elementContent); \
- }
-
-
-/**
* Implements cloning methods for an XMLObject specialization implementation class.
*
* @param cname the name of the XMLObject specialization
* @param desc documentation for class
*/
#define DECL_XMLOBJECT_SIMPLE(linkage,cname,proper,desc) \
- BEGIN_XMLOBJECT(linkage,cname,xmltooling::SimpleElement,desc); \
- DECL_XMLOBJECT_CONTENT(proper); \
+ BEGIN_XMLOBJECT(linkage,cname,xmltooling::XMLObject,desc); \
+ DECL_SIMPLE_CONTENT(proper); \
END_XMLOBJECT
/**
class linkage cname##Impl \
: public virtual cname, \
public xmltooling::AbstractSimpleElement, \
- public xmltooling::AbstractChildlessElement, \
public xmltooling::AbstractDOMCachingXMLObject, \
- public xmltooling::AbstractValidatingXMLObject, \
public xmltooling::AbstractXMLObjectMarshaller, \
public xmltooling::AbstractXMLObjectUnmarshaller \
{ \
cname##Impl(const cname##Impl& src) \
: xmltooling::AbstractXMLObject(src), \
xmltooling::AbstractSimpleElement(src), \
- xmltooling::AbstractDOMCachingXMLObject(src), \
- xmltooling::AbstractValidatingXMLObject(src) {} \
+ xmltooling::AbstractDOMCachingXMLObject(src) {} \
IMPL_XMLOBJECT_CLONE(cname) \
- IMPL_XMLOBJECT_CONTENT \
}
/**
{ \
public: \
virtual ~cname##SchemaValidator() {} \
- virtual cname##SchemaValidator* clone() const { \
- return new cname##SchemaValidator(); \
- } \
virtual void validate(const xmltooling::XMLObject* xmlObject) const { \
const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
if (!ptr) \
{ \
public: \
virtual ~cname##SchemaValidator() {} \
- virtual cname##SchemaValidator* clone() const { \
- return new cname##SchemaValidator(); \
- } \
virtual void validate(const xmltooling::XMLObject* xmlObject) const { \
const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
if (!ptr) \