• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeui
 

tdeui

  • tdeui
kstringvalidator.cpp
1/*
2 kstringvalidator.cpp
3
4 Copyright (c) 2001 Marc Mutz <mutz@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; version 2.0
9 of the License.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public
17 License along with this library; if not, write to the Free
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA
20*/
21
22#include "kstringvalidator.h"
23#include "kdebug.h"
24
25//
26// KStringListValidator
27//
28
29TQValidator::State KStringListValidator::validate( TQString & input, int& ) const {
30 if ( input.isEmpty() ) return Intermediate;
31
32 if ( isRejecting() ) // anything not in mStringList is acceptable:
33 if ( mStringList.find( input ) == mStringList.end() )
34 return Acceptable;
35 else
36 return Intermediate;
37 else // only what is in mStringList is acceptable:
38 if ( mStringList.find( input ) != mStringList.end() )
39 return Acceptable;
40 else
41 for ( TQStringList::ConstIterator it = mStringList.begin() ;
42 it != mStringList.end() ; ++it )
43 if ( (*it).startsWith( input ) || input.startsWith( *it ) )
44 return Intermediate;
45
46 return Invalid;
47}
48
49void KStringListValidator::fixup( TQString & /* input */ ) const {
50 if ( !isFixupEnabled() ) return;
51 // warn (but only once!) about non-implemented fixup():
52 static bool warn = true;
53 if ( warn ) {
54 kdDebug() << "KStringListValidator::fixup() isn't yet implemented!"
55 << endl;
56 warn = false;
57 }
58}
59
60//
61// KMimeTypeValidator
62//
63
64#define ALLOWED_CHARS "!#-'*+.0-9^-~+-"
65
66TQValidator::State KMimeTypeValidator::validate( TQString & input, int& ) const
67{
68 if ( input.isEmpty() )
69 return Intermediate;
70
71 TQRegExp acceptable( "[" ALLOWED_CHARS "]+/[" ALLOWED_CHARS "]+",
72 false /*case-insens.*/);
73 if ( acceptable.exactMatch( input ) )
74 return Acceptable;
75
76 TQRegExp intermediate( "[" ALLOWED_CHARS "]*/?[" ALLOWED_CHARS "]*",
77 false /*case-insensitive*/);
78 if ( intermediate.exactMatch( input ) )
79 return Intermediate;
80
81 return Invalid;
82}
83
84void KMimeTypeValidator::fixup( TQString & input ) const
85{
86 TQRegExp invalidChars("[^/" ALLOWED_CHARS "]+");
87 input.replace( invalidChars, TQString());
88}
89
90#include "kstringvalidator.moc"
KMimeTypeValidator::validate
virtual State validate(TQString &input, int &pos) const
Checks for well-formed mimetype.
Definition: kstringvalidator.cpp:66
KMimeTypeValidator::fixup
virtual void fixup(TQString &input) const
Removes all characters that are forbidden in mimetypes.
Definition: kstringvalidator.cpp:84
endl
kndbgstream & endl(kndbgstream &s)
kdDebug
kdbgstream kdDebug(int area=0)

tdeui

Skip menu "tdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeui

Skip menu "tdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.9.4
This website is maintained by Timothy Pearson.