11#include <owl/validate.rh>
51void TPXPictureValidator::Init(
bool autoFill)
119TPXPictureValidator::IsComplete(
TPicResult rslt)
128TPXPictureValidator::IsIncomplete(
TPicResult rslt)
137TPXPictureValidator::ToGroupEnd(
uint termCh,
uint& i)
146 case _T(
'['): brkLevel++;
break;
147 case _T(
']'): brkLevel--;
break;
148 case _T(
'{'): brcLevel++;
break;
149 case _T(
'}'): brcLevel--;
break;
150 case _T(
';'): i++;
break;
155 ToGroupEnd(termCh, i);
159 }
while (brkLevel || brcLevel);
166TPXPictureValidator::SkipToComma(
uint termCh,
uint& i)
169 ToGroupEnd(termCh, i);
172 if (Pic[i] ==
_T(
',')) {
183TPXPictureValidator::CalcTerm(
uint termCh,
uint i)
185 ToGroupEnd(termCh, i);
193TPXPictureValidator::Iteration(LPTSTR input,
uint termCh,
uint& i,
uint& j)
204 itr = itr * 10 + Pic[i] -
_T(
'0');
209 newTermCh = CalcTerm(termCh, i);
216 for (
uint m = 0; m < itr; m++) {
218 rslt = Process(input, newTermCh, i, j);
219 if (!IsComplete(rslt)) {
229 rslt = Process(input, newTermCh, i, j);
230 }
while (IsComplete(rslt));
244TPXPictureValidator::Group(LPTSTR input,
uint termCh,
uint& i,
uint& j)
246 uint groupTermCh = CalcTerm(termCh, i);
248 TPicResult rslt = Process(input, groupTermCh - 1, i, j);
249 if (!IsIncomplete(rslt))
261 if (IsIncomplete(rslt)) {
264 if (Pic[j] ==
_T(
'['))
265 ToGroupEnd(termCh, j);
267 else if (Pic[j] ==
_T(
'*')) {
268 if (!isdigit((
tchar)Pic[j+1])) {
270 ToGroupEnd(termCh, j);
288#if !defined(__GNUC__)
293TPXPictureValidator::Scan(LPTSTR input,
uint termCh,
uint& i,
uint& j)
299 while (i != termCh && Pic[i] !=
_T(
',')) {
301 return CheckComplete(termCh, i, rslt);
330#if defined(BI_DBCS_SUPPORT)
347#if defined(BI_DBCS_SUPPORT)
360 rslt = Iteration(input, termCh, i, j);
361 if (!IsComplete(rslt))
367 rslt = Group(input, termCh, i, j);
368 if (!IsComplete(rslt))
372 rslt = Group(input, termCh, i, j);
373 if (IsIncomplete(rslt))
379#if defined(BI_DBCS_SUPPORT)
380 if (Pic[i] ==
_T(
';'))
388#if defined(BI_AUTO_COMPLETION_DBCS_BY_SPACE)
392 memmove(input+n2, input+n, len-n+1);
397 input[j++] = Pic[i++];
401 input[j++] = Pic[i++];
409 input[j++] = Pic[i++];
415 for (
uint i1 = 0; i1 < n; i1++)
416 if (input[j+i1] != Pic[i+i1])
419 input[j++] = Pic[i++];
422 if (Pic[i] ==
_T(
';'))
444#if !defined(__GNUC__)
452TPXPictureValidator::Process(LPTSTR input,
uint termCh,
uint& i,
uint& j)
455 uint incompJ, incompI;
456 incompJ = incompI = 0;
462 rslt = Scan(input, termCh, i, j);
481 if (!SkipToComma(termCh, i)) {
500TPXPictureValidator::SyntaxCheck()
502 const auto n =
static_cast<int>(Pic.length());
504 (Pic.back() ==
_T(
';')) ||
505 (Pic.back() ==
_T(
'*') && Pic[n - 2] !=
_T(
';')))
512 auto next = [&](
int& i) { i +=
CharSize(&Pic[i]) /
sizeof(
tchar); };
513 for (
auto i = 0; i < n; next(i))
517 case _T(
'['): ++brkLevel;
break;
518 case _T(
']'): --brkLevel;
break;
519 case _T(
'{'): ++brcLevel;
break;
520 case _T(
'}'): --brcLevel;
break;
521 case _T(
';'): next(i);
break;
529 return brkLevel == 0 && brcLevel == 0;
564 if (!input || !*input)
574 TPicResult rslt = Process(input,
static_cast<uint>(Pic.length()), iPic, iInput);
583 bool reprocess =
false;
584 while (iPic < Pic.length() && !
_tcschr(
_T(
"#?&!@*{}[],"), Pic[iPic]))
586 if (Pic[iPic] ==
_T(
';'))
588#if defined(BI_DBCS_SUPPORT)
591 memmove(input + k, Pic.c_str() + iPic, n);
592 input[k + n] =
_T(
'\0');
596 input[iInput++] = Pic[iPic++];
602 input[iInput] =
_T(
'\0');
604 rslt = Process(input,
static_cast<uint>(Pic.length()), iPic, iInput);
621#if OWL_PERSISTENT_STREAMS
630 is >> GetObject()->Pic;
638TPXPictureValidator::Streamer::Write(opstream& os)
const
641 os << GetObject()->Pic;
Definition of class TAppDictionary.
Definition of class TApplication.
#define PRECONDITION(condition)
TPXPictureValidator objects compare user input with a picture of a data format to determine the valid...
int Adjust(tstring &text, int &begPos, int &endPos, int amount)
Adjusts the 'value' of the text, given a cursor position and an amount.
virtual TPicResult Picture(TCHAR *input, bool autoFill=false)
Checks the validity of the input according to the format specified by the picture string,...
TPXPictureValidator(LPCTSTR pic, bool autoFill=false)
Constructs a picture validator object by first calling the constructor inherited from TValidator and ...
bool IsValid(LPCTSTR str)
IsValid overrides TValidator's virtual function and compares the string passed in str with the format...
void Error(TWindow *owner)
Overrides TValidator's virtual function and displays a message box that indicates an error in the pic...
bool IsValidInput(TCHAR *str, bool suppressFill)
IsValidInput overrides TValidator's virtual function and checks the string passed in str against the ...
A streamable class, TValidator defines an abstract data validation object.
uint16 Options
A bitmap member used to control options for various descendants of TValidator.
TValidator()
Constructs an abstract validator object and sets Options fields to 0.
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
tstring LoadString(uint id) const
auto FormatMessageBox(const tstring &formatStr, const tstring &caption, uint flags,...) const -> int
static void Raise()
Creates an instance of TXValidator and throws it.
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition of class TFrameWindow.
void ReadBaseObject(Base *base, ipstream &in)
void WriteBaseObject(Base *base, opstream &out)
TPicResult
Validation result type.
@ voOnAppend
Option to only validate input on appending.
@ voFill
Option to fill in chars on IsValidInput checks.
UINT CharSize(const TCHAR *s)
Return the number of bytes of the first character of the passed string.
Object Windows Library (OWLNext Core).
IMPLEMENT_STREAMABLE1(TApplication, TModule)
#define CONST_CAST(targetType, object)