it_bus/schema_type_traits.h

00001 #ifndef _IT_BUS_SCHEMA_TYPE_TRAITS_H_
00002 #define _IT_BUS_SCHEMA_TYPE_TRAITS_H_
00003 
00004 // @Copyright 2004 IONA Technologies, Plc. All Rights Reserved.
00005 //
00006 #include <it_bus/types.h>
00007 #include <it_bus/binary_type.h>
00008 #include <it_bus/any_holder.h>
00009 #include <it_bus/any_uri.h>
00010 #include <it_bus/date.h>
00011 #include <it_bus/gday.h>
00012 #include <it_bus/gmonth.h>
00013 #include <it_bus/gmonthday.h>
00014 #include <it_bus/gyear.h>
00015 #include <it_bus/gyearmonth.h>
00016 #include <it_bus/duration.h>
00017 #include <it_bus/integer.h>
00018 #include <it_bus/time.h>
00019 #include <it_bus/normalized_string.h>
00020 #include <it_bus/token.h>
00021 #include <it_bus/language.h>
00022 #include <it_bus/name.h>
00023 #include <it_bus/ncname.h>
00024 #include <it_bus/nmtoken.h>
00025 #include <it_bus/id.h>
00026 #include <it_bus/any.h>
00027 #include <it_bus/any_holder.h>
00028 #include <it_schema_model/w3c_constants.h>
00029 #include <it_bus/reflect/built_in_type.h>
00030 
00031 namespace IT_Bus
00032 {
00043     // Generic template covers built-in types.
00044     template <class T>
00045     struct SchemaTypeTraits
00046     {
00047         static const QName&
00048         type_name()
00049         {
00050             return T::get_static_type();
00051         }
00052     };
00053     
00054     // Specializations for built-in types.
00055     template<>
00056     struct SchemaTypeTraits<Boolean>
00057     {
00058         static const QName&
00059         type_name()
00060         {
00061             return IT_W3CConstants::NT_SCHEMA_BOOLEAN;
00062         }
00063         enum { value_kind = IT_Reflect::BuiltInType::BOOLEAN };
00064     };
00065     
00066     template<>
00067     struct SchemaTypeTraits<Float>
00068     {
00069         static const QName&
00070         type_name()
00071         {
00072             return IT_W3CConstants::NT_SCHEMA_FLOAT;
00073         }
00074         enum { value_kind = IT_Reflect::BuiltInType::FLOAT };
00075     };
00076 
00077     template<>
00078     struct SchemaTypeTraits<Double>
00079     {
00080         static const QName&
00081         type_name()
00082         {
00083             return IT_W3CConstants::NT_SCHEMA_DOUBLE;
00084         }
00085         enum { value_kind = IT_Reflect::BuiltInType::DOUBLE };
00086     };
00087 
00088     template<>
00089     struct SchemaTypeTraits<Int>
00090     {
00091         static const QName&
00092         type_name()
00093         {
00094             return IT_W3CConstants::NT_SCHEMA_INT;
00095         }
00096         enum { value_kind = IT_Reflect::BuiltInType::INT };
00097     };
00098 
00099     template<>
00100     struct SchemaTypeTraits<UInt>
00101     {
00102         static const QName&
00103         type_name()
00104         {
00105             return IT_W3CConstants::NT_SCHEMA_UINT;
00106         }
00107         enum { value_kind = IT_Reflect::BuiltInType::UINT };
00108     };
00109 
00110     template<>
00111     struct SchemaTypeTraits<Long>
00112     {
00113         static const QName&
00114         type_name()
00115         {
00116             return IT_W3CConstants::NT_SCHEMA_LONG;
00117         }
00118         enum { value_kind = IT_Reflect::BuiltInType::LONG };
00119     };
00120 
00121     template<>
00122     struct SchemaTypeTraits<Short>
00123     {
00124         static const QName&
00125         type_name()
00126         {
00127             return IT_W3CConstants::NT_SCHEMA_SHORT;
00128         }
00129         enum { value_kind = IT_Reflect::BuiltInType::SHORT };
00130     };
00131 
00132     template<>
00133     struct SchemaTypeTraits<ULong>
00134     {
00135         static const QName&
00136         type_name()
00137         {
00138             return IT_W3CConstants::NT_SCHEMA_ULONG;
00139         }
00140         enum { value_kind = IT_Reflect::BuiltInType::ULONG };
00141     };
00142 
00143     template<>
00144     struct SchemaTypeTraits<UShort>
00145     {
00146         static const QName&
00147         type_name()
00148         {
00149             return IT_W3CConstants::NT_SCHEMA_USHORT;
00150         }
00151         enum { value_kind = IT_Reflect::BuiltInType::USHORT };
00152     };
00153 
00154     template<>
00155     struct SchemaTypeTraits<Byte>
00156     {
00157         static const QName&
00158         type_name()
00159         {
00160             return IT_W3CConstants::NT_SCHEMA_BYTE;
00161         }
00162         enum { value_kind = IT_Reflect::BuiltInType::BYTE };
00163     };
00164 
00165     template<>
00166     struct SchemaTypeTraits<UByte>
00167     {
00168         static const QName&
00169         type_name()
00170         {
00171             return IT_W3CConstants::NT_SCHEMA_UBYTE;
00172         }
00173         enum { value_kind = IT_Reflect::BuiltInType::UBYTE };
00174     };
00175 
00176     template<>
00177     struct SchemaTypeTraits<String>
00178     {
00179         static const QName&
00180         type_name()
00181         {
00182             return IT_W3CConstants::NT_SCHEMA_STRING;
00183         }
00184         enum { value_kind = IT_Reflect::BuiltInType::STRING };
00185     };
00186 
00187     template<>
00188     struct SchemaTypeTraits<DateTime>
00189     {
00190         static const QName&
00191         type_name()
00192         {
00193             return IT_W3CConstants::NT_SCHEMA_DATETIME;
00194         }
00195         enum { value_kind = IT_Reflect::BuiltInType::DATETIME };
00196     };
00197 
00198     template <>
00199     struct SchemaTypeTraits<Decimal>
00200     {
00201         static const QName&
00202         type_name()
00203         {
00204             return IT_W3CConstants::NT_SCHEMA_DECIMAL;
00205         }
00206         enum { value_kind = IT_Reflect::BuiltInType::DECIMAL };
00207     };
00208 
00209     template <>
00210     struct SchemaTypeTraits<Base64Binary>
00211     {
00212         static const QName&
00213         type_name()
00214         {
00215             return IT_W3CConstants::NT_SCHEMA_BASE64;
00216         }
00217         enum { value_kind = IT_Reflect::BuiltInType::BASE64BINARY };
00218     };
00219 
00220     template<>
00221     struct SchemaTypeTraits<HexBinary>
00222     {
00223         static const QName&
00224         type_name()
00225         {
00226             return IT_W3CConstants::NT_SCHEMA_HBIN;
00227         }
00228         enum { value_kind = IT_Reflect::BuiltInType::HEXBINARY };
00229     };
00230 
00231     // Treat a raw binary buffer as base64.
00232     // 
00233     template <>
00234     struct SchemaTypeTraits<BinaryBuffer>
00235     {
00236         static const QName&
00237         type_name()
00238         {
00239             return IT_W3CConstants::NT_SCHEMA_BASE64;
00240         }
00241         enum { value_kind = IT_Reflect::BuiltInType::BASE64BINARY };
00242     };
00243 
00244     template<>
00245     struct SchemaTypeTraits<QName>
00246     {
00247         static const QName&
00248         type_name()
00249         {
00250             return IT_W3CConstants::NT_SCHEMA_QNAME;
00251         }
00252         enum { value_kind = IT_Reflect::BuiltInType::QNAME };
00253     };
00254 
00255     template <>
00256     struct SchemaTypeTraits<AnyURI>
00257     {
00258         static const QName&
00259         type_name()
00260         {
00261             return AnyURI::get_static_type();
00262         }
00263         enum { value_kind = IT_Reflect::BuiltInType::ANYURI };
00264     };
00265     
00266     template <>
00267     struct SchemaTypeTraits<Date>
00268     {
00269         static const QName&
00270         type_name()
00271         {
00272             return Date::get_static_type();
00273         }
00274         enum { value_kind = IT_Reflect::BuiltInType::DATE };
00275     };
00276     
00277     template <>
00278     struct SchemaTypeTraits<GDay>
00279     {
00280         static const QName&
00281         type_name()
00282         {
00283             return GDay::get_static_type();
00284         }
00285         enum { value_kind = IT_Reflect::BuiltInType::GDAY };
00286     };
00287     
00288     template <>
00289     struct SchemaTypeTraits<Duration>
00290     {
00291         static const QName&
00292         type_name()
00293         {
00294             return Duration::get_static_type();
00295         }
00296         enum { value_kind = IT_Reflect::BuiltInType::DURATION };
00297     };
00298     
00299     template <>
00300     struct SchemaTypeTraits<GMonth>
00301     {
00302         static const QName&
00303         type_name()
00304         {
00305             return GMonth::get_static_type();
00306         }
00307         enum { value_kind = IT_Reflect::BuiltInType::GMONTH };
00308     };
00309     
00310     template <>
00311     struct SchemaTypeTraits<GMonthDay>
00312     {
00313         static const QName&
00314         type_name()
00315         {
00316             return GMonthDay::get_static_type();
00317         }
00318         enum { value_kind = IT_Reflect::BuiltInType::GMDAY };
00319     };
00320     
00321     template <>
00322     struct SchemaTypeTraits<GYear>
00323     {
00324         static const QName&
00325         type_name()
00326         {
00327             return GYear::get_static_type();
00328         }
00329         enum { value_kind = IT_Reflect::BuiltInType::GYEAR };        
00330     };
00331     
00332     template <>
00333     struct SchemaTypeTraits<GYearMonth>
00334     {
00335         static const QName&
00336         type_name()
00337         {
00338             return GYearMonth::get_static_type();
00339         }
00340         enum { value_kind = IT_Reflect::BuiltInType::GYMON };        
00341     };
00342     
00343     template <>
00344     struct SchemaTypeTraits<Integer>
00345     {
00346         static const QName&
00347         type_name()
00348         {
00349             return Integer::get_static_type();
00350         }
00351         enum { value_kind = IT_Reflect::BuiltInType::INTEGER };        
00352     };
00353     
00354     template <>
00355     struct SchemaTypeTraits<Time>
00356     {
00357         static const QName&
00358         type_name()
00359         {
00360             return Time::get_static_type();
00361         }
00362         enum { value_kind = IT_Reflect::BuiltInType::TIME };
00363     };
00364     
00365     template <>
00366     struct SchemaTypeTraits<NormalizedString>
00367     {
00368         static const QName&
00369         type_name()
00370         {
00371             return NormalizedString::get_static_type();
00372         }
00373         enum { value_kind = IT_Reflect::BuiltInType::NSTRING };        
00374     };
00375     
00376     template <>
00377     struct SchemaTypeTraits<Token>
00378     {
00379         static const QName&
00380         type_name()
00381         {
00382             return Token::get_static_type();
00383         }
00384         enum { value_kind = IT_Reflect::BuiltInType::TOKEN };        
00385     };
00386     
00387     template <>
00388     struct SchemaTypeTraits<Language>
00389     {
00390         static const QName&
00391         type_name()
00392         {
00393             return Language::get_static_type();
00394         }
00395         enum { value_kind = IT_Reflect::BuiltInType::LANG };        
00396     };
00397     
00398     template <>
00399     struct SchemaTypeTraits<Name>
00400     {
00401         static const QName&
00402         type_name()
00403         {
00404             return Name::get_static_type();
00405         }
00406         enum { value_kind = IT_Reflect::BuiltInType::NAME };        
00407     };
00408     
00409     template <>
00410     struct SchemaTypeTraits<NCName>
00411     {
00412         static const QName&
00413         type_name()
00414         {
00415             return NCName::get_static_type();
00416         }
00417         enum { value_kind = IT_Reflect::BuiltInType::NCNAME };        
00418     };
00419     
00420     template <>
00421     struct SchemaTypeTraits<NMToken>
00422     {
00423         static const QName&
00424         type_name()
00425         {
00426             return NMToken::get_static_type();
00427         }
00428         enum { value_kind = IT_Reflect::BuiltInType::NMTOKEN };        
00429     };
00430     
00431     template <>
00432     struct SchemaTypeTraits<ID>
00433     {
00434         static const QName&
00435         type_name()
00436         {
00437             return ID::get_static_type();
00438         }
00439         enum { value_kind = IT_Reflect::BuiltInType::ID };        
00440     };
00441     
00442     template <>
00443     struct SchemaTypeTraits<PositiveInteger>
00444     {
00445         static const QName&
00446         type_name()
00447         {
00448             return PositiveInteger::get_static_type();
00449         }
00450         enum { value_kind = IT_Reflect::BuiltInType::PINT };
00451     };
00452     
00453     template <>
00454     struct SchemaTypeTraits<NonPositiveInteger>
00455     {
00456         static const QName&
00457         type_name()
00458         {
00459             return NonPositiveInteger::get_static_type();
00460         }
00461         enum { value_kind = IT_Reflect::BuiltInType::NPINT };        
00462     };
00463     
00464     template <>
00465     struct SchemaTypeTraits<NegativeInteger>
00466     {
00467         static const QName&
00468         type_name()
00469         {
00470             return NegativeInteger::get_static_type();
00471         }
00472         enum { value_kind = IT_Reflect::BuiltInType::NINT };
00473     };
00474     
00475     template <>
00476     struct SchemaTypeTraits<NonNegativeInteger>
00477     {
00478         static const QName&
00479         type_name()
00480         {
00481             return NonNegativeInteger::get_static_type();
00482         }
00483         enum { value_kind = IT_Reflect::BuiltInType::NNINT };
00484     };
00485 
00486     template <>
00487     struct SchemaTypeTraits<Any>
00488     {
00489         static const QName&
00490         type_name()
00491         {
00492             return Any::get_static_type();
00493         }
00494         enum { value_kind = IT_Reflect::BuiltInType::ANY };
00495     };
00496 
00497     template <>
00498     struct SchemaTypeTraits<AnyList>
00499     {
00500         static const QName&
00501         type_name()
00502         {
00503             return Any::get_static_type();
00504         }
00505         enum { value_kind = IT_Reflect::BuiltInType::ANY_LIST };
00506     };
00507 
00508     template <>
00509     struct SchemaTypeTraits<AnyHolder>
00510     {
00511         static const QName&
00512         type_name()
00513         {
00514             return AnyHolder::get_static_type();
00515         }
00516         enum { value_kind = IT_Reflect::BuiltInType::ANY_HOLDER };
00517     };
00518 
00519 }
00520 
00521 #endif  

Generated on Tue Mar 20 15:27:43 2007 for Artix by  doxygen 1.5.1-p1