22 #include "kstringvalidator.h"
29 TQValidator::State KStringListValidator::validate( TQString & input,
int& )
const {
30 if ( input.isEmpty() )
return Intermediate;
33 if ( mStringList.find( input ) == mStringList.end() )
38 if ( mStringList.find( input ) != mStringList.end() )
41 for ( TQStringList::ConstIterator it = mStringList.begin() ;
42 it != mStringList.end() ; ++it )
43 if ( (*it).startsWith( input ) || input.startsWith( *it ) )
49 void KStringListValidator::fixup( TQString & )
const {
50 if ( !isFixupEnabled() )
return;
52 static bool warn =
true;
54 kdDebug() <<
"KStringListValidator::fixup() isn't yet implemented!"
64 #define ALLOWED_CHARS "!#-'*+.0-9^-~+-"
68 if ( input.isEmpty() )
71 TQRegExp acceptable(
"[" ALLOWED_CHARS
"]+/[" ALLOWED_CHARS
"]+",
73 if ( acceptable.exactMatch( input ) )
76 TQRegExp intermediate(
"[" ALLOWED_CHARS
"]*/?[" ALLOWED_CHARS
"]*",
78 if ( intermediate.exactMatch( input ) )
86 TQRegExp invalidChars(
"[^/" ALLOWED_CHARS
"]+");
87 input.replace( invalidChars, TQString());
90 #include "kstringvalidator.moc"
virtual State validate(TQString &input, int &pos) const
Checks for well-formed mimetype.
virtual void fixup(TQString &input) const
Removes all characters that are forbidden in mimetypes.
kndbgstream & endl(kndbgstream &s)
kdbgstream kdDebug(int area=0)