/usr/include/Wt/WRegExpValidator is in libwt-dev 3.1.10-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef WREGEXPVALIDATOR_H_
#define WREGEXPVALIDATOR_H_
#include <limits>
#include <Wt/WValidator>
namespace Wt {
class WRegExp;
/*! \class WRegExpValidator Wt/WRegExpValidator Wt/WRegExpValidator
* \brief A validator that checks user input against a regular expression.
*
* This validator checks whether user input is matched by the given
* (perl-like) regular expression.
*
* The following perl features are not supported (since client-side validation
* cannot handle them):
* <ul>
* <li>No Lookbehind support, i.e. the constructs (?<=text) and (?<!text).
* </li>
* <li>No atomic grouping, i.e. the construct (?>group).</li>
* <li>No conditional expressions, i.e. the consturct (?ifthen|else).</li>
* </ul>
*
* Usage example:
* \if cpp
* \code
* Wt::WLineEdit *lineEdit = new Wt::WLineEdit(this);
* // an email address validator
* Wt::WRegExpValidator *validator = new Wt::WRegExpValidator("[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}");
* lineEdit->setValidator(validator);
* lineEdit->setText("koen@emweb.be");
* \endcode
* \elseif java
* \code
* WLineEdit lineEdit = new WLineEdit(this);
* // an email address validator
* WRegExpValidator validator = new WRegExpValidator("[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}");
* lineEdit.setValidator(validator);
* lineEdit.setText("pieter@emweb.be");
* \endcode
* \endif
*
* \note This validator does not fully support unicode: it matches on the
* UTF8-encoded representation of the string.
*
* <h3>i18n</h3>
*
* The strings used in this class can be translated by overriding
* the default values for the following localization keys:
* - Wt.WRegExpValidator.Invalid: Invalid input
*/
class WT_API WRegExpValidator : public WValidator
{
public:
/*! \brief Sets a new regular expression validator.
*/
WRegExpValidator(WObject *parent = 0);
/*! \brief Sets a new regular expression validator that accepts input
* that matches the given regular expression.
*
* This constructs a validator that matches the perl regular
* expression \p expr.
*/
WRegExpValidator(const WT_USTRING& pattern, WObject *parent = 0);
/*! \brief Destructor.
*/
~WRegExpValidator();
/*! \brief Sets the regular expression for valid input.
*
* Sets the perl regular expression \p expr.
*/
void setRegExp(const WT_USTRING& pattern);
/*! \brief Returns the regular expression for valid input.
*
* Returns the perl regular expression.
*/
WT_USTRING regExp() const;
/*! \brief Sets regular expression matching flags.
*/
void setFlags(WFlags<RegExpFlag> flags);
/*! \brief Returns regular expression matching flags.
*/
WFlags<RegExpFlag> flags() const;
/*! \brief Validates the given input.
*
* The input is considered valid only when it is blank for a non-mandatory
* field, or matches the regular expression.
*/
virtual State validate(WT_USTRING& input) const;
virtual void createExtConfig(std::ostream& config) const;
/*! \brief Sets the text to be shown if no match can be found.
*
* Sets the text to be shown if no match can be found.
*/
void setNoMatchText(const WString& text);
/*! \brief Sets the message to display when the input does not match.
*
* The default value is "Invalid input".
*/
void setInvalidNoMatchText(const WString& text);
/*! \brief Returns the message displayed when the input does not match.
*
* \sa setInvalidNoMatchText(const WString&)
*/
WString invalidNoMatchText() const;
virtual std::string javaScriptValidate() const;
private:
WRegExp *regexp_;
WString noMatchText_;
static void loadJavaScript(WApplication *app);
};
}
#endif // WREGEXPVALIDATOR_H_
|