OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
filtval.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1993, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Implementation of TFilterValidator, a validator that filters out keys that
7/// are not in the valid character set.
8//----------------------------------------------------------------------------
9#include <owl/pch.h>
10
11#include <owl/validate.h>
12#include <owl/validate.rh>
13#include <owl/applicat.h>
14#include <owl/appdict.h>
15#include <owl/framewin.h>
16
17namespace owl {
18
20
21/** Let the compiler know that the following template instances will be defined elsewhere. **/
22//#pragma option -Jgx
23
24//
25/// Constructs a filter validator object by first calling the constructor inherited
26/// from TValidator, then setting ValidChars to validChars.
27//
34
35//
36/// IsValidInput overrides TValidator's virtual function and checks each character
37/// in the string str to ensure it is in the set of allowed characters, ValidChar.
38/// IsValidInput returns true if all characters in str are valid; otherwise, it
39/// returns false.
40//
41bool
42TFilterValidator::IsValidInput(LPTSTR str, bool /*suppressFill*/)
43{
44 for (LPTSTR p = str; *p; ) {
45 uint n = CharSize(p) / sizeof(tchar);
46 if (n > 1 || !ValidChars.Has(static_cast<tchar>(*p)))
47 return false;
48 p += n;
49 }
50 return true;
51}
52
53//
54/// IsValid overrides TValidator's virtuals and returns true if all characters in
55/// str are in the set of allowed characters, ValidChar; otherwise, it returns
56/// false.
57//
58bool
60{
61 for (LPCTSTR p = str; *p;) {
62 uint n = CharSize(p) / sizeof(tchar);
63 if (n > 1 || !ValidChars.Has(static_cast<tchar>(*p)))
64 return false;
65 p += n;
66 }
67 return true;
68}
69
70//
71/// Error overrides TValidator's virtual function and displays a message box
72/// indicating that the text string contains an invalid character.
73//
74void
80
81
83
84#if OWL_PERSISTENT_STREAMS
85
86//
87//
88//
89void*
90TFilterValidator::Streamer::Read(ipstream& is, uint32 /*version*/) const
91{
92 ReadBaseObject((TValidator*)GetObject(), is);
93 is >> GetObject()->ValidChars;
94 return GetObject();
95}
96
97//
98//
99//
100void
101TFilterValidator::Streamer::Write(opstream& os) const
102{
103 WriteBaseObject((TValidator*)GetObject(), os);
104 os << GetObject()->ValidChars;
105}
106
107#endif
108
109
110} // OWL namespace
111
Definition of class TAppDictionary.
Definition of class TApplication.
#define PRECONDITION(condition)
Definition checks.h:227
bool Has(T item) const
Return true if a bit is turned on.
Definition bitset.cpp:42
Derived from TBitSet, TCharSet sets and clears bytes for a group of characters.
Definition bitset.h:125
A streamable class, TFilterValidator checks an input field as the user types into it.
Definition validate.h:194
TFilterValidator(const TCharSet &validChars)
Let the compiler know that the following template instances will be defined elsewhere.
Definition filtval.cpp:28
void Error(TWindow *owner)
Error overrides TValidator's virtual function and displays a message box indicating that the text str...
Definition filtval.cpp:75
bool IsValid(LPCTSTR str)
IsValid overrides TValidator's virtuals and returns true if all characters in str are in the set of a...
Definition filtval.cpp:59
bool IsValidInput(TCHAR *str, bool suppressFill)
IsValidInput overrides TValidator's virtual function and checks each character in the string str to e...
Definition filtval.cpp:42
A streamable class, TValidator defines an abstract data validation object.
Definition validate.h:71
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition objstrm.h:391
Definition of class TFrameWindow.
void ReadBaseObject(Base *base, ipstream &in)
Definition objstrm.h:1159
#define IMPLEMENT_STREAMABLE1(cls, base1)
Definition objstrm.h:1725
void WriteBaseObject(Base *base, opstream &out)
Definition objstrm.h:1150
UINT CharSize(const TCHAR *s)
Return the number of bytes of the first character of the passed string.
Definition memory.h:56
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned long uint32
Definition number.h:34
char tchar
Definition defs.h:77
OWL_DIAGINFO
Definition animctrl.cpp:14