home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / OWLSRC.PAK / VALIDATE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  2.6 KB  |  157 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1993, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.5  $
  6. //
  7. // Implementation of TValidator, user input validator abstract base class
  8. //----------------------------------------------------------------------------
  9. #pragma hdrignore SECTION
  10. #include <owl/pch.h>
  11. #if !defined(OWL_VALIDATE_H)
  12. # include <owl/validate.h>
  13. #endif
  14. #if !defined(OWL_MODULE_H)
  15. # include <owl/module.h>
  16. #endif
  17. #include <stdlib.h>
  18. #include <ctype.h>
  19.  
  20. OWL_DIAGINFO;
  21.  
  22. #if !defined(SECTION) || SECTION == 1
  23.  
  24. //
  25. // Construct a validator
  26. //
  27. TValidator::TValidator()
  28. {
  29.   Options = 0;
  30. }
  31.  
  32. //
  33. //
  34. //
  35. TValidator::~TValidator()
  36. {
  37. }
  38.  
  39. //
  40. // Validator error display. Overridden in derived classes
  41. //
  42. void
  43. TValidator::Error(TWindow* /*owner*/)
  44. {
  45. }
  46.  
  47. //
  48. // Checks current input against validator. May adjust input if suppressFill
  49. // isn't set & validator has the voFill option set.
  50. //
  51. bool
  52. TValidator::IsValidInput(char far*, bool /*suppressFill*/)
  53. {
  54.   return true;
  55. }
  56.  
  57. //
  58. // Checks input against validator for completeness. Never modifies input.
  59. //
  60. bool
  61. TValidator::IsValid(const char far*)
  62. {
  63.   return true;
  64. }
  65.  
  66. //
  67. //
  68. //
  69. uint
  70. TValidator::Transfer(char far*, void*, TTransferDirection)
  71. {
  72.   return 0;
  73. }
  74.  
  75. //
  76. // Adjust the 'value' of the text, given a cursor position & an amount
  77. // Return the actual amount adjusted.
  78. //
  79. int
  80. TValidator::Adjust(string& /*text*/, uint& /*begPos*/, uint& /*endPos*/, int /*amount*/)
  81. {
  82.   return 0;
  83. }
  84.  
  85. //----------------------------------------------------------------------------
  86.  
  87. //
  88. //
  89. //
  90. TXValidator::TXValidator(uint resId)
  91. :
  92.   TXOwl(resId)
  93. {
  94. }
  95.  
  96.  
  97. //
  98. // Copies the exception so it can be rethrown at a safer time.
  99. //
  100. #if defined(BI_NO_COVAR_RET)
  101. TXBase*
  102. #else
  103. TXValidator*
  104. #endif
  105. TXValidator::Clone()
  106. {
  107.   return new TXValidator(*this);
  108. }
  109.  
  110. //
  111. // Throws the exception.
  112. //
  113. void
  114. TXValidator::Throw()
  115. {
  116.   THROW( *this );
  117. }
  118.  
  119. //
  120. // Creates an instance of TXValidator and throws it.
  121. //
  122. void
  123. TXValidator::Raise()
  124. {
  125.   TXValidator().Throw();
  126. }
  127.  
  128. #endif
  129. #if !defined(SECTION) || SECTION == 2
  130.  
  131. #if !defined(BI_NO_OBJ_STREAMING)
  132.  
  133. IMPLEMENT_STREAMABLE(TValidator);
  134.  
  135. //
  136. //
  137. //
  138. void*
  139. TValidator::Streamer::Read(ipstream& is, uint32 /*version*/) const
  140. {
  141.   is >> GetObject()->Options;
  142.   return GetObject();
  143. }
  144.  
  145. //
  146. //
  147. //
  148. void
  149. TValidator::Streamer::Write(opstream& os) const
  150. {
  151.   os << GetObject()->Options;
  152. }
  153.  
  154. #endif  // if !defined(BI_NO_OBJ_STREAMING)
  155.  
  156. #endif
  157.