regexp.hpp Example File
regexp/src/regexp.hpp
#ifndef REGEXP_HPP
#define REGEXP_HPP
#include <QtCore/QObject>
#include <QtCore/QRegExp>
#include <QtCore/QVector>
class RegExp: public QObject
{
Q_OBJECT
Q_PROPERTY(QString pattern READ pattern WRITE setPattern NOTIFY patternChanged)
Q_PROPERTY(QString escapedPattern READ escapedPattern NOTIFY regexpChanged)
Q_PROPERTY(bool caseSensitive READ caseSensitive WRITE setCaseSensitive NOTIFY caseSensitiveChanged)
Q_PROPERTY(bool minimal READ minimal WRITE setMinimal NOTIFY minimalChanged)
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(int matchIndex READ matchIndex NOTIFY regexpChanged)
Q_PROPERTY(int matchLength READ matchLength NOTIFY regexpChanged)
Q_PROPERTY(bool capture0Available READ capture0Available NOTIFY regexpChanged)
Q_PROPERTY(QString capture0Text READ capture0Text NOTIFY regexpChanged)
Q_PROPERTY(bool capture1Available READ capture1Available NOTIFY regexpChanged)
Q_PROPERTY(QString capture1Text READ capture1Text NOTIFY regexpChanged)
Q_PROPERTY(bool capture2Available READ capture2Available NOTIFY regexpChanged)
Q_PROPERTY(QString capture2Text READ capture2Text NOTIFY regexpChanged)
Q_PROPERTY(bool capture3Available READ capture3Available NOTIFY regexpChanged)
Q_PROPERTY(QString capture3Text READ capture3Text NOTIFY regexpChanged)
Q_PROPERTY(bool capture4Available READ capture4Available NOTIFY regexpChanged)
Q_PROPERTY(QString capture4Text READ capture4Text NOTIFY regexpChanged)
Q_PROPERTY(bool capture5Available READ capture5Available NOTIFY regexpChanged)
Q_PROPERTY(QString capture5Text READ capture5Text NOTIFY regexpChanged)
public:
RegExp(QObject *parent = 0);
void setPattern(const QString &pattern);
QString pattern() const;
void setPatternSyntax(QRegExp::PatternSyntax syntax);
QString escapedPattern() const;
void setCaseSensitive(bool caseSensitive);
bool caseSensitive() const;
void setMinimal(bool minimal);
bool minimal() const;
void setText(const QString &text);
QString text() const;
int matchIndex() const;
int matchLength() const;
bool capture0Available() const;
QString capture0Text() const;
bool capture1Available() const;
QString capture1Text() const;
bool capture2Available() const;
QString capture2Text() const;
bool capture3Available() const;
QString capture3Text() const;
bool capture4Available() const;
QString capture4Text() const;
bool capture5Available() const;
QString capture5Text() const;
Q_SIGNALS:
void patternChanged();
void caseSensitiveChanged();
void minimalChanged();
void textChanged();
void regexpChanged();
private:
void refresh();
struct Capture
{
bool available;
QString text;
};
QString m_pattern;
QString m_escapedPattern;
QRegExp::PatternSyntax m_patternSyntax;
bool m_caseSensitive;
bool m_minimal;
QString m_text;
int m_matchIndex;
int m_matchLength;
int m_matchText;
QVector<Capture> m_captures;
};
#endif