Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

validate.h

Go to the documentation of this file.
00001 /*
00002  * validate.h
00003  *
00004  * Turbo Vision - Version 2.0
00005  *
00006  * Copyright (c) 1994 by Borland International
00007  * All Rights Reserved.
00008  *
00009  * Modified by Sergio Sigala <sergio@sigala.it>
00010  */
00011 
00012 #if defined(Uses_TValidator) && !defined(__TValidator)
00013 #define __TValidator
00014 
00015 // TValidator Status constants
00016 
00021 static const int
00022   vsOk     =  0,
00023   vsSyntax =  1,      // Error in the syntax of either a TPXPictureValidator
00024                       // or a TDBPictureValidator
00025 
00026 // Validator option flags
00027   voFill     =  0x0001,
00028   voTransfer =  0x0002,
00029   voReserved =  0x00FC;
00030 
00031 // TVTransfer constants
00032 
00033 enum TVTransfer {vtDataSize, vtSetData, vtGetData};
00034 
00035 // Abstract TValidator object
00036 
00045 class TValidator : public TObject, public TStreamable
00046 {
00047 public:
00051     TValidator();
00058     virtual void error();
00085     virtual Boolean isValidInput(char* s, Boolean suppressFill);
00096     virtual Boolean isValid(const char* s);
00140     virtual ushort transfer(char *s, void* buffer, TVTransfer flag);
00154     Boolean validate(const char* s);
00179     ushort status;
00200     ushort options;
00201 protected:
00208     TValidator( StreamableInit );
00212     virtual void write( opstream& os );
00216     virtual void* read( ipstream& is );
00217 private:
00218     virtual const char *streamableName() const  {return name;};
00219 public:
00223     static TStreamable *build();
00227     static const char * const name;
00228 };
00229 
00230 #endif
00231 
00232 
00233 #if defined(Uses_TPXPictureValidator) && !defined(__TPXPictureValidator)
00234 #define __TPXPictureValidator
00235 
00236 // TPXPictureValidator result type
00237 
00238 enum TPicResult {prComplete, prIncomplete, prEmpty, prError, prSyntax,
00239     prAmbiguous, prIncompNoFill};
00240 
00241 // TPXPictureValidator
00242 
00254 class TPXPictureValidator : public TValidator
00255 {
00256     static const char * errorMsg;
00257 public:
00265     TPXPictureValidator(const char* aPic, Boolean autoFill);
00271     ~TPXPictureValidator();
00276     virtual void error();
00291     virtual Boolean isValidInput(char* s, Boolean suppressFill);
00298     virtual Boolean isValid(const char* s);
00379     virtual TPicResult picture(char* input, Boolean autoFill);
00380 protected:
00387     TPXPictureValidator( StreamableInit );
00391     virtual void write( opstream& os );
00395     virtual void* read( ipstream& is );
00401     char* pic;
00402 private:
00406     void consume(char ch, char* input);
00410     void toGroupEnd(int& i, int termCh);
00414     Boolean skipToComma(int termCh);
00418     int calcTerm(int);
00422     TPicResult iteration(char* input, int termCh);
00426     TPicResult group(char* input, int termCh);
00430     TPicResult checkComplete(TPicResult rslt, int termCh);
00434     TPicResult scan(char* input, int termCh);
00438     TPicResult process(char* input, int termCh);
00442     Boolean syntaxCheck();
00446     virtual const char *streamableName() const  {return name;};
00450     int index, jndex;
00451 public:
00455     static TStreamable *build();
00459     static const char * const name;
00460 };
00461 
00465 inline ipstream& operator >> ( ipstream& is, TValidator& v )
00466     { return is >> (TStreamable&)v; }
00470 inline ipstream& operator >> ( ipstream& is, TValidator*& v )
00471     { return is >> (void *&)v; }
00472 
00476 inline opstream& operator << ( opstream& os, TValidator& v )
00477     { return os << (TStreamable&)v; }
00481 inline opstream& operator << ( opstream& os, TValidator* v )
00482     { return os << (TStreamable *)v; }
00483 
00484 #endif
00485 
00486 
00487 #if defined(Uses_TFilterValidator) && !defined(__TFilterValidator)
00488 #define __TFilterValidator
00489 
00490 // TFilterValidator
00491 
00502 class TFilterValidator : public TValidator
00503 {
00504     static const char * errorMsg;
00505 public:
00511     TFilterValidator(const char* aValidChars);
00515     ~TFilterValidator();
00519     virtual void error();
00525     virtual Boolean isValidInput(char* s, Boolean suppressFill);
00531     virtual Boolean isValid(const char* s);
00532 protected:
00539     TFilterValidator( StreamableInit );
00543     virtual void write( opstream& os);
00547     virtual void* read( ipstream& is );
00553     char* validChars;
00554 private:
00558     virtual const char *streamableName() const  {return name;};
00559 public:
00563     static TStreamable *build();
00567     static const char * const name;
00568 };
00569 
00573 inline ipstream& operator >> ( ipstream& is, TFilterValidator& v )
00574     { return is >> (TStreamable&)v; }
00578 inline ipstream& operator >> ( ipstream& is, TFilterValidator*& v )
00579     { return is >> (void *&)v; }
00580 
00584 inline opstream& operator << ( opstream& os, TFilterValidator& v )
00585     { return os << (TStreamable&)v; }
00589 inline opstream& operator << ( opstream& os, TFilterValidator* v )
00590     { return os << (TStreamable *)v; }
00591 
00592 #endif
00593 
00594 
00595 #if defined(Uses_TRangeValidator) && !defined(__TRangeValidator)
00596 #define __TRangeValidator
00597 
00598 // TRangeValidator
00599 
00606 class TRangeValidator : public TFilterValidator
00607 {
00611     static const char * validUnsignedChars;
00615     static const char * validSignedChars;
00619     static const char * errorMsg;
00620 public:
00629     TRangeValidator(long aMin, long aMax);
00634     virtual void error();
00645     virtual Boolean isValid(const char* s);
00670     virtual ushort transfer(char* s, void* buffer, TVTransfer flag);
00671 protected:
00675     long min;
00679     long max;
00686     TRangeValidator( StreamableInit );
00690     virtual void write( opstream& os );
00694     virtual void* read( ipstream& is );
00695 private:
00699     virtual const char *streamableName() const  {return name;};
00700 public:
00704     static TStreamable *build();
00708     static const char * const name;
00709 };
00710 
00714 inline ipstream& operator >> ( ipstream& is, TRangeValidator& v )
00715     { return is >> (TStreamable&)v; }
00719 inline ipstream& operator >> ( ipstream& is, TRangeValidator*& v )
00720     { return is >> (void *&)v; }
00721 
00725 inline opstream& operator << ( opstream& os, TRangeValidator& v )
00726     { return os << (TStreamable&)v; }
00730 inline opstream& operator << ( opstream& os, TRangeValidator* v )
00731     { return os << (TStreamable *)v; }
00732 
00733 #endif
00734 
00735 #if defined(Uses_TLookupValidator) && !defined(__TLookupValidator)
00736 #define __TLookupValidator
00737 
00738 // TLookupValidator
00739 
00752 class TLookupValidator : public TValidator
00753 {
00754 public:
00758     TLookupValidator() {};
00764     virtual Boolean isValid(const char* s);
00773     virtual Boolean lookup(const char* s);
00777     static TStreamable *build();
00781     static const char * const name;
00782 protected:
00789     TLookupValidator( StreamableInit );
00790 private:
00794     virtual const char *streamableName() const  {return name;};
00795 };
00796 
00800 inline ipstream& operator >> ( ipstream& is, TLookupValidator& v )
00801     { return is >> (TStreamable&)v; }
00805 inline ipstream& operator >> ( ipstream& is, TLookupValidator*& v )
00806     { return is >> (void *&)v; }
00807 
00811 inline opstream& operator << ( opstream& os, TLookupValidator& v )
00812     { return os << (TStreamable&)v; }
00816 inline opstream& operator << ( opstream& os, TLookupValidator* v )
00817     { return os << (TStreamable *)v; }
00818 
00819 #endif
00820 
00821 
00822 #if defined(Uses_TStringLookupValidator) && !defined(__TStringLookupValidator)
00823 #define __TStringLookupValidator
00824 
00825 // TStringLookupValidator
00826 
00835 class TStringLookupValidator : public TLookupValidator
00836 {
00837     static const char * errorMsg;
00838 public:
00844     TStringLookupValidator(TStringCollection* aStrings);
00851     ~TStringLookupValidator();
00856     virtual void error();
00862     virtual Boolean lookup(const char* s);
00863 protected:
00870     TStringLookupValidator( StreamableInit );
00874     virtual void write( opstream& os );
00878     virtual void* read( ipstream& is );
00883     TStringCollection* strings;
00884 private:
00888     virtual const char *streamableName() const  {return name;};
00889 public:
00898     void newStringList(TStringCollection* aStrings);
00902     static TStreamable *build();
00906     static const char * const name;
00907 };
00908 
00909 
00913 inline ipstream& operator >> ( ipstream& is, TStringLookupValidator& v )
00914     { return is >> (TStreamable&)v; }
00918 inline ipstream& operator >> ( ipstream& is, TStringLookupValidator*& v )
00919     { return is >> (void *&)v; }
00920 
00924 inline opstream& operator << ( opstream& os, TStringLookupValidator& v )
00925     { return os << (TStreamable&)v; }
00929 inline opstream& operator << ( opstream& os, TStringLookupValidator* v )
00930     { return os << (TStreamable *)v; }
00931 
00932 
00933 #endif

Generated at Sat Sep 22 20:19:13 2001 for TVision by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001