aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/guiSQLiteStudio/common/ipvalidator.h
blob: 1c9ca4d6ba6e3c7ffa1aef1407b58c48e44b2112 (plain) (blame)
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
#ifndef IPVALIDATOR_H
#define IPVALIDATOR_H

#include <QValidator>

class IpValidator : public QValidator
{
    public:
        IpValidator(QObject* parent = 0);
        ~IpValidator();

        State validate(QString& input, int&) const;

        bool getAcceptWhiteSpaces() const;
        void setAcceptWhiteSpaces(bool value);

        bool getAcceptEmptyParts() const;
        void setAcceptEmptyParts(bool value);

        QChar getWhitespaceCharacter() const;
        void setWhitespaceCharacter(const QChar& value);

        static bool check(const QString& input, bool acceptWhiteSpaces = false);

    private:
        static QString getPattern(bool acceptWhiteSpaces, bool requireFull, QChar whitespaceCharacter);

        bool acceptWhiteSpaces = false;
        bool acceptEmptyParts = false;
        QChar whitespaceCharacter = ' ';

        static QString reStr;
};

#endif // IPVALIDATOR_H