00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "stdafx.h"
00016
00017 #include <cfl/ControlIntegerEdit.h>
00018
00019 IMPLEMENT_DYNAMIC( CIntegerEdit, CFilterEdit )
00020
00021
00022
00023
00024
00025 bool CIntegerEdit::Check( const CString &csText )
00026 {
00027 char *ePtr;
00028 (void) _tcstol( csText, &ePtr, m_bUseBase ? 0 : 10 );
00029 return _TCHAR('\0') == *ePtr;
00030 }
00031
00032
00033
00034
00035
00036 bool CIntegerEdit::Match( const CString &csText )
00037 {
00038 int base = 10;
00039
00040 const TCHAR* cPtr = csText;
00041
00042
00043
00044 if ( _TCHAR('+') == *cPtr || ( m_bSigned && _TCHAR('-') == *cPtr ) )
00045 {
00046 ++cPtr;
00047 }
00048
00049
00050
00051 if ( m_bUseBase && _TCHAR('0') == *cPtr )
00052 {
00053 ++cPtr;
00054 base = 8;
00055 }
00056
00057
00058
00059 if ( 8 == base && ( _TCHAR('x') == *cPtr || _TCHAR('X') == *cPtr ) )
00060 {
00061 ++cPtr;
00062 base = 16;
00063 }
00064
00065
00066
00067 if ( 8 == base )
00068 {
00069 while ( *cPtr && _TCHAR('0') <= *cPtr && *cPtr <= _TCHAR('7') )
00070 ++cPtr;
00071 }
00072 else if ( 10 == base )
00073 {
00074 while ( *cPtr && _istdigit( *cPtr ) )
00075 ++cPtr;
00076 }
00077 else if ( 16 == base )
00078 {
00079 while ( *cPtr && _istxdigit( *cPtr ) )
00080 ++cPtr;
00081 }
00082
00083
00084 return cPtr == (const TCHAR*) csText + csText.GetLength();
00085 }
00086
00087
00088
00089