cocos2d-x  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CCDictElement Class Reference

CCDictElement is used for traversing CCDictionary. More...

#include <CCDictionary.h>

Public Member Functions

 ~CCDictElement ()
 The destructor of CCDictElement. More...
 
const char * getStrKey () const
 Get the string key of this element. More...
 
intptr_t getIntKey () const
 Get the integer key of this element. More...
 
CCObjectgetObject () const
 Get the object of this element. More...
 

Public Attributes

UT_hash_handle hh

Friends

class CCDictionary

Detailed Description

CCDictElement is used for traversing CCDictionary.

A CCDictElement is one element of CCDictionary, it contains two properties, key and object. Its key has two different type (integer and string).

Note
The key type is unique, all the elements in CCDictionary has the same key type(integer or string).
CCDictElement* pElement;
CCDICT_FOREACH(dict, pElement)
{
const char*key = pElement->getStrKey();
// You certainly know the type of value, so we assume that it's a CCSprite.
CCSprite* pSprite = (CCSprite*)pElement->getObject();
// ......
}

Constructor & Destructor Documentation

The destructor of CCDictElement.

Member Function Documentation

intptr_t getIntKey ( ) const
inline

Get the integer key of this element.

Note
This method assumes you know the key type in the element. If the element's key type is string, invoking this method will cause an assert.
Returns
The integer key of this element.
CCObject* getObject ( ) const
inline

Get the object of this element.

Returns
The object of this element.
const char* getStrKey ( ) const
inline

Get the string key of this element.

Note
This method assumes you know the key type in the element. If the element's key type is integer, invoking this method will cause an assert.
Returns
The string key of this element.

Friends And Related Function Documentation

friend class CCDictionary
friend

Member Data Documentation

UT_hash_handle hh

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