Qt 4.8
Public Functions | Properties | List of all members
QRegExpCharClass Class Reference

Public Functions

void addCategories (int cats)
 
void addRange (ushort from, ushort to)
 
void addSingleton (ushort ch)
 
void clear ()
 
void dump () const
 
const QVector< int > & firstOccurrence () const
 
bool in (QChar ch) const
 
bool negative () const
 
QRegExpCharClassoperator= (const QRegExpCharClass &cc)
 
 QRegExpCharClass ()
 
 QRegExpCharClass (const QRegExpCharClass &cc)
 
void setNegative (bool negative)
 

Properties

int c
 
bool n
 
QVector< int > occ1
 
QVector< QRegExpCharClassRanger
 

Detailed Description

Definition at line 1022 of file qregexp.cpp.

Constructors and Destructors

◆ QRegExpCharClass() [1/2]

QRegExpCharClass::QRegExpCharClass ( )

Definition at line 2323 of file qregexp.cpp.

2324  : c(0), n(false)
2325 {
2326 #ifndef QT_NO_REGEXP_OPTIM
2328 #endif
2329 }
QVector< T > & fill(const T &t, int size=-1)
Assigns value to all items in the vector.
Definition: qvector.h:665
const int NumBadChars
Definition: qregexp.cpp:698
QVector< int > occ1
Definition: qregexp.cpp:1051
const int NoOccurrence
Definition: qregexp.cpp:701

◆ QRegExpCharClass() [2/2]

QRegExpCharClass::QRegExpCharClass ( const QRegExpCharClass cc)
inline

Definition at line 1026 of file qregexp.cpp.

1026 { operator=(cc); }
QRegExpCharClass & operator=(const QRegExpCharClass &cc)
Definition: qregexp.cpp:2331

Functions

◆ addCategories()

void QRegExpCharClass::addCategories ( int  cats)

Definition at line 2357 of file qregexp.cpp.

Referenced by QRegExpEngine::getEscape().

2358 {
2359  c |= cats;
2360 #ifndef QT_NO_REGEXP_OPTIM
2361  occ1.fill(0, NumBadChars);
2362 #endif
2363 }
QVector< T > & fill(const T &t, int size=-1)
Assigns value to all items in the vector.
Definition: qvector.h:665
const int NumBadChars
Definition: qregexp.cpp:698
QVector< int > occ1
Definition: qregexp.cpp:1051

◆ addRange()

void QRegExpCharClass::addRange ( ushort  from,
ushort  to 
)

Definition at line 2365 of file qregexp.cpp.

Referenced by QRegExpEngine::getEscape(), and QRegExpEngine::getToken().

2366 {
2367  if (from > to)
2368  qSwap(from, to);
2369  int m = r.size();
2370  r.resize(m + 1);
2371  r[m].from = from;
2372  r[m].len = to - from + 1;
2373 
2374 #ifndef QT_NO_REGEXP_OPTIM
2375  int i;
2376 
2377  if (to - from < NumBadChars) {
2378  if (from % NumBadChars <= to % NumBadChars) {
2379  for (i = from % NumBadChars; i <= to % NumBadChars; i++)
2380  occ1[i] = 0;
2381  } else {
2382  for (i = 0; i <= to % NumBadChars; i++)
2383  occ1[i] = 0;
2384  for (i = from % NumBadChars; i < NumBadChars; i++)
2385  occ1[i] = 0;
2386  }
2387  } else {
2388  occ1.fill(0, NumBadChars);
2389  }
2390 #endif
2391 }
QVector< T > & fill(const T &t, int size=-1)
Assigns value to all items in the vector.
Definition: qvector.h:665
const int NumBadChars
Definition: qregexp.cpp:698
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
QVector< int > occ1
Definition: qregexp.cpp:1051
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181
QVector< QRegExpCharClassRange > r
Definition: qregexp.cpp:1048
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ addSingleton()

void QRegExpCharClass::addSingleton ( ushort  ch)
inline

Definition at line 1035 of file qregexp.cpp.

Referenced by QRegExpEngine::getEscape(), and QRegExpEngine::getToken().

1035 { addRange(ch, ch); }
void addRange(ushort from, ushort to)
Definition: qregexp.cpp:2365

◆ clear()

void QRegExpCharClass::clear ( )

Definition at line 2342 of file qregexp.cpp.

Referenced by QRegExpEngine::getToken().

2343 {
2344  c = 0;
2345  r.resize(0);
2346  n = false;
2347 }
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
QVector< QRegExpCharClassRange > r
Definition: qregexp.cpp:1048

◆ dump()

void QRegExpCharClass::dump ( ) const

Definition at line 2415 of file qregexp.cpp.

2416 {
2417  int i;
2418  qDebug(" %stive character class", n ? "nega" : "posi");
2419 #ifndef QT_NO_REGEXP_CCLASS
2420  if (c != 0)
2421  qDebug(" categories 0x%.8x", c);
2422 #endif
2423  for (i = 0; i < r.size(); i++)
2424  qDebug(" 0x%.4x through 0x%.4x", r[i].from, r[i].from + r[i].len - 1);
2425 }
Q_CORE_EXPORT void qDebug(const char *,...)
QVector< QRegExpCharClassRange > r
Definition: qregexp.cpp:1048
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ firstOccurrence()

const QVector<int>& QRegExpCharClass::firstOccurrence ( ) const
inline

Definition at line 1039 of file qregexp.cpp.

Referenced by QRegExpEngine::Box::set().

1039 { return occ1; }
QVector< int > occ1
Definition: qregexp.cpp:1051

◆ in()

bool QRegExpCharClass::in ( QChar  ch) const

Definition at line 2393 of file qregexp.cpp.

Referenced by QRegExpMatchState::matchHere().

2394 {
2395 #ifndef QT_NO_REGEXP_OPTIM
2396  if (occ1.at(BadChar(ch)) == NoOccurrence)
2397  return n;
2398 #endif
2399 
2400  if (c != 0 && (c & (1 << (int)ch.category())) != 0)
2401  return !n;
2402 
2403  const int uc = ch.unicode();
2404  int size = r.size();
2405 
2406  for (int i = 0; i < size; ++i) {
2407  const QRegExpCharClassRange &range = r.at(i);
2408  if (uint(uc - range.from) < uint(r.at(i).len))
2409  return !n;
2410  }
2411  return n;
2412 }
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
Category category() const
Returns the character&#39;s category.
Definition: qchar.cpp:853
QVector< int > occ1
Definition: qregexp.cpp:1051
unsigned int uint
Definition: qglobal.h:996
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QVector< QRegExpCharClassRange > r
Definition: qregexp.cpp:1048
#define BadChar(ch)
Definition: qregexp.cpp:699
const int NoOccurrence
Definition: qregexp.cpp:701
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ negative()

bool QRegExpCharClass::negative ( ) const
inline

Definition at line 1031 of file qregexp.cpp.

Referenced by QRegExpEngine::getEscape(), QRegExpMatchState::matchHere(), and setNegative().

1031 { return n; }

◆ operator=()

QRegExpCharClass & QRegExpCharClass::operator= ( const QRegExpCharClass cc)

Definition at line 2331 of file qregexp.cpp.

2332 {
2333  c = cc.c;
2334  r = cc.r;
2335  n = cc.n;
2336 #ifndef QT_NO_REGEXP_OPTIM
2337  occ1 = cc.occ1;
2338 #endif
2339  return *this;
2340 }
QVector< int > occ1
Definition: qregexp.cpp:1051
QVector< QRegExpCharClassRange > r
Definition: qregexp.cpp:1048

◆ setNegative()

void QRegExpCharClass::setNegative ( bool  negative)

Definition at line 2349 of file qregexp.cpp.

Referenced by QRegExpEngine::getEscape(), and QRegExpEngine::getToken().

2350 {
2351  n = negative;
2352 #ifndef QT_NO_REGEXP_OPTIM
2353  occ1.fill(0, NumBadChars);
2354 #endif
2355 }
QVector< T > & fill(const T &t, int size=-1)
Assigns value to all items in the vector.
Definition: qvector.h:665
const int NumBadChars
Definition: qregexp.cpp:698
bool negative() const
Definition: qregexp.cpp:1031
QVector< int > occ1
Definition: qregexp.cpp:1051

Properties

◆ c

int QRegExpCharClass::c
private

Definition at line 1047 of file qregexp.cpp.

Referenced by addCategories(), clear(), dump(), in(), and operator=().

◆ n

bool QRegExpCharClass::n
private

Definition at line 1049 of file qregexp.cpp.

Referenced by clear(), dump(), in(), operator=(), and setNegative().

◆ occ1

QVector<int> QRegExpCharClass::occ1
private

Definition at line 1051 of file qregexp.cpp.

Referenced by addCategories(), addRange(), in(), operator=(), QRegExpCharClass(), and setNegative().

◆ r

QVector<QRegExpCharClassRange> QRegExpCharClass::r
private

Definition at line 1048 of file qregexp.cpp.

Referenced by addRange(), clear(), dump(), in(), and operator=().


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