cocos2d-x  2.2.3-gd2.113-rev1ec524e
Loading...
Searching...
No Matches
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();
// ......
}
CCDictElement is used for traversing CCDictionary.
Definition: CCDictionary.h:64
CCObject * getObject() const
Get the object of this element.
Definition: CCDictionary.h:121
const char * getStrKey() const
Get the string key of this element.
Definition: CCDictionary.h:97
CCSprite is a 2d image ( http://en.wikipedia.org/wiki/Sprite_(computer_graphics) )
Definition: CCSprite.h:86
#define CCDICT_FOREACH(__dict__, __el__)
The macro for traversing dictionary.
Definition: CCDictionary.h:141
NA NA

Constructor & Destructor Documentation

◆ ~CCDictElement()

The destructor of CCDictElement.

Member Function Documentation

◆ getIntKey()

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.

◆ getObject()

CCObject * getObject ( ) const
inline

Get the object of this element.

Returns
The object of this element.

◆ getStrKey()

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

◆ CCDictionary

friend class CCDictionary
friend

Member Data Documentation

◆ hh

UT_hash_handle hh

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