home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1998 September / dppcpro0998.iso / Rwc / Sybase / Install.exe / hpp.z / DTTYPED.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-25  |  12.5 KB  |  385 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_WBuffer : public DTType {
  41.     public:
  42.         DTType_WBuffer( const MMType * imp );
  43.  
  44.         virtual WBool               Textify( WString &, DT_Textify ) const;
  45.         virtual WBool               DeTextify( const WString &, DT_Textify );
  46.  
  47.         virtual WBool               Set( const WByte * val, WULong size );
  48.         virtual const WBuffer &     Get() const;
  49.  
  50.         virtual WBool               operator==( const DTType & o );
  51.  
  52.         static DTType *             Instantiate( const MMType * );
  53.  
  54.     protected:
  55.         WBuffer         _bufferValue;
  56. };
  57.  
  58. class METAEXPORTCLASSDEF DTType_WFilePath : public DTType_Impl_String {
  59.     public:
  60.         DTType_WFilePath( const MMType * imp );
  61.  
  62.         virtual WBool               Browse( WWindow * parent, DTObject * obj );
  63.         virtual WBool               Textify( WString &, DT_Textify ) const;
  64.         virtual WBool               DeTextify( const WString &, DT_Textify );
  65.  
  66.         static DTType *             Instantiate( const MMType * );
  67. };
  68.  
  69. class METAEXPORTCLASSDEF DTType_Anything : public DTType_Impl_String {
  70.     public:
  71.         DTType_Anything( const MMType * imp );
  72.  
  73.         virtual WBool               Textify( WString &, DT_Textify ) const;
  74.         static DTType *             Instantiate( const MMType * );
  75. };
  76.  
  77. class METAEXPORTCLASSDEF DTType_Identifier : public DTType_Anything {
  78.     public:
  79.         DTType_Identifier( 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_NullOrIdentifier : public DTType_Identifier {
  90.     public:
  91.         DTType_NullOrIdentifier( const MMType * imp );
  92.         static DTType *             Instantiate( const MMType * );
  93. };
  94.  
  95. class METAEXPORTCLASSDEF DTType_IntegerOrIdentifier : public DTType_Anything {
  96.     public:
  97.         DTType_IntegerOrIdentifier( const MMType * imp, WBool allowNull );
  98.  
  99.         virtual WBool               DeTextify( const WString &, DT_Textify );
  100.  
  101.         static DTType *             Instantiate( const MMType * );
  102.  
  103.     private:
  104.         WBool   _allowNull;
  105. };
  106.  
  107. class METAEXPORTCLASSDEF DTType_NullOrIntegerOrIdentifier : public DTType_IntegerOrIdentifier {
  108.     public:
  109.         DTType_NullOrIntegerOrIdentifier( const MMType * mm );
  110.         static DTType *             Instantiate( const MMType * mm );
  111. };
  112.  
  113. TYPE_ALIAS( Type_Impl_String, Type_WString );
  114. TYPE_ALIAS( Type_Impl_String, Type_const_WString__ref_ );
  115. TYPE_ALIAS( Type_Impl_String, Type_const_WChar__ptr_ );
  116.  
  117. TYPE_ALIAS( Type_Anything, Type_WObject__ptr_ );
  118.  
  119. /******************
  120.  *** Color Type ***
  121.  ******************/
  122.  
  123. class METAEXPORTCLASSDEF DTType_WColor : public DTType {
  124.     public:
  125.         DTType_WColor( const MMType * imp );
  126.  
  127.         virtual WBool               Textify( WString &, DT_Textify ) const;
  128.         virtual WBool               DeTextify( const WString &, DT_Textify );
  129.  
  130.         virtual WBool               operator==( const DTType & o );
  131.  
  132.         virtual WBool               Set( const WColor & val );
  133.         virtual const WColor &      Get() const;
  134.  
  135.         virtual WBool               Browse( WWindow * parent, DTObject * obj );
  136.  
  137.         virtual WUInt               GetNumValues();
  138.         virtual WString             GetValue( WUInt i );
  139.  
  140.         static DTType *             Instantiate( const MMType * );
  141.  
  142.     protected:
  143.         WColor          _c_value;
  144. };
  145.  
  146.  
  147. TYPE_ALIAS( Type_WColor, Type_const_WColor__ref_ );
  148.  
  149. /******************
  150.  *** WFont Type ***
  151.  ******************/
  152.  
  153. class METAEXPORTCLASSDEF DTType_WFont : public DTType {
  154.     public:
  155.         DTType_WFont( const MMType * imp );
  156.  
  157.         virtual WBool               Textify( WString &, DT_Textify ) const;
  158.         virtual WBool               DeTextify( const WString &, DT_Textify );
  159.  
  160.         virtual WBool               operator==( const DTType & o );
  161.  
  162.         virtual WBool               Set( const WFont & val );
  163.         virtual const WFont &       Get() const;
  164.  
  165.         virtual WBool               Browse( WWindow * parent, DTObject * obj );
  166.  
  167.         static DTType *             Instantiate( const MMType * );
  168.     private:
  169.         WFont           _value;
  170. };
  171.  
  172. TYPE_ALIAS( Type_WFont, Type_const_WFont__ref_ );
  173.  
  174. /******************
  175.  *** WRect Type ***
  176.  ******************/
  177.  
  178. class METAEXPORTCLASSDEF DTType_WRect : public DTType {
  179.     public:
  180.         DTType_WRect( const MMType * imp );
  181.  
  182.         virtual WBool               Textify( WString &, DT_Textify ) const;
  183.         virtual WBool               DeTextify( const WString &, DT_Textify );
  184.  
  185.         virtual WBool               operator==( const DTType & o );
  186.  
  187.         virtual WBool               Set( const WRect & val );
  188.         virtual const WRect &       Get() const;
  189.  
  190.         static DTType *             Instantiate( const MMType * );
  191.  
  192.     private:
  193.         WRect           _value;
  194. };
  195.  
  196. TYPE_ALIAS( Type_WRect, Type_const_WRect__ref_ );
  197.  
  198. /*******************
  199.  *** WPoint Type ***
  200.  *******************/
  201.  
  202. class METAEXPORTCLASSDEF DTType_WPoint : public DTType {
  203.     public:
  204.         DTType_WPoint( const MMType * imp );
  205.  
  206.         virtual WBool               Textify( WString &, DT_Textify ) const;
  207.         virtual WBool               DeTextify( const WString &, DT_Textify );
  208.  
  209.         virtual WBool               operator==( const DTType & o );
  210.  
  211.         virtual WBool               Set( const WPoint & val );
  212.         virtual const WPoint &      Get() const;
  213.  
  214.         static DTType *             Instantiate( const MMType * );
  215.  
  216.     private:
  217.         WPoint          _value;
  218. };
  219.  
  220. TYPE_ALIAS( Type_WPoint, Type_const_WPoint__ref_ );
  221.  
  222. /*******************
  223.  *** WSize Type ***
  224.  *******************/
  225.  
  226. class METAEXPORTCLASSDEF DTType_WSize : public DTType {
  227.     public:
  228.         DTType_WSize( const MMType * imp );
  229.  
  230.         virtual WBool               Textify( WString &, DT_Textify ) const;
  231.         virtual WBool               DeTextify( const WString &, DT_Textify );
  232.  
  233.         virtual WBool               operator==( const DTType & o );
  234.  
  235.         virtual WBool               Set( const WSize & val );
  236.         virtual const WSize &       Get() const;
  237.  
  238.         static DTType *             Instantiate( const MMType * );
  239.  
  240.     private:
  241.         WSize           _value;
  242. };
  243.  
  244.  
  245. /*******************
  246.  *** WRange Type ***
  247.  *******************/
  248.  
  249. class METAEXPORTCLASSDEF DTType_WRange : public DTType {
  250.     public:
  251.         DTType_WRange( const MMType * imp );
  252.  
  253.         virtual WBool               Textify( WString &, DT_Textify ) const;
  254.         virtual WBool               DeTextify( const WString &, DT_Textify );
  255.  
  256.         virtual WBool               operator==( const DTType & o );
  257.  
  258.         virtual WBool               Set( const WRange & val );
  259.         virtual const WRange &      Get() const;
  260.  
  261.         static DTType *             Instantiate( const MMType * );
  262.  
  263.     private:
  264.         WRange          _value;
  265. };
  266.  
  267. TYPE_ALIAS( Type_WRange, Type_const_WRange__ref_ );
  268.  
  269. class METAEXPORTCLASSDEF DTType_WBitmap : public DTType {
  270.     public:
  271.         DTType_WBitmap( const MMType * imp );
  272.  
  273.         virtual WBool               Textify( WString &, DT_Textify ) const;
  274.         virtual WBool               DeTextify( const WString &, DT_Textify );
  275.  
  276.         virtual WBool               operator==( const DTType & o );
  277.         virtual WBool               SetName( const WString & val );
  278.         virtual const WString &     GetName() const;
  279.  
  280.         static DTType *             Instantiate( const MMType * );
  281.  
  282.     protected:
  283.         WString         _value;
  284. };
  285.  
  286. class METAEXPORTCLASSDEF DTType_WHotKeyInfo : public DTType {
  287.     public:
  288.         DTType_WHotKeyInfo( const MMType * imp );
  289.  
  290.         virtual WBool               Textify( WString & s, DT_Textify ) const;
  291.         virtual WBool               DeTextify( const WString & s, DT_Textify );
  292.  
  293.         virtual WBool               operator==( const DTType & o );
  294.  
  295.         virtual WBool               Set( const WHotKeyInfo & val );
  296.         virtual const WHotKeyInfo & Get() const;
  297.  
  298.         static DTType *             Instantiate( const MMType * imp );
  299.  
  300.     protected:
  301.         WHotKeyInfo                 _value;
  302. };
  303.  
  304. /**********************
  305.  *** Integral Types ***
  306.  **********************/
  307.  
  308. class METAEXPORTCLASSDEF DTType_Impl_Integral : public DTType {
  309.     public:
  310.         DTType_Impl_Integral( const MMType * imp,
  311.                             WBool sign, size_t bytes );
  312.  
  313.         virtual WBool       Textify( WString &, DT_Textify ) const;
  314.         virtual WBool       DeTextify( const WString &, DT_Textify );
  315.  
  316.         virtual WBool       operator==( const DTType & o );
  317.  
  318.         virtual WBool       Set( long val );
  319.         virtual WLong       GetVal() const;
  320.  
  321.     private:
  322.         WBool           _sign;
  323.         size_t          _bytes;
  324.         WLong           _value;
  325. };
  326.  
  327. /*
  328.  * SIGNED is a macro used to determine if a data type is signed or not.
  329.  */
  330.  
  331. #define SIGNED( __type ) ( static_cast< __type >(-1) <= 0 )
  332.  
  333. #define MAKE_INTEGRAL( __type, __name )                                         \
  334. class METAEXPORTCLASSDEF DTType_ ## __name : public DTType_Impl_Integral {                              \
  335.     public:                                                                     \
  336.         DTType_ ## __name( const MMType * imp )                                 \
  337.             : DTType_Impl_Integral( imp, SIGNED( __type ), sizeof( __type ) ){} \
  338.                                                                                 \
  339.         virtual __type Get() const {                                            \
  340.             WTraceMember();                                                     \
  341.             return (__type)DTType_Impl_Integral::GetVal();                      \
  342.         }                                                                       \
  343.                                                                                 \
  344.         static DTType *     Instantiate( const MMType * tp ) {                  \
  345.             WTraceFunction();                                                   \
  346.             return new DTType_ ## __name( tp );                                 \
  347.         }                                                                       \
  348. }
  349.  
  350. MAKE_INTEGRAL( WInt, WInt );
  351. MAKE_INTEGRAL( WUInt, WUInt );
  352. MAKE_INTEGRAL( WShort, WShort );
  353. MAKE_INTEGRAL( WUShort, WUShort );
  354. MAKE_INTEGRAL( WLong, WLong );
  355. MAKE_INTEGRAL( WULong, WULong );
  356. MAKE_INTEGRAL( WChar, WChar_Base );
  357. MAKE_INTEGRAL( WUChar, WUChar );
  358.  
  359. TYPE_ALIAS( Type_WUShort, Type_const_WUShort );
  360. TYPE_ALIAS( Type_WULong, Type_WButtonState );
  361.  
  362. MAKE_INTEGRAL( int, signed_int );
  363. MAKE_INTEGRAL( unsigned int, unsigned_int );
  364. MAKE_INTEGRAL( short, signed_short );
  365. MAKE_INTEGRAL( unsigned short, unsigned_short );
  366. MAKE_INTEGRAL( long, signed_long );
  367. MAKE_INTEGRAL( unsigned long, unsigned_long );
  368. MAKE_INTEGRAL( char, char );
  369. MAKE_INTEGRAL( unsigned char, unsigned_char );
  370.  
  371. class METAEXPORTCLASSDEF DTType_WChar : public DTType_WChar_Base {
  372.     public:
  373.         DTType_WChar( const MMType * imp )
  374.             : DTType_WChar_Base( imp ){}
  375.         virtual WBool               Textify( WString &, DT_Textify ) const;
  376.         virtual WBool               DeTextify( const WString &, DT_Textify );
  377.  
  378.         static DTType *     Instantiate( const MMType * tp ) {
  379.             WTraceFunction();
  380.             return new DTType_WChar( tp );
  381.         }
  382. };
  383.  
  384. #endif // _DTTYPED_HPP
  385.