home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 11.ddi / OWLSRC.PAK / FILTVAL.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  1.6 KB  |  69 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1993 by Borland International
  3. //   source\owl\filtval.cpp
  4. //----------------------------------------------------------------------------
  5. #pragma hdrignore SECTION
  6. #include <owl\owlpch.h>
  7. #include <owl\validate.h>
  8. #include <owl\applicat.h>
  9. #include <classlib\objstrm.h>
  10.  
  11. #if !defined(SECTION) || SECTION == 1
  12.  
  13.  
  14. TFilterValidator::TFilterValidator(const TCharSet& validChars)
  15.   : TValidator()
  16. {
  17.   ValidChars = validChars;
  18. }
  19.  
  20. BOOL
  21. TFilterValidator::IsValidInput(char far* str, BOOL /*suppressFill*/)
  22. {
  23.   for (const char far* p = str; *p; p++)
  24.     if (!ValidChars.Has(*p))
  25.       return FALSE;
  26.   return TRUE;
  27. }
  28.  
  29. BOOL
  30. TFilterValidator::IsValid(const char far* str)
  31. {
  32.   for (const char far* p = str; *p; p++)
  33.     if (!ValidChars.Has(*p))
  34.       return FALSE;
  35.   return TRUE;
  36. }
  37.  
  38. void
  39. TFilterValidator::Error()
  40. {
  41.   ::MessageBox(0, string(*GetApplicationObject(), IDS_VALINVALIDCHAR).c_str(),
  42.              GetApplicationObject()->GetName(),
  43.              MB_ICONEXCLAMATION | MB_OK | MB_TASKMODAL);
  44. }
  45.  
  46. #endif
  47. #if !defined(SECTION) || SECTION == 2
  48.  
  49. IMPLEMENT_STREAMABLE1(TFilterValidator, TValidator);
  50.  
  51. void*
  52. TFilterValidator::Streamer::Read(ipstream& is, uint32 /*version*/) const
  53. {
  54.   ReadBaseObject((TValidator*)GetObject(), is);
  55.   is >> GetObject()->ValidChars;
  56.   return GetObject();
  57. }
  58.  
  59. void
  60. TFilterValidator::Streamer::Write(opstream& os) const
  61. {
  62.   WriteBaseObject((TValidator*)GetObject(), os);
  63.   os << GetObject()->ValidChars;
  64. }
  65.  
  66. #endif
  67.  
  68.  
  69.