X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltooling%2Fbase.h;h=05128dd636fdaa51ee7dff87cb3e8fa32e74a102;hb=60058d95e579f98bdbd5798bcc2dbac1a71e67fe;hp=450c37f0672cb5fbeb42c3fad3ebc2d736fa7a3e;hpb=f9be91405ccd7bef42163fb2ba28ecf6d005a8a0;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltooling/base.h b/xmltooling/base.h index 450c37f..05128dd 100644 --- a/xmltooling/base.h +++ b/xmltooling/base.h @@ -1,6 +1,6 @@ /* * Copyright 2001-2007 Internet2 - * + * * 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 @@ -16,7 +16,7 @@ /** * @file xmltooling/base.h - * + * * Base header file definitions * Must be included prior to including any other header */ @@ -208,7 +208,7 @@ * Begins the declaration of an XMLObject specialization for an abstract element/type. * 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 base class to derive from using public virtual inheritance @@ -229,7 +229,7 @@ * Begins the declaration of an XMLObject specialization. * 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 base class to derive from using public virtual inheritance @@ -251,7 +251,7 @@ * Begins the declaration of an XMLObject specialization with two 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 @@ -274,7 +274,7 @@ * 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 @@ -298,7 +298,7 @@ * 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 @@ -323,7 +323,7 @@ * Begins the declaration of an XMLObject specialization with five 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 @@ -368,7 +368,7 @@ /** * Implements a static variable holding an XMLObject's element QName. - * + * * @param cname the name of the XMLObject specialization * @param namespaceURI the XML namespace of the default associated element * @param namespacePrefix the XML namespace prefix of the default associated element @@ -378,7 +378,7 @@ /** * Implements a static variable holding an XMLObject's schema type QName. - * + * * @param cname the name of the XMLObject specialization * @param namespaceURI the XML namespace of the default associated element * @param namespacePrefix the XML namespace prefix of the default associated element @@ -389,7 +389,7 @@ /** * Declares abstract set method for a typed XML attribute. * The get method is omitted. - * + * * @param proper the proper name of the attribute * @param upcased the upcased name of the attribute * @param type the attribute's data type @@ -403,7 +403,7 @@ /** * Declares abstract get/set methods for a typed XML attribute. - * + * * @param proper the proper name of the attribute * @param upcased the upcased name of the attribute * @param type the attribute's data type @@ -420,7 +420,7 @@ /** * Declares abstract set method for a string XML attribute. * The get method is omitted. - * + * * @param proper the proper name of the attribute * @param upcased the upcased name of the attribute */ @@ -429,7 +429,7 @@ /** * Declares abstract get/set methods for a string XML attribute. - * + * * @param proper the proper name of the attribute * @param upcased the upcased name of the attribute */ @@ -439,7 +439,7 @@ /** * Declares abstract set method for a DateTime XML attribute. * The get method is omitted. - * + * * @param proper the proper name of the attribute * @param upcased the upcased name of the attribute */ @@ -452,7 +452,7 @@ /** * Declares abstract get/set methods for a DateTime XML attribute. - * + * * @param proper the proper name of the attribute * @param upcased the upcased name of the attribute */ @@ -468,7 +468,7 @@ /** * Declares abstract set method for an integer XML attribute. * The get method is omitted. - * + * * @param proper the proper name of the attribute * @param upcased the upcased name of the attribute */ @@ -483,7 +483,7 @@ /** * Declares abstract get/set methods for an integer XML attribute. - * + * * @param proper the proper name of the attribute * @param upcased the upcased name of the attribute */ @@ -500,7 +500,7 @@ /** * Declares abstract get/set methods for a boolean XML 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 @@ -556,7 +556,7 @@ /** * Implements get/set methods and a private member for a typed XML attribute. - * + * * @param proper the proper name of the attribute * @param type the attribute's data type */ @@ -573,7 +573,7 @@ /** * Implements get/set methods and a private member for a string XML attribute. - * + * * @param proper the proper name of the attribute */ #define IMPL_STRING_ATTRIB(proper) \ @@ -582,7 +582,7 @@ /** * 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_ID_ATTRIB(proper) \ @@ -593,11 +593,30 @@ /** * 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) \ + IMPL_DATETIME_ATTRIB_EX(proper,fallback,false) + +/** + * Implements get/set methods and a private member for a duration-valued DateTime XML attribute. + * + * @param proper the proper name of the attribute + * @param fallback epoch to return when attribute is NULL + */ +#define IMPL_DURATION_ATTRIB(proper,fallback) \ + IMPL_DATETIME_ATTRIB_EX(proper,fallback,true) + +/** + * 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 + * @param duration true iff the attribute should be handled as a duration + */ +#define IMPL_DATETIME_ATTRIB_EX(proper,fallback,duration) \ protected: \ DateTime* m_##proper; \ time_t m_##proper##Epoch; \ @@ -614,18 +633,18 @@ m_##proper##Epoch=m_##proper->getEpoch(); \ } \ void set##proper(time_t proper) { \ - m_##proper = prepareForAssignment(m_##proper,proper); \ + m_##proper = prepareForAssignment(m_##proper,proper,duration); \ m_##proper##Epoch = proper; \ } \ void set##proper(const XMLCh* proper) { \ - m_##proper = prepareForAssignment(m_##proper,proper); \ + m_##proper = prepareForAssignment(m_##proper,proper,duration); \ 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 */ #define IMPL_INTEGER_ATTRIB(proper) \ @@ -647,7 +666,7 @@ /** * Implements get/set methods and a private member for a boolean XML attribute. - * + * * @param proper the proper name of the attribute */ #define IMPL_BOOLEAN_ATTRIB(proper) \ @@ -667,7 +686,7 @@ /** * Declares abstract set method for a typed XML child object in a foreign namespace. * The get method is omitted. - * + * * @param proper the proper name of the child type * @param ns the C++ namespace for the type */ @@ -678,7 +697,7 @@ /** * Declares abstract get/set methods for a typed XML child object in a foreign namespace. - * + * * @param proper the proper name of the child type * @param ns the C++ namespace for the type */ @@ -692,7 +711,7 @@ /** * Declares abstract set method for a typed XML child object. * The get method is omitted. - * + * * @param proper the proper name of the child type */ #define DECL_INHERITED_TYPED_CHILD(proper) \ @@ -702,7 +721,7 @@ /** * Declares abstract get/set methods for a typed XML child object. - * + * * @param proper the proper name of the child type */ #define DECL_TYPED_CHILD(proper) \ @@ -714,7 +733,7 @@ /** * Declares abstract get/set methods for a generic XML child object. - * + * * @param proper the proper name of the child */ #define DECL_XMLOBJECT_CHILD(proper) \ @@ -727,7 +746,7 @@ /** * Implements get/set methods and a private list iterator member for a typed XML child object. - * + * * @param proper the proper name of the child type */ #define IMPL_TYPED_CHILD(proper) \ @@ -746,7 +765,7 @@ /** * Implements get/set methods and a private list iterator member for * a typed XML child object in a foreign namespace - * + * * @param proper the proper name of the child type * @param ns the C++ namespace for the type */ @@ -765,7 +784,7 @@ /** * Implements get/set methods and a private list iterator member for a generic XML child object. - * + * * @param proper the proper name of the child */ #define IMPL_XMLOBJECT_CHILD(proper) \ @@ -783,7 +802,7 @@ /** * Declares abstract get/set methods for a typed XML child collection. - * + * * @param proper the proper name of the child type */ #define DECL_TYPED_CHILDREN(proper) \ @@ -795,7 +814,7 @@ /** * Declares abstract get/set methods for a typed XML child collection in a foreign namespace. - * + * * @param proper the proper name of the child type * @param ns the C++ namespace for the type */ @@ -808,7 +827,7 @@ /** * Declares abstract get/set methods for a generic XML child collection. - * + * * @param proper the proper name of the child */ #define DECL_XMLOBJECT_CHILDREN(proper) \ @@ -820,7 +839,7 @@ /** * Implements get method and a private vector member for a typed XML child collection. - * + * * @param proper the proper name of the child type * @param fence insertion fence for new objects of the child collection in backing list */ @@ -833,12 +852,12 @@ } \ const std::vector& get##proper##s() const { \ return m_##proper##s; \ - } + } /** * Implements get method and a private vector member for a typed XML child collection * in a foreign namespace. - * + * * @param proper the proper name of the child type * @param ns the C++ namespace for the type * @param fence insertion fence for new objects of the child collection in backing list @@ -852,11 +871,11 @@ } \ const std::vector& get##proper##s() const { \ return m_##proper##s; \ - } + } /** * Implements get method and a private vector member for a generic XML child collection. - * + * * @param proper the proper name of the child * @param fence insertion fence for new objects of the child collection in backing list */ @@ -869,11 +888,11 @@ } \ const std::vector& get##proper##s() const { \ return m_##proper##s; \ - } + } /** * Implements marshalling for a string attribute - * + * * @param proper the proper name of the attribute * @param ucase the upcased name of the attribute * @param namespaceURI the XML namespace of the attribute @@ -885,7 +904,7 @@ /** * Implements marshalling for a DateTime attribute - * + * * @param proper the proper name of the attribute * @param ucase the upcased name of the attribute * @param namespaceURI the XML namespace of the attribute @@ -897,7 +916,7 @@ /** * Implements marshalling for an integer attribute - * + * * @param proper the proper name of the attribute * @param ucase the upcased name of the attribute * @param namespaceURI the XML namespace of the attribute @@ -909,7 +928,7 @@ /** * Implements marshalling for a boolean attribute - * + * * @param proper the proper name of the attribute * @param ucase the upcased name of the attribute * @param namespaceURI the XML namespace of the attribute @@ -934,7 +953,7 @@ /** * Implements marshalling for a QName attribute - * + * * @param proper the proper name of the attribute * @param ucase the upcased name of the attribute * @param namespaceURI the XML namespace of the attribute @@ -947,7 +966,7 @@ /** * Implements marshalling for an ID attribute - * + * * @param proper the proper name of the attribute * @param ucase the upcased name of the attribute * @param namespaceURI the XML namespace of the attribute @@ -960,7 +979,7 @@ /** * Implements unmarshalling process branch for a string attribute - * + * * @param proper the proper name of the attribute * @param ucase the upcased name of the attribute * @param namespaceURI the XML namespace of the attribute @@ -973,7 +992,7 @@ /** * Implements unmarshalling process branch for an ID attribute - * + * * @param proper the proper name of the attribute * @param ucase the upcased name of the attribute * @param namespaceURI the XML namespace of the attribute @@ -987,7 +1006,7 @@ /** * Implements unmarshalling process branch for a DateTime attribute - * + * * @param proper the proper name of the attribute * @param ucase the upcased name of the attribute * @param namespaceURI the XML namespace of the attribute @@ -997,7 +1016,7 @@ /** * Implements unmarshalling process branch for a DateTime attribute - * + * * @param proper the proper name of the attribute * @param ucase the upcased name of the attribute * @param namespaceURI the XML namespace of the attribute @@ -1010,7 +1029,7 @@ /** * Implements unmarshalling process branch for an integer attribute - * + * * @param proper the proper name of the attribute * @param ucase the upcased name of the attribute * @param namespaceURI the XML namespace of the attribute @@ -1020,7 +1039,7 @@ /** * Implements unmarshalling process branch for a boolean attribute - * + * * @param proper the proper name of the attribute * @param ucase the upcased name of the attribute * @param namespaceURI the XML namespace of the attribute @@ -1030,7 +1049,7 @@ /** * Implements unmarshalling process branch for typed child collection element - * + * * @param proper the proper name of the child type * @param namespaceURI the XML namespace of the child element * @param force bypass use of hint and just cast down to check child @@ -1047,7 +1066,7 @@ /** * Implements unmarshalling process branch for typed child collection element * in a foreign namespace. - * + * * @param proper the proper name of the child type * @param ns the C++ namespace for the type * @param namespaceURI the XML namespace of the child element @@ -1064,7 +1083,7 @@ /** * Implements unmarshalling process branch for typed child singleton element - * + * * @param proper the proper name of the child type * @param namespaceURI the XML namespace of the child element * @param force bypass use of hint and just cast down to check child @@ -1082,7 +1101,7 @@ /** * Implements unmarshalling process branch for typed child singleton element * in a foreign namespace. - * + * * @param proper the proper name of the child type * @param ns the C++ namespace for the type * @param namespaceURI the XML namespace of the child element @@ -1100,7 +1119,7 @@ /** * Implements unmarshalling process branch for a generic child singleton element - * + * * @param proper the proper name of the child type * @param namespaceURI the XML namespace of the child element */ @@ -1115,7 +1134,7 @@ /** * Declares aliased get/set methods for named XML element simple content. - * + * * @param proper the proper name to label the element's content */ #define DECL_SIMPLE_CONTENT(proper) \ @@ -1130,7 +1149,7 @@ /** * Declares aliased get/set methods for named integer XML element content. - * + * * @param proper the proper name to label the element's content */ #define DECL_INTEGER_CONTENT(proper) \ @@ -1152,7 +1171,7 @@ /** * Implements cloning methods for an XMLObject specialization implementation class. - * + * * @param cname the name of the XMLObject specialization */ #define IMPL_XMLOBJECT_CLONE(cname) \ @@ -1172,7 +1191,7 @@ /** * Declares an XMLObject specialization with a simple content model and type, * handling it as string data. - * + * * @param linkage linkage specifier for the class * @param cname the name of the XMLObject specialization * @param proper the proper name to label the element's content @@ -1186,7 +1205,7 @@ /** * Declares and defines an implementation class for an XMLObject with * a simple content model and type, handling it as string data. - * + * * @param linkage linkage specifier for the class * @param cname the name of the XMLObject specialization */ @@ -1216,7 +1235,7 @@ * Begins the declaration of an XMLObjectBuilder specialization. * Basic boilerplate includes an empty virtual destructor, and * a default builder that defaults the element name. - * + * * @param linkage linkage specifier for the class * @param cname the name of the XMLObject specialization * @param namespaceURI the XML namespace of the default associated element @@ -1243,7 +1262,7 @@ /** * Declares a generic XMLObjectBuilder specialization. - * + * * @param linkage linkage specifier for the class * @param cname the name of the XMLObject specialization * @param namespaceURI the XML namespace of the default associated element @@ -1263,8 +1282,8 @@ END_XMLOBJECTBUILDER /** - * Implements the standard XMLObjectBuilder specialization function. - * + * Implements the standard XMLObjectBuilder specialization function. + * * @param cname the name of the XMLObject specialization */ #define IMPL_XMLOBJECTBUILDER(cname) \ @@ -1281,7 +1300,7 @@ * Begins the declaration of an XMLObjectBuilder specialization. * Basic boilerplate includes an empty virtual destructor, and * a default builder that defaults the element name. - * + * * @param linkage linkage specifier for the class * @param cname the name of the XMLObject specialization * @param namespaceURI the XML namespace of the default associated element @@ -1308,7 +1327,7 @@ /** * Declares a generic XMLObjectBuilder specialization. - * + * * @param linkage linkage specifier for the class * @param cname the name of the XMLObject specialization * @param namespaceURI the XML namespace of the default associated element @@ -1328,8 +1347,8 @@ END_XMLOBJECTBUILDER /** - * Implements the standard XMLObjectBuilder specialization function. - * + * Implements the standard XMLObjectBuilder specialization function. + * * @param cname the name of the XMLObject specialization */ #define IMPL_XMLOBJECTBUILDER(cname) \ @@ -1344,7 +1363,7 @@ /** * Begins the declaration of a Schema Validator specialization. - * + * * @param linkage linkage specifier for the class * @param cname the base name of the Validator specialization */ @@ -1362,7 +1381,7 @@ /** * Begins the declaration of a Schema Validator specialization subclass. - * + * * @param linkage linkage specifier for the class * @param cname the base name of the Validator specialization * @param base base class for the validator @@ -1384,7 +1403,7 @@ /** * Validator code that checks the object type. - * + * * @param cname the name of the XMLObject specialization */ #define XMLOBJECTVALIDATOR_CHECKTYPE(cname) \ @@ -1394,9 +1413,9 @@ /** * Validator code that checks for a required attribute, content, or singleton. - * + * * @param cname the name of the XMLObject specialization - * @param proper the proper name of the attribute, content, or singleton member + * @param proper the proper name of the attribute, content, or singleton member */ #define XMLOBJECTVALIDATOR_REQUIRE(cname,proper) \ if (!ptr->get##proper()) \ @@ -1404,9 +1423,9 @@ /** * Validator code that checks for a required integer attribute - * + * * @param cname the name of the XMLObject specialization - * @param proper the proper name of the attribute, content, or singleton member + * @param proper the proper name of the attribute, content, or singleton member */ #define XMLOBJECTVALIDATOR_REQUIRE_INTEGER(cname,proper) \ if (!ptr->get##proper().first) \ @@ -1415,10 +1434,10 @@ /** * Validator code that checks for one of a pair of * required attributes, content, or singletons. - * + * * @param cname the name of the XMLObject specialization - * @param proper1 the proper name of the first attribute, content, or singleton member - * @param proper2 the proper name of the second attribute, content, or singleton member + * @param proper1 the proper name of the first attribute, content, or singleton member + * @param proper2 the proper name of the second attribute, content, or singleton member */ #define XMLOBJECTVALIDATOR_ONEOF(cname,proper1,proper2) \ if (!ptr->get##proper1() && !ptr->get##proper2()) \ @@ -1427,10 +1446,10 @@ /** * Validator code that checks for one of a pair of * required attributes, content, or singletons, but disallows both. - * + * * @param cname the name of the XMLObject specialization - * @param proper1 the proper name of the first attribute, content, or singleton member - * @param proper2 the proper name of the second attribute, content, or singleton member + * @param proper1 the proper name of the first attribute, content, or singleton member + * @param proper2 the proper name of the second attribute, content, or singleton member */ #define XMLOBJECTVALIDATOR_ONLYONEOF(cname,proper1,proper2) \ if ((!ptr->get##proper1() && !ptr->get##proper2()) || (ptr->get##proper1() && ptr->get##proper2())) \ @@ -1439,7 +1458,7 @@ /** * Validator code that checks for one of a set of three * required attributes, content, or singletons. - * + * * @param cname the name of the XMLObject specialization * @param proper1 the proper name of the first attribute, content, or singleton member * @param proper2 the proper name of the second attribute, content, or singleton member @@ -1452,7 +1471,7 @@ /** * Validator code that checks for one of a set of three * required attributes, content, or singletons but disallows more than one. - * + * * @param cname the name of the XMLObject specialization * @param proper1 the proper name of the first attribute, content, or singleton member * @param proper2 the proper name of the second attribute, content, or singleton member @@ -1472,10 +1491,10 @@ /** * Validator code that checks a co-constraint (if one present, the other must be) * between a pair of attributes, content, or singletons. - * + * * @param cname the name of the XMLObject specialization - * @param proper1 the proper name of the first attribute, content, or singleton member - * @param proper2 the proper name of the second attribute, content, or singleton member + * @param proper1 the proper name of the first attribute, content, or singleton member + * @param proper2 the proper name of the second attribute, content, or singleton member */ #define XMLOBJECTVALIDATOR_NONEORBOTH(cname,proper1,proper2) \ if ((ptr->get##proper1() && !ptr->get##proper2()) || (!ptr->get##proper1() && ptr->get##proper2())) \ @@ -1483,9 +1502,9 @@ /** * Validator code that checks for a non-empty collection. - * + * * @param cname the name of the XMLObject specialization - * @param proper the proper name of the collection item + * @param proper the proper name of the collection item */ #define XMLOBJECTVALIDATOR_NONEMPTY(cname,proper) \ if (ptr->get##proper##s().empty()) \ @@ -1494,7 +1513,7 @@ /** * Declares/defines a Validator specialization that checks object type and * a non-empty simple content model. - * + * * @param linkage linkage specifier for the class * @param cname the name of the XMLObject specialization */ @@ -1515,7 +1534,7 @@ namespace xmltooling { * Template function for cloning a sequence of XMLObjects. * Invokes the clone() member on each element of the input sequence and adds the copy to * the output sequence. Order is preserved. - * + * * @param in input sequence to clone * @param out output sequence to copy cloned pointers into */ @@ -1535,14 +1554,14 @@ namespace xmltooling { { /** * Function operator to delete an object. - * + * * @param ptr object to delete */ void operator()(T* ptr) {delete ptr;} - + /** * Function operator to delete an object stored as const. - * + * * @param ptr object to delete after casting away const */ void operator()(const T* ptr) {delete const_cast(ptr);} @@ -1555,7 +1574,7 @@ namespace xmltooling { { /** * Function operator to delete an object. - * + * * @param p a pair in which the second component is the object to delete */ void operator()(const std::pair& p) {delete p.second;} @@ -1568,7 +1587,7 @@ namespace xmltooling { { /** * Function operator to delete an object stored as const - * + * * @param p a pair in which the second component is the const object to delete */ void operator()(const std::pair& p) {delete const_cast(p.second);}