home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / vrac / ve2tv103.zip / TINTFILE.H < prev    next >
C/C++ Source or Header  |  1994-07-31  |  4KB  |  142 lines

  1. // File    : TINTFILE.H
  2. // Author  : Eric Woodruff,  CIS ID: 72134,1150
  3. // Updated : Sun 07/31/94 15:56:28
  4. // Note    : Copyright 1994, Eric Woodruff, All rights reserved
  5. // Compiler: Borland C++ 3.1 to 4.02
  6. //
  7. // TInteger, TLong, and TFilename class header file.  Nothing special, just
  8. // enough to provide some form of validated input for the demo.
  9. //
  10.  
  11. #if !defined(__FLAT__)
  12.  
  13. #if !defined(_NEAR)
  14. #define _NEAR   near
  15. #endif
  16.  
  17. #if !defined(_FAR)
  18. #define _FAR    far
  19. #endif
  20.  
  21. #endif
  22.  
  23. #if defined(Uses_TInteger)
  24.  
  25. class TInteger : public TInputLine
  26. {
  27. private:
  28.     short max_val, min_val;     // Maximum and minimum values.
  29.  
  30. public:
  31.     TInteger(const TRect &bounds, int aMaxLen, short maxVal = 32767,
  32.       short minVal = 0);
  33.  
  34.     virtual ushort dataSize();
  35.     virtual void getData(void *rec);
  36.     virtual void setData(void *rec);
  37.     virtual Boolean valid(ushort command);
  38.     virtual void handleEvent(TEvent& event);
  39.  
  40. private:
  41.     virtual const char *streamableName() const
  42.         { return name; }
  43.  
  44. protected:
  45.     TInteger( StreamableInit );
  46.     virtual void write( opstream& );
  47.     virtual void *read( ipstream& );
  48.  
  49. public:
  50.     static const char * const _NEAR name;
  51.     static TStreamable *build();
  52. };
  53.  
  54. inline ipstream& operator >> ( ipstream& is, TInteger& cl )
  55.     { return is >> (TStreamable&)cl; }
  56. inline ipstream& operator >> ( ipstream& is, TInteger*& cl )
  57.     { return is >> (void *&)cl; }
  58.  
  59. inline opstream& operator << ( opstream& os, TInteger& cl )
  60.     { return os << (TStreamable&)cl; }
  61. inline opstream& operator << ( opstream& os, TInteger* cl )
  62.     { return os << (TStreamable *)cl; }
  63.  
  64. #endif      // class TInteger
  65.  
  66. #if defined(Uses_TLong)
  67.  
  68. class TLong : public TInputLine
  69. {
  70. private:
  71.     long max_val, min_val;     // Maximum and minimum values.
  72.  
  73. public:
  74.     TLong(const TRect &bounds, int aMaxLen, long maxVal = 0x7FFFFFFFL,
  75.       long minVal = 0L);
  76.  
  77.     virtual ushort dataSize();
  78.     virtual void getData(void *rec);
  79.     virtual void setData(void *rec);
  80.     virtual Boolean valid(ushort command);
  81.     virtual void handleEvent(TEvent& event);
  82.  
  83. private:
  84.     virtual const char *streamableName() const
  85.         { return name; }
  86.  
  87. protected:
  88.     TLong( StreamableInit );
  89.     virtual void write( opstream& );
  90.     virtual void *read( ipstream& );
  91.  
  92. public:
  93.     static const char * const _NEAR name;
  94.     static TStreamable *build();
  95. };
  96.  
  97. inline ipstream& operator >> ( ipstream& is, TLong& cl )
  98.     { return is >> (TStreamable&)cl; }
  99. inline ipstream& operator >> ( ipstream& is, TLong*& cl )
  100.     { return is >> (void *&)cl; }
  101.  
  102. inline opstream& operator << ( opstream& os, TLong& cl )
  103.     { return os << (TStreamable&)cl; }
  104. inline opstream& operator << ( opstream& os, TLong* cl )
  105.     { return os << (TStreamable *)cl; }
  106.  
  107. #endif      // class TLong
  108.  
  109. #if defined(Uses_TFilename)
  110.  
  111. class TFilename : public TInputLine
  112. {
  113. public:
  114.     TFilename(const TRect&bounds, int aMaxLen) :
  115.         TInputLine(bounds, aMaxLen) {}
  116.  
  117.     virtual void handleEvent(TEvent& event);
  118.  
  119. private:
  120.     virtual const char *streamableName() const
  121.         { return name; }
  122.  
  123. protected:
  124.     TFilename( StreamableInit );
  125.  
  126. public:
  127.     static const char * const _NEAR name;
  128.     static TStreamable *build();
  129. };
  130.  
  131. inline ipstream& operator >> ( ipstream& is, TFilename& cl )
  132.     { return is >> (TStreamable&)cl; }
  133. inline ipstream& operator >> ( ipstream& is, TFilename*& cl )
  134.     { return is >> (void *&)cl; }
  135.  
  136. inline opstream& operator << ( opstream& os, TFilename& cl )
  137.     { return os << (TStreamable&)cl; }
  138. inline opstream& operator << ( opstream& os, TFilename* cl )
  139.     { return os << (TStreamable *)cl; }
  140.  
  141. #endif      // class TFilename
  142.