Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
FilterValidator Class Referenceabstract

Abstract QValidator for filter expressions, attachable to any QLineEdit. More...

#include <filter_validator.h>

Inheritance diagram for FilterValidator:
CaptureFilterValidator DisplayFilterValidator

Classes

struct  Detail
 Diagnostic detail produced by the most recent validate() call. More...

Public Member Functions

 FilterValidator (QObject *parent=nullptr)
QValidator::State validate (QString &input, int &pos) const override=0
 Validates input and updates the stashed Detail.
virtual Detail lastDetail () const =0
 Returns the Detail produced by the most recent validate() call.
QString lastError () const
 Short error message from the last validation (Detail::errMsg).
QString lastErrorFull (const QString &filter) const
 Full, location-annotated error message for filter.
QString deprecatedToken () const
 The deprecated token from the last validation, or empty.

Static Public Member Functions

static QString createSyntaxErrorMessageFull (const QString &filter, const QString &err_msg, qsizetype loc_start, size_t loc_length)
 Builds a full, location-annotated error string.

Detailed Description

Abstract QValidator for filter expressions, attachable to any QLineEdit.

Plain QValidator is insufficient for filter editing: its State is only Invalid/Intermediate/Acceptable and it carries no error text, error location, or deprecation information. FilterValidator extends it with a Detail accessor that the host widget reads immediately after calling validate().

The validator is intended to be single-owner: each instance is permanently attached to one widget, so the "validate() then read lastDetail()" stash-and-read pattern is safe and non-reentrant.

Subclasses (DisplayFilterValidator, CaptureFilterValidator) implement validate() against their respective compilers and return matching Detail.

Member Function Documentation

◆ createSyntaxErrorMessageFull()

QString FilterValidator::createSyntaxErrorMessageFull ( const QString & filter,
const QString & err_msg,
qsizetype loc_start,
size_t loc_length )
static

Builds a full, location-annotated error string.

Parameters
filterThe expression that failed validation.
err_msgShort error message.
loc_startZero-based offset where the error begins.
loc_lengthNumber of characters the error spans.

◆ lastDetail()

virtual Detail FilterValidator::lastDetail ( ) const
pure virtual

Returns the Detail produced by the most recent validate() call.

Implemented in CaptureFilterValidator, and DisplayFilterValidator.

◆ lastErrorFull()

QString FilterValidator::lastErrorFull ( const QString & filter) const

Full, location-annotated error message for filter.

Combines the expression with a caret/underline marking the error span reported in lastDetail(). Returns an empty string when there is no error.

◆ validate()

QValidator::State FilterValidator::validate ( QString & input,
int & pos ) const
overridepure virtual

Validates input and updates the stashed Detail.

Parameters
inputThe text to validate; may be normalised in place.
posIn/out cursor position.
Returns
Invalid, Intermediate, or Acceptable.

Implemented in CaptureFilterValidator, and DisplayFilterValidator.


The documentation for this class was generated from the following files: