Qt 4.8
Classes | Public Functions | Protected Functions | Private Types | Properties | List of all members
QDeclarativeIntegerCache Class Reference

#include <qdeclarativeintegercache_p.h>

Inheritance diagram for QDeclarativeIntegerCache:
QDeclarativeRefCount QDeclarativeCleanup

Classes

struct  Data
 

Public Functions

void add (const QString &, int)
 
int count () const
 
QString findId (int value) const
 
 QDeclarativeIntegerCache (QDeclarativeEngine *)
 
int value (const QString &)
 
int value (const QScriptDeclarativeClass::Identifier &id) const
 
virtual ~QDeclarativeIntegerCache ()
 
- Public Functions inherited from QDeclarativeRefCount
void addref ()
 
 QDeclarativeRefCount ()
 
void release ()
 
virtual ~QDeclarativeRefCount ()
 
- Public Functions inherited from QDeclarativeCleanup
 QDeclarativeCleanup (QDeclarativeEngine *)
 
virtual ~QDeclarativeCleanup ()
 

Protected Functions

virtual void clear ()
 

Private Types

typedef QHash< QScriptDeclarativeClass::Identifier, Data * > IdentifierCache
 
typedef QHash< QString, Data * > StringCache
 

Properties

QDeclarativeEngineengine
 
IdentifierCache identifierCache
 
StringCache stringCache
 

Detailed Description

Definition at line 67 of file qdeclarativeintegercache_p.h.

Typedefs

◆ IdentifierCache

Definition at line 91 of file qdeclarativeintegercache_p.h.

◆ StringCache

Definition at line 90 of file qdeclarativeintegercache_p.h.

Constructors and Destructors

◆ QDeclarativeIntegerCache()

QDeclarativeIntegerCache::QDeclarativeIntegerCache ( QDeclarativeEngine e)

Definition at line 49 of file qdeclarativeintegercache.cpp.

51 {
52 }
QDeclarativeCleanup(QDeclarativeEngine *)

◆ ~QDeclarativeIntegerCache()

QDeclarativeIntegerCache::~QDeclarativeIntegerCache ( )
virtual

Definition at line 54 of file qdeclarativeintegercache.cpp.

55 {
56  clear();
57 }

Functions

◆ add()

void QDeclarativeIntegerCache::add ( const QString id,
int  value 
)

Definition at line 77 of file qdeclarativeintegercache.cpp.

Referenced by QDeclarativeCompiler::genContextCache(), and QDeclarativeContext::setContextProperty().

78 {
80 
82 
83  // ### use contextClass
84  Data *d = new Data(enginePriv->objectClass->createPersistentIdentifier(id), value);
85 
86  stringCache.insert(id, d);
87  identifierCache.insert(d->identifier, d);
88 }
double d
Definition: qnumeric_p.h:62
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753

◆ clear()

void QDeclarativeIntegerCache::clear ( )
protectedvirtual

Implements QDeclarativeCleanup.

Definition at line 59 of file qdeclarativeintegercache.cpp.

Referenced by ~QDeclarativeIntegerCache().

60 {
63  identifierCache.clear();
64  engine = 0;
65 }
void clear()
Removes all items from the hash.
Definition: qhash.h:574
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

◆ count()

int QDeclarativeIntegerCache::count ( ) const
inline

Definition at line 104 of file qdeclarativeintegercache_p.h.

Referenced by QDeclarativeContextData::setIdPropertyData().

105 {
106  return stringCache.count();
107 }
int count(const Key &key) const
Returns the number of items associated with the key.
Definition: qhash.h:719

◆ findId()

QString QDeclarativeIntegerCache::findId ( int  value) const

Definition at line 67 of file qdeclarativeintegercache.cpp.

Referenced by QDeclarativeContextData::findObjectId().

68 {
70  iter != stringCache.end(); ++iter) {
71  if (iter.value() && iter.value()->value == value)
72  return iter.key();
73  }
74  return QString();
75 }
const_iterator ConstIterator
Qt-style synonym for QHash::const_iterator.
Definition: qhash.h:474
The QString class provides a Unicode character string.
Definition: qstring.h:83
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464

◆ value() [1/2]

int QDeclarativeIntegerCache::value ( const QString id)

Definition at line 90 of file qdeclarativeintegercache.cpp.

Referenced by add(), QDeclarativeContext::contextProperty(), QDeclarativeCompiledBindingsPrivate::findgeneric(), findId(), QDeclarativeContextScriptClass::queryProperty(), and QDeclarativeContext::setContextProperty().

91 {
92  Data *d = stringCache.value(id);
93  return d?d->value:-1;
94 }
double d
Definition: qnumeric_p.h:62
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606

◆ value() [2/2]

int QDeclarativeIntegerCache::value ( const QScriptDeclarativeClass::Identifier id) const
inline

Definition at line 98 of file qdeclarativeintegercache_p.h.

99 {
100  Data *d = identifierCache.value(id);
101  return d?d->value:-1;
102 }
double d
Definition: qnumeric_p.h:62

Properties

◆ engine

QDeclarativeEngine* QDeclarativeIntegerCache::engine
private

Definition at line 95 of file qdeclarativeintegercache_p.h.

Referenced by add(), and clear().

◆ identifierCache

IdentifierCache QDeclarativeIntegerCache::identifierCache
private

Definition at line 94 of file qdeclarativeintegercache_p.h.

Referenced by add(), clear(), and value().

◆ stringCache

StringCache QDeclarativeIntegerCache::stringCache
private

Definition at line 93 of file qdeclarativeintegercache_p.h.

Referenced by add(), clear(), count(), findId(), and value().


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