it_bus/integer.h

00001 #ifndef _IT_BUS_INTEGER_H_
00002 #define _IT_BUS_INTEGER_H_
00003 
00004 // @Copyright 2004 IONA Technologies, Plc. All Rights Reserved.
00005 //
00006 
00007 #ifndef IT_MINIMISE_INCLUDES
00008 #include <it_dsa/fixed_point.h>
00009 #endif
00010 
00011 #include <it_cal/types.h>
00012 #include <it_bus/exception.h>
00013 #include <it_bus/api_defines.h>
00014 #include <it_bus/any_simple_type.h>
00015 
00016 namespace IT_Reflect
00017 {
00018     class Reflection;
00019     template <class T> class ValueRef;
00020 }
00021 
00022 namespace IT_Bus
00023 {
00030     class IT_AFC_API Integer : public AnySimpleType
00031     {
00032       public:
00033         typedef IT_Reflect::ValueRef<IT_Bus::Integer> IT_ReflectionType;
00034 
00038         Integer(
00039         ) throw(());
00040 
00046         Integer(
00047             short value
00048         ) throw(());
00049 
00055         Integer(
00056             unsigned short value
00057         ) throw(());
00058 
00064         Integer(
00065             int value
00066         ) throw(());
00067 
00073         Integer(
00074             unsigned int value
00075         ) throw(());
00076 
00082         Integer(
00083             long value
00084         ) throw(());
00085 
00091         Integer(
00092             unsigned long value
00093         ) throw(());
00094 
00095 #if !IT_LONG_LONG_IS_SAME_AS_LONG
00096 
00101         Integer(
00102             IT_LongLong value
00103         ) throw(());
00104 
00110         Integer(
00111             IT_ULongLong value
00112         ) throw(());
00113 #endif
00114 
00121         Integer(
00122             const char* value,
00123             bool truncate = false
00124         ) throw((IT_Bus::Exception));
00125 
00132         Integer(
00133             const String& value,
00134             bool truncate = false
00135         ) throw((IT_Bus::Exception));
00136 
00143         Integer(
00144             const Decimal& value,
00145             bool truncate = false
00146         ) throw((IT_Bus::Exception));
00147 
00153         Integer(
00154             const Integer& copy
00155         ) throw(());
00156 
00160         Integer&
00161         operator=(
00162             const Integer& rhs
00163         ) throw(());
00164 
00168         Integer&
00169         operator+=(
00170             const Integer& rhs
00171         ) throw((IT_Bus::Exception));
00172 
00176         Integer&
00177         operator-=(
00178             const Integer& rhs
00179         ) throw((IT_Bus::Exception));
00180 
00184         Integer&
00185         operator*=(
00186             const Integer& rhs
00187         ) throw((IT_Bus::Exception));
00188 
00192         Integer&
00193         operator/=(
00194             const Integer& rhs
00195         ) throw((IT_Bus::Exception));
00196 
00200         Integer&
00201         operator%=(
00202             const Integer& rhs
00203         ) throw((IT_Bus::Exception));
00204 
00208         Integer&
00209         operator++(
00210         ) throw((IT_Bus::Exception));
00211 
00215         const Integer
00216         operator++(
00217             int
00218         ) throw((IT_Bus::Exception));
00219 
00223         Integer&
00224         operator--(
00225         ) throw((IT_Bus::Exception));
00226 
00230         const Integer
00231         operator--(
00232             int
00233         ) throw((IT_Bus::Exception));
00234 
00238         bool
00239         is_negative(
00240         ) const throw(());
00241 
00245         bool
00246         is_positive(
00247         ) const throw(());
00248 
00252         bool
00253         is_non_negative(
00254         ) const throw(());
00255 
00259         bool
00260         is_non_positive(
00261         ) const throw(());
00262 
00275         int
00276         compare(
00277             const Integer& other
00278         ) const throw(());
00279 
00285         const Decimal&
00286         get_value(
00287         ) const throw(());
00288 
00301         void
00302         set_value(
00303             const Decimal& value,
00304             bool truncate = false
00305         ) throw((IT_Bus::Exception));
00306 
00312         String
00313         to_string(
00314         ) const throw(());
00315 
00322         static bool
00323         is_valid_integer(
00324             const Decimal& value
00325         ) throw(());
00326 
00327         // Implementation of methods from AnyType.
00328         //
00329         virtual AnyType&
00330         copy(
00331             const AnyType& copy
00332         );
00333 
00341         virtual AnyType::Kind
00342         get_kind() const;
00343 
00350         virtual const QName&
00351         get_type() const;
00352 
00353         virtual IT_Reflect::Reflection*
00354         get_reflection(
00355         ) throw((IT_Reflect::ReflectException));
00356         
00357         virtual const IT_Reflect::Reflection*
00358         get_reflection(
00359         ) const throw((IT_Reflect::ReflectException));
00360 
00361         // Implementation of methods from AnySimpleType.
00362         //
00363         virtual void
00364         write_value(
00365             AnySimpleTypeWriter& writer
00366         ) const throw((IT_Bus::SerializationException));
00367 
00368         virtual void
00369         read_value(
00370             AnySimpleTypeReader& reader
00371         ) throw((IT_Bus::DeserializationException));
00372 
00373         // Used by SchemaTypeTraits.
00374         //
00375         static const QName&
00376         get_static_type();
00377 
00378       protected:
00386         virtual void
00387         validate(
00388             const Decimal& value
00389         ) const throw((IT_Bus::Exception));
00390 
00398         static Decimal
00399         from_string(
00400             const char* value,
00401             bool truncate = false
00402         ) throw((IT_Bus::Exception));
00403 
00410         static Decimal
00411         from_signed(
00412             IT_LongLong value
00413         ) throw(());
00414 
00421         static Decimal
00422         from_unsigned(
00423             IT_ULongLong value
00424         ) throw(());
00425         
00431         static void
00432         validate_integer(
00433             const Decimal& value
00434         ) throw((IT_Bus::Exception));
00435 
00439         Decimal m_value;
00440     };
00441 
00448     class IT_AFC_API NonPositiveInteger : public Integer
00449     {
00450       public:
00451         typedef IT_Reflect::ValueRef<IT_Bus::NonPositiveInteger>
00452         IT_ReflectionType;
00453 
00457         NonPositiveInteger(
00458         ) throw(());
00459 
00465         NonPositiveInteger(
00466             short value
00467         ) throw((IT_Bus::Exception));
00468 
00474         NonPositiveInteger(
00475             unsigned short value
00476         ) throw((IT_Bus::Exception));
00477 
00483         NonPositiveInteger(
00484             int value
00485         ) throw((IT_Bus::Exception));
00486 
00492         NonPositiveInteger(
00493             unsigned int value
00494         ) throw((IT_Bus::Exception));
00495 
00501         NonPositiveInteger(
00502             long value
00503         ) throw((IT_Bus::Exception));
00504 
00510         NonPositiveInteger(
00511             unsigned long value
00512         ) throw((IT_Bus::Exception));
00513 
00514 #if !IT_LONG_LONG_IS_SAME_AS_LONG
00515 
00520         NonPositiveInteger(
00521             IT_LongLong value
00522         ) throw((IT_Bus::Exception));
00523 
00529         NonPositiveInteger(
00530             IT_ULongLong value
00531         ) throw((IT_Bus::Exception));
00532 #endif
00533 
00540         NonPositiveInteger(
00541             const char* value,
00542             bool truncate = false
00543         ) throw((IT_Bus::Exception));
00544 
00551         NonPositiveInteger(
00552             const String& value,
00553             bool truncate = false
00554         ) throw((IT_Bus::Exception));
00555 
00562         NonPositiveInteger(
00563             const Decimal& value,
00564             bool truncate = false
00565         ) throw((IT_Bus::Exception));
00566 
00572         NonPositiveInteger(
00573             const Integer& copy
00574         ) throw((IT_Bus::Exception));
00575 
00579         NonPositiveInteger(
00580             const NonPositiveInteger& copy
00581         ) throw(());
00582 
00586         NonPositiveInteger&
00587         operator=(
00588             short value
00589         ) throw((IT_Bus::Exception));
00590 
00594         NonPositiveInteger&
00595         operator=(
00596             unsigned short value
00597         ) throw((IT_Bus::Exception));
00598 
00602         NonPositiveInteger&
00603         operator=(
00604             int value
00605         ) throw((IT_Bus::Exception));
00606 
00610         NonPositiveInteger&
00611         operator=(
00612             unsigned int value
00613         ) throw((IT_Bus::Exception));
00614 
00618         NonPositiveInteger&
00619         operator=(
00620             long value
00621         ) throw((IT_Bus::Exception));
00622 
00626         NonPositiveInteger&
00627         operator=(
00628             unsigned long value
00629         ) throw((IT_Bus::Exception));
00630 
00631 #if !IT_LONG_LONG_IS_SAME_AS_LONG
00632 
00635         NonPositiveInteger&
00636         operator=(
00637             IT_LongLong value
00638         ) throw((IT_Bus::Exception));
00639 
00643         NonPositiveInteger&
00644         operator=(
00645             IT_ULongLong value
00646         ) throw((IT_Bus::Exception));
00647 #endif
00648 
00652         NonPositiveInteger&
00653         operator=(
00654             const Integer& rhs
00655         ) throw((IT_Bus::Exception));
00656 
00660         NonPositiveInteger&
00661         operator=(
00662             const NonPositiveInteger& rhs
00663         ) throw(());
00664 
00671         static bool
00672         is_valid_non_positive_integer(
00673             const Decimal& value
00674         ) throw(());
00675 
00676         // Implementation of methods from AnyType.
00677         //
00678         virtual AnyType&
00679         copy(
00680             const AnyType& copy
00681         );
00682 
00688         virtual const QName&
00689         get_type() const;
00690 
00691         virtual IT_Reflect::Reflection*
00692         get_reflection(
00693         ) throw((IT_Reflect::ReflectException));
00694         
00695         virtual const IT_Reflect::Reflection*
00696         get_reflection(
00697         ) const throw((IT_Reflect::ReflectException));
00698 
00699         // Used by SchemaTypeTraits.
00700         //
00701         static const QName&
00702         get_static_type();
00703 
00704       protected:
00712         virtual void
00713         validate(
00714             const Decimal& value
00715         ) const throw((IT_Bus::Exception));
00716 
00723         static void
00724         validate_non_positive_integer(
00725             const Decimal& value
00726         ) throw((IT_Bus::Exception));
00727     };
00728 
00735     class IT_AFC_API NegativeInteger : public NonPositiveInteger
00736     {
00737       public:
00738         typedef IT_Reflect::ValueRef<IT_Bus::NegativeInteger>
00739         IT_ReflectionType;
00740 
00744         NegativeInteger(
00745         ) throw(());
00746 
00752         NegativeInteger(
00753             short value
00754         ) throw((IT_Bus::Exception));
00755 
00761         NegativeInteger(
00762             int value
00763         ) throw((IT_Bus::Exception));
00764 
00770         NegativeInteger(
00771             long value
00772         ) throw((IT_Bus::Exception));
00773 
00774 #if !IT_LONG_LONG_IS_SAME_AS_LONG
00775 
00780         NegativeInteger(
00781             IT_LongLong value
00782         ) throw((IT_Bus::Exception));
00783 #endif
00784 
00791         NegativeInteger(
00792             const char* value,
00793             bool truncate = false
00794         ) throw((IT_Bus::Exception));
00795 
00802         NegativeInteger(
00803             const String& value,
00804             bool truncate = false
00805         ) throw((IT_Bus::Exception));
00806 
00813         NegativeInteger(
00814             const Decimal& value,
00815             bool truncate = false
00816         ) throw((IT_Bus::Exception));
00817 
00823         NegativeInteger(
00824             const Integer& copy
00825         ) throw((IT_Bus::Exception));
00826 
00830         NegativeInteger(
00831             const NegativeInteger& copy
00832         ) throw(());
00833 
00837         NegativeInteger&
00838         operator=(
00839             short value
00840         ) throw((IT_Bus::Exception));
00841 
00845         NegativeInteger&
00846         operator=(
00847             int value
00848         ) throw((IT_Bus::Exception));
00849 
00853         NegativeInteger&
00854         operator=(
00855             long value
00856         ) throw((IT_Bus::Exception));
00857 
00858 #if !IT_LONG_LONG_IS_SAME_AS_LONG
00859 
00862         NegativeInteger&
00863         operator=(
00864             IT_LongLong value
00865         ) throw((IT_Bus::Exception));
00866 #endif
00867 
00871         NegativeInteger&
00872         operator=(
00873             const Integer& rhs
00874         ) throw((IT_Bus::Exception));
00875 
00879         NegativeInteger&
00880         operator=(
00881             const NegativeInteger& rhs
00882         ) throw(());
00883 
00889         static bool
00890         is_valid_negative_integer(
00891             const Decimal& value
00892         ) throw(());
00893 
00894         // Implementation of methods from AnyType.
00895         //
00896         virtual AnyType&
00897         copy(
00898             const AnyType& copy
00899         );
00900 
00906         virtual const QName&
00907         get_type() const;
00908 
00909         virtual IT_Reflect::Reflection*
00910         get_reflection(
00911         ) throw((IT_Reflect::ReflectException));
00912         
00913         virtual const IT_Reflect::Reflection*
00914         get_reflection(
00915         ) const throw((IT_Reflect::ReflectException));
00916 
00917         // Used by SchemaTypeTraits.
00918         //
00919         static const QName&
00920         get_static_type();
00921 
00922       protected:
00930         virtual void
00931         validate(
00932             const Decimal& value
00933         ) const throw((IT_Bus::Exception));
00934 
00941         static void
00942         validate_negative_integer(
00943             const Decimal& value
00944         ) throw((IT_Bus::Exception));
00945     };
00946 
00953     class IT_AFC_API NonNegativeInteger : public Integer
00954     {
00955       public:
00956         typedef IT_Reflect::ValueRef<IT_Bus::NonNegativeInteger>
00957         IT_ReflectionType;
00958 
00962         NonNegativeInteger(
00963         ) throw(());
00964 
00970         NonNegativeInteger(
00971             short value
00972         ) throw((IT_Bus::Exception));
00973 
00979         NonNegativeInteger(
00980             unsigned short value
00981         ) throw(());
00982 
00988         NonNegativeInteger(
00989             int value
00990         ) throw((IT_Bus::Exception));
00991 
00997         NonNegativeInteger(
00998             unsigned int value
00999         ) throw(());
01000 
01006         NonNegativeInteger(
01007             long value
01008         ) throw((IT_Bus::Exception));
01009 
01015         NonNegativeInteger(
01016             unsigned long value
01017         ) throw(());
01018 
01019 #if !IT_LONG_LONG_IS_SAME_AS_LONG
01020 
01025         NonNegativeInteger(
01026             IT_LongLong value
01027         ) throw((IT_Bus::Exception));
01028 
01034         NonNegativeInteger(
01035             IT_ULongLong value
01036         ) throw(());
01037 #endif
01038 
01045         NonNegativeInteger(
01046             const char* value,
01047             bool truncate = false
01048         ) throw((IT_Bus::Exception));
01049 
01056         NonNegativeInteger(
01057             const String& value,
01058             bool truncate = false
01059         ) throw((IT_Bus::Exception));
01060 
01067         NonNegativeInteger(
01068             const Decimal& value,
01069             bool truncate = false
01070         ) throw((IT_Bus::Exception));
01071 
01077         NonNegativeInteger(
01078             const Integer& copy
01079         ) throw((IT_Bus::Exception));
01080 
01084         NonNegativeInteger(
01085             const NonNegativeInteger& copy
01086         ) throw(());
01087 
01091         NonNegativeInteger&
01092         operator=(
01093             short value
01094         ) throw((IT_Bus::Exception));
01095 
01099         NonNegativeInteger&
01100         operator=(
01101             unsigned short value
01102         ) throw(());
01103 
01107         NonNegativeInteger&
01108         operator=(
01109             int value
01110         ) throw((IT_Bus::Exception));
01111 
01115         NonNegativeInteger&
01116         operator=(
01117             unsigned int value
01118         ) throw(());
01119 
01123         NonNegativeInteger&
01124         operator=(
01125             long value
01126         ) throw((IT_Bus::Exception));
01127 
01131         NonNegativeInteger&
01132         operator=(
01133             unsigned long value
01134         ) throw(());
01135 
01136 #if !IT_LONG_LONG_IS_SAME_AS_LONG
01137 
01140         NonNegativeInteger&
01141         operator=(
01142             IT_LongLong value
01143         ) throw((IT_Bus::Exception));
01144 
01148         NonNegativeInteger&
01149         operator=(
01150             IT_ULongLong value
01151         ) throw(());
01152 #endif
01153 
01157         NonNegativeInteger&
01158         operator=(
01159             const Integer& rhs
01160         ) throw((IT_Bus::Exception));
01161 
01165         NonNegativeInteger&
01166         operator=(
01167             const NonNegativeInteger& rhs
01168         ) throw(());
01169 
01175         static bool
01176         is_valid_non_negative_integer(
01177             const Decimal& value
01178         ) throw(());
01179 
01180         // Implementation of methods from AnyType.
01181         //
01182         virtual AnyType&
01183         copy(
01184             const AnyType& copy
01185         );
01186 
01192         virtual const QName&
01193         get_type() const;
01194 
01195         virtual IT_Reflect::Reflection*
01196         get_reflection(
01197         ) throw((IT_Reflect::ReflectException));
01198         
01199         virtual const IT_Reflect::Reflection*
01200         get_reflection(
01201         ) const throw((IT_Reflect::ReflectException));
01202 
01203         // Used by SchemaTypeTraits.
01204         //
01205         static const QName&
01206         get_static_type();
01207 
01208       protected:
01216         virtual void
01217         validate(
01218             const Decimal& value
01219         ) const throw((IT_Bus::Exception));
01220 
01227         static void
01228         validate_non_negative_integer(
01229             const Decimal& value
01230         ) throw((IT_Bus::Exception));
01231     };
01232 
01239     class IT_AFC_API PositiveInteger : public NonNegativeInteger
01240     {
01241       public:
01242         typedef IT_Reflect::ValueRef<IT_Bus::PositiveInteger>
01243         IT_ReflectionType;
01244 
01248         PositiveInteger(
01249         ) throw(());
01250 
01256         PositiveInteger(
01257             short value
01258         ) throw((IT_Bus::Exception));
01259 
01265         PositiveInteger(
01266             unsigned short value
01267         ) throw((IT_Bus::Exception));
01268 
01274         PositiveInteger(
01275             int value
01276         ) throw((IT_Bus::Exception));
01277 
01283         PositiveInteger(
01284             unsigned int value
01285         ) throw((IT_Bus::Exception));
01286 
01292         PositiveInteger(
01293             long value
01294         ) throw((IT_Bus::Exception));
01295 
01301         PositiveInteger(
01302             unsigned long value
01303         ) throw((IT_Bus::Exception));
01304 
01305 #if !IT_LONG_LONG_IS_SAME_AS_LONG
01306 
01311         PositiveInteger(
01312             IT_LongLong value
01313         ) throw((IT_Bus::Exception));
01314 
01320         PositiveInteger(
01321             IT_ULongLong value
01322         ) throw((IT_Bus::Exception));
01323 #endif
01324 
01331         PositiveInteger(
01332             const char* value,
01333             bool truncate = false
01334         ) throw((IT_Bus::Exception));
01335 
01342         PositiveInteger(
01343             const String& value,
01344             bool truncate = false
01345         ) throw((IT_Bus::Exception));
01346 
01353         PositiveInteger(
01354             const Decimal& value,
01355             bool truncate = false
01356         ) throw((IT_Bus::Exception));
01357 
01363         PositiveInteger(
01364             const Integer& copy
01365         ) throw((IT_Bus::Exception));
01366 
01372         PositiveInteger(
01373             const PositiveInteger& copy
01374         ) throw(());
01375 
01379         PositiveInteger&
01380         operator=(
01381             short value
01382         ) throw((IT_Bus::Exception));
01383 
01387         PositiveInteger&
01388         operator=(
01389             unsigned short value
01390         ) throw((IT_Bus::Exception));
01391 
01395         PositiveInteger&
01396         operator=(
01397             int value
01398         ) throw((IT_Bus::Exception));
01399 
01403         PositiveInteger&
01404         operator=(
01405             unsigned int value
01406         ) throw((IT_Bus::Exception));
01407 
01411         PositiveInteger&
01412         operator=(
01413             long value
01414         ) throw((IT_Bus::Exception));
01415 
01419         PositiveInteger&
01420         operator=(
01421             unsigned long value
01422         ) throw((IT_Bus::Exception));
01423 
01424 #if !IT_LONG_LONG_IS_SAME_AS_LONG
01425 
01428         PositiveInteger&
01429         operator=(
01430             IT_LongLong value
01431         ) throw((IT_Bus::Exception));
01432 
01436         PositiveInteger&
01437         operator=(
01438             IT_ULongLong value
01439         ) throw((IT_Bus::Exception));
01440 #endif
01441 
01445         PositiveInteger&
01446         operator=(
01447             const Integer& rhs
01448         ) throw((IT_Bus::Exception));
01449 
01453         PositiveInteger&
01454         operator=(
01455             const PositiveInteger& rhs
01456         ) throw(());
01457 
01463         static bool
01464         is_valid_positive_integer(
01465             const Decimal& value
01466         ) throw(());
01467 
01468         // Implementation of methods from AnyType.
01469         //
01470         virtual AnyType&
01471         copy(
01472             const AnyType& copy
01473         );
01474 
01480         virtual const QName&
01481         get_type() const;
01482 
01483         virtual IT_Reflect::Reflection*
01484         get_reflection(
01485         ) throw((IT_Reflect::ReflectException));
01486         
01487         virtual const IT_Reflect::Reflection*
01488         get_reflection(
01489         ) const throw((IT_Reflect::ReflectException));
01490 
01491         // Used by SchemaTypeTraits.
01492         //
01493         static const QName&
01494         get_static_type();
01495 
01496       protected:
01504         virtual void
01505         validate(
01506             const Decimal& value
01507         ) const throw((IT_Bus::Exception));
01508 
01515         static void
01516         validate_positive_integer(
01517             const Decimal& value
01518         ) throw((IT_Bus::Exception));
01519     };
01520 
01524     extern IT_AFC_API bool
01525     operator==(
01526         const Integer& lhs,
01527         const Integer& rhs
01528     ) throw(());
01529 
01533     extern IT_AFC_API bool
01534     operator!=(
01535         const Integer& lhs,
01536         const Integer& rhs
01537     ) throw(());
01538 
01542     extern IT_AFC_API bool
01543     operator<(
01544         const Integer& lhs,
01545         const Integer& rhs
01546     ) throw(());
01547 
01551     extern IT_AFC_API bool
01552     operator>(
01553         const Integer& lhs,
01554         const Integer& rhs
01555     ) throw(());
01556 
01560     extern IT_AFC_API bool
01561     operator>=(
01562         const Integer& lhs,
01563         const Integer& rhs
01564     ) throw(());
01565 
01569     extern IT_AFC_API bool
01570     operator<=(
01571         const Integer& lhs,
01572         const Integer& rhs
01573     ) throw(());
01574 
01578     extern IT_AFC_API Integer
01579     operator+(
01580         const Integer& rhs
01581     ) throw(());
01582 
01586     extern IT_AFC_API Integer
01587     operator-(
01588         const Integer& rhs
01589     ) throw(());
01590 
01594     extern IT_AFC_API bool
01595     operator!(
01596         const Integer& rhs
01597     ) throw(());
01598 
01602     extern IT_AFC_API Integer
01603     operator+(
01604         const Integer& lhs,
01605         const Integer& rhs
01606     ) throw((IT_Bus::Exception));
01607 
01611     extern IT_AFC_API Integer
01612     operator-(
01613         const Integer& lhs,
01614         const Integer& rhs
01615     ) throw((IT_Bus::Exception));
01616 
01620     extern IT_AFC_API Integer
01621     operator*(
01622         const Integer& lhs,
01623         const Integer& rhs
01624     ) throw((IT_Bus::Exception));
01625 
01629     extern IT_AFC_API Integer
01630     operator/(
01631         const Integer& lhs,
01632         const Integer& rhs
01633     ) throw((IT_Bus::Exception));
01634 
01638     extern IT_AFC_API Integer
01639     operator%(
01640         const Integer& lhs,
01641         const Integer& rhs
01642     ) throw((IT_Bus::Exception));
01643 
01644 }
01645 
01646 
01647 #endif /*_IT_BUS_INTEGER_H_*/

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