home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / DTTYPED.HPP < prev    next >
C/C++ Source or Header  |  1996-11-21  |  11KB  |  329 lines

  1. #ifndef _DTTYPED_HPP
  2. #define _DTTYPED_HPP
  3.  
  4. #include <stddef.h>
  5. #include "dttype.hpp"
  6.  
  7. #define TYPE_ALIAS( _base, _alias )     \
  8. typedef DT ## _base DT ## _alias;
  9.  
  10. /*************
  11.  *** WBool ***
  12.  *************/
  13.  
  14. typedef DTBoolType DTType_WBool;
  15. typedef DTBoolType DTType_const_WBool;
  16.  
  17. /********************
  18.  *** String Types ***
  19.  ********************/
  20.  
  21. class METAEXPORTCLASSDEF DTType_Impl_String : public DTType {
  22.     public:
  23.         DTType_Impl_String( const MMType * imp );
  24.  
  25.         virtual WBool               Textify( WString &, DT_Textify ) const;
  26.         virtual WBool               DeTextify( const WString &, DT_Textify );
  27.  
  28.         virtual WBool               operator==( const DTType & o );
  29.  
  30.         virtual WBool               Set( const WChar * val );
  31.         virtual const WString &     Get() const;
  32.  
  33.         static DTType *             Instantiate( const MMType * );
  34.  
  35.     protected:
  36.         WString         _value;
  37. };
  38. typedef DTType_Impl_String DTType_WString;
  39.  
  40. class METAEXPORTCLASSDEF DTType_WFilePath : public DTType_Impl_String {
  41.     public:
  42.         DTType_WFilePath( const MMType * imp );
  43.  
  44.         virtual WBool               Browse( WWindow * parent, DTObject * obj );
  45.         virtual WBool               Textify( WString &, DT_Textify ) const;
  46.         virtual WBool               DeTextify( const WString &, DT_Textify );
  47.  
  48.         static DTType *             Instantiate( const MMType * );
  49. };
  50.  
  51. class METAEXPORTCLASSDEF DTType_Anything : public DTType_Impl_String {
  52.     public:
  53.         DTType_Anything( const MMType * imp );
  54.  
  55.         virtual WBool               Textify( WString &, DT_Textify ) const;
  56.         static DTType *             Instantiate( const MMType * );
  57. };
  58.  
  59. class METAEXPORTCLASSDEF DTType_Identifier : public DTType_Anything {
  60.     public:
  61.         DTType_Identifier( const MMType * imp, WBool allowNull );
  62.  
  63.         virtual WBool               DeTextify( const WString &, DT_Textify );
  64.  
  65.         static DTType *             Instantiate( const MMType * );
  66.  
  67.     private:
  68.         WBool   _allowNull;
  69. };
  70.  
  71. class METAEXPORTCLASSDEF DTType_NullOrIdentifier : public DTType_Identifier {
  72.     public:
  73.         DTType_NullOrIdentifier( const MMType * imp );
  74.         static DTType *             Instantiate( const MMType * );
  75. };
  76.  
  77. class METAEXPORTCLASSDEF DTType_IntegerOrIdentifier : public DTType_Anything {
  78.     public:
  79.         DTType_IntegerOrIdentifier( const MMType * imp, WBool allowNull );
  80.  
  81.         virtual WBool               DeTextify( const WString &, DT_Textify );
  82.  
  83.         static DTType *             Instantiate( const MMType * );
  84.  
  85.     private:
  86.         WBool   _allowNull;
  87. };
  88.  
  89. class METAEXPORTCLASSDEF DTType_NullOrIntegerOrIdentifier : public DTType_IntegerOrIdentifier {
  90.     public:
  91.         DTType_NullOrIntegerOrIdentifier( const MMType * mm );
  92.         static DTType *             Instantiate( const MMType * mm );
  93. };
  94.  
  95. TYPE_ALIAS( Type_Impl_String, Type_WString );
  96. TYPE_ALIAS( Type_Impl_String, Type_const_WString__ref_ );
  97. TYPE_ALIAS( Type_Impl_String, Type_const_WChar__ptr_ );
  98.  
  99. TYPE_ALIAS( Type_Anything, Type_WObject__ptr_ );
  100.  
  101. /******************
  102.  *** Color Type ***
  103.  ******************/
  104.  
  105. class METAEXPORTCLASSDEF DTType_WColor : public DTType {
  106.     public:
  107.         DTType_WColor( const MMType * imp );
  108.  
  109.         virtual WBool               Textify( WString &, DT_Textify ) const;
  110.         virtual WBool               DeTextify( const WString &, DT_Textify );
  111.  
  112.         virtual WBool               operator==( const DTType & o );
  113.  
  114.         virtual WBool               Set( const WColor & val );
  115.         virtual const WColor &      Get() const;
  116.  
  117.         virtual WBool               Browse( WWindow * parent, DTObject * obj );
  118.  
  119.         virtual WUInt               GetNumValues();
  120.         virtual WString             GetValue( WUInt i );
  121.  
  122.         static DTType *             Instantiate( const MMType * );
  123.  
  124.     private:
  125.         WColor          _c_value;
  126. };
  127.  
  128.  
  129. TYPE_ALIAS( Type_WColor, Type_const_WColor__ref_ );
  130.  
  131. /******************
  132.  *** WFont Type ***
  133.  ******************/
  134.  
  135. class METAEXPORTCLASSDEF DTType_WFont : public DTType {
  136.     public:
  137.         DTType_WFont( const MMType * imp );
  138.  
  139.         virtual WBool               Textify( WString &, DT_Textify ) const;
  140.         virtual WBool               DeTextify( const WString &, DT_Textify );
  141.  
  142.         virtual WBool               operator==( const DTType & o );
  143.  
  144.         virtual WBool               Set( const WFont & val );
  145.         virtual const WFont &       Get() const;
  146.  
  147.         virtual WBool               Browse( WWindow * parent, DTObject * obj );
  148.  
  149.         static DTType *             Instantiate( const MMType * );
  150.     private:
  151.         WFont           _value;
  152. };
  153.  
  154. TYPE_ALIAS( Type_WFont, Type_const_WFont__ref_ );
  155.  
  156. /******************
  157.  *** WRect Type ***
  158.  ******************/
  159.  
  160. class METAEXPORTCLASSDEF DTType_WRect : public DTType {
  161.     public:
  162.         DTType_WRect( const MMType * imp );
  163.  
  164.         virtual WBool               Textify( WString &, DT_Textify ) const;
  165.         virtual WBool               DeTextify( const WString &, DT_Textify );
  166.  
  167.         virtual WBool               operator==( const DTType & o );
  168.  
  169.         virtual WBool               Set( const WRect & val );
  170.         virtual const WRect &       Get() const;
  171.  
  172.         static DTType *             Instantiate( const MMType * );
  173.  
  174.     private:
  175.         WRect           _value;
  176. };
  177.  
  178. TYPE_ALIAS( Type_WRect, Type_const_WRect__ref_ );
  179.  
  180. /*******************
  181.  *** WPoint Type ***
  182.  *******************/
  183.  
  184. class METAEXPORTCLASSDEF DTType_WPoint : public DTType {
  185.     public:
  186.         DTType_WPoint( const MMType * imp );
  187.  
  188.         virtual WBool               Textify( WString &, DT_Textify ) const;
  189.         virtual WBool               DeTextify( const WString &, DT_Textify );
  190.  
  191.         virtual WBool               operator==( const DTType & o );
  192.  
  193.         virtual WBool               Set( const WPoint & val );
  194.         virtual const WPoint &      Get() const;
  195.  
  196.         static DTType *             Instantiate( const MMType * );
  197.  
  198.     private:
  199.         WPoint          _value;
  200. };
  201.  
  202. TYPE_ALIAS( Type_WPoint, Type_const_WPoint__ref_ );
  203.  
  204. /*******************
  205.  *** WSize Type ***
  206.  *******************/
  207.  
  208. class METAEXPORTCLASSDEF DTType_WSize : public DTType {
  209.     public:
  210.         DTType_WSize( const MMType * imp );
  211.  
  212.         virtual WBool               Textify( WString &, DT_Textify ) const;
  213.         virtual WBool               DeTextify( const WString &, DT_Textify );
  214.  
  215.         virtual WBool               operator==( const DTType & o );
  216.  
  217.         virtual WBool               Set( const WSize & val );
  218.         virtual const WSize &       Get() const;
  219.  
  220.         static DTType *             Instantiate( const MMType * );
  221.  
  222.     private:
  223.         WSize           _value;
  224. };
  225.  
  226.  
  227. /*******************
  228.  *** WRange Type ***
  229.  *******************/
  230.  
  231. class METAEXPORTCLASSDEF DTType_WRange : public DTType {
  232.     public:
  233.         DTType_WRange( const MMType * imp );
  234.  
  235.         virtual WBool               Textify( WString &, DT_Textify ) const;
  236.         virtual WBool               DeTextify( const WString &, DT_Textify );
  237.  
  238.         virtual WBool               operator==( const DTType & o );
  239.  
  240.         virtual WBool               Set( const WRange & val );
  241.         virtual const WRange &      Get() const;
  242.  
  243.         static DTType *             Instantiate( const MMType * );
  244.  
  245.     private:
  246.         WRange          _value;
  247. };
  248.  
  249. TYPE_ALIAS( Type_WRange, Type_const_WRange__ref_ );
  250.  
  251. /**********************
  252.  *** Integral Types ***
  253.  **********************/
  254.  
  255. class METAEXPORTCLASSDEF DTType_Impl_Integral : public DTType {
  256.     public:
  257.         DTType_Impl_Integral( const MMType * imp,
  258.                             WBool sign, size_t bytes );
  259.  
  260.         virtual WBool       Textify( WString &, DT_Textify ) const;
  261.         virtual WBool       DeTextify( const WString &, DT_Textify );
  262.  
  263.         virtual WBool       operator==( const DTType & o );
  264.  
  265.         virtual WBool       Set( long val );
  266.         virtual WLong       GetVal() const;
  267.  
  268.     private:
  269.         WBool           _sign;
  270.         size_t          _bytes;
  271.         WLong           _value;
  272. };
  273.  
  274. /*
  275.  * SIGNED is a macro used to determine if a data type is signed or not.
  276.  */
  277.  
  278. #define SIGNED( __type ) ( static_cast< __type >(-1) <= 0 )
  279.  
  280. #define MAKE_INTEGRAL( __type, __name )                                         \
  281. class METAEXPORTCLASSDEF DTType_ ## __name : public DTType_Impl_Integral {                              \
  282.     public:                                                                     \
  283.         DTType_ ## __name( const MMType * imp )                                 \
  284.             : DTType_Impl_Integral( imp, SIGNED( __type ), sizeof( __type ) ){} \
  285.                                                                                 \
  286.         virtual __type Get() const {                                            \
  287.             return (__type)DTType_Impl_Integral::GetVal();                      \
  288.         }                                                                       \
  289.                                                                                 \
  290.         static DTType *     Instantiate( const MMType * tp ) {                  \
  291.             return new DTType_ ## __name( tp );                                 \
  292.         }                                                                       \
  293. }
  294.  
  295. MAKE_INTEGRAL( WInt, WInt );
  296. MAKE_INTEGRAL( WUInt, WUInt );
  297. MAKE_INTEGRAL( WShort, WShort );
  298. MAKE_INTEGRAL( WUShort, WUShort );
  299. MAKE_INTEGRAL( WLong, WLong );
  300. MAKE_INTEGRAL( WULong, WULong );
  301. MAKE_INTEGRAL( WChar, WChar_Base );
  302. MAKE_INTEGRAL( WUChar, WUChar );
  303.  
  304. TYPE_ALIAS( Type_WUShort, Type_const_WUShort );
  305. TYPE_ALIAS( Type_WULong, Type_WButtonState );
  306.  
  307. MAKE_INTEGRAL( int, signed_int );
  308. MAKE_INTEGRAL( unsigned int, unsigned_int );
  309. MAKE_INTEGRAL( short, signed_short );
  310. MAKE_INTEGRAL( unsigned short, unsigned_short );
  311. MAKE_INTEGRAL( long, signed_long );
  312. MAKE_INTEGRAL( unsigned long, unsigned_long );
  313. MAKE_INTEGRAL( char, char );
  314. MAKE_INTEGRAL( unsigned char, unsigned_char );
  315.  
  316. class METAEXPORTCLASSDEF DTType_WChar : public DTType_WChar_Base {
  317.     public:
  318.         DTType_WChar( const MMType * imp )
  319.             : DTType_WChar_Base( imp ){}
  320.         virtual WBool               Textify( WString &, DT_Textify ) const;
  321.         virtual WBool               DeTextify( const WString &, DT_Textify );
  322.  
  323.         static DTType *     Instantiate( const MMType * tp ) {
  324.             return new DTType_WChar( tp );
  325.         }                                                                       \
  326. };
  327.  
  328. #endif // _DTTYPED_HPP
  329.