/usr/include/Wt/WIntValidator is in libwt-dev 3.3.3+dfsg-4.1.
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 138 139 140 141 142 143 144 145 146 147 148 149 | // 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 WINTVALIDATOR_H_
#define WINTVALIDATOR_H_
#include <limits>
#include <Wt/WValidator>
namespace Wt {
/*! \class WIntValidator Wt/WIntValidator Wt/WIntValidator
* \brief A validator that validates integer user input.
*
* This validator checks whether user input is an integer number in a
* pre-defined range.
*
* \if cpp
* Usage example:
* \code
* Wt::WLineEdit *lineEdit = new Wt::WLineEdit(this);
* Wt::WIntValidator *validator = new Wt::WIntValidator(0, 100);
* lineEdit->setValidator(validator);
* lineEdit->setText("50");
* \endcode
* \endif
*
* <h3>i18n</h3>
*
* The strings used in this class can be translated by overriding
* the default values for the following localization keys:
* - Wt.WIntValidator.NotAnInteger: Must be an integer number
* - Wt.WIntValidator.TooSmall: The number must be larger than {1}
* - Wt.WIntValidator.BadRange: The number must be in the range {1} to {2}
* - Wt.WIntValidator.TooLarge: The number must be smaller than {1}
*/
class WT_API WIntValidator : public WValidator
{
public:
/*! \brief Creates a new integer validator that accepts any integer.
*
* The validator will accept numbers using the current locale's format.
*
* \sa WLocale::currentLocale()
*/
WIntValidator(WObject *parent = 0);
/*! \brief Creates a new integer validator that accepts integer input
* within the given range.
*
* \sa WLocale::currentLocale()
*/
WIntValidator(int minimum, int maximum, WObject *parent = 0);
/*! \brief Returns the bottom of the valid integer range.
*/
int bottom() const { return bottom_; }
/*! \brief Sets the bottom of the valid integer range.
*
* The default value is the minimum integer value.
*/
void setBottom(int bottom);
/*! \brief Returns the top of the valid integer range.
*/
int top() const { return top_; }
/*! \brief Sets the top of the valid integer range.
*
* The default value is the maximum integer value.
*/
void setTop(int top);
/*! \brief Sets the range of valid integers.
*/
virtual void setRange(int bottom, int top);
/*! \brief Validates the given input.
*
* The input is considered valid only when it is blank for a non-mandatory
* field, or represents an integer within the valid range.
*/
virtual Result validate(const WT_USTRING& input) const;
virtual void createExtConfig(std::ostream& config) const;
/*! \brief Sets the message to display when the input is not a number.
*
* The default value is "Must be an integer number."
*/
void setInvalidNotANumberText(const WString& text);
/*! \brief Returns the message displayed when the input is not a number.
*
* \sa setInvalidNotANumberText(const WString&)
*/
WString invalidNotANumberText() const;
/*! \brief Sets the message to display when the number is too small
*
* Depending on whether bottom() and top() are real bounds, the
* default message is "The number must be between {1} and {2}" or
* "The number must be larger than {1}".
*/
void setInvalidTooSmallText(const WString& text);
/*! \brief Returns the message displayed when the number is too small.
*
* \sa setInvalidTooSmallText(const WString&)
*/
WString invalidTooSmallText() const;
/*! \brief Sets the message to display when the number is too large
*
* Depending on whether bottom() and top() are real bounds, the
* default message is "The number must be between {1} and {2}" or
* "The number must be smaller than {2}".
*/
void setInvalidTooLargeText(const WString& text);
/*! \brief Returns the message displayed when the number is too large.
*
* \sa setInvalidTooLargeText(const WString&)
*/
WString invalidTooLargeText() const;
virtual std::string javaScriptValidate() const;
virtual std::string inputFilter() const;
private:
int bottom_;
int top_;
WString tooSmallText_;
WString tooLargeText_;
WString nanText_;
static void loadJavaScript(WApplication *app);
};
}
#endif // WINTVALIDATOR_H_
|