2013-01-15 17:09:25 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2012 - 2013 cocos2d-x.org
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
#include "CCDictionary.h"
|
|
|
|
#include "CCString.h"
|
|
|
|
#include "CCInteger.h"
|
2013-02-01 18:48:44 +08:00
|
|
|
#include "platform/CCFileUtils.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2013-01-15 17:09:25 +08:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
// CCDictElement
|
|
|
|
|
|
|
|
CCDictElement::CCDictElement(const char* pszKey, CCObject* pObject)
|
|
|
|
{
|
|
|
|
CCAssert(pszKey && strlen(pszKey) > 0, "Invalid key value.");
|
|
|
|
m_iKey = 0;
|
|
|
|
const char* pStart = pszKey;
|
|
|
|
|
|
|
|
int len = strlen(pszKey);
|
|
|
|
if (len > MAX_KEY_LEN )
|
|
|
|
{
|
|
|
|
char* pEnd = (char*)&pszKey[len-1];
|
|
|
|
pStart = pEnd - (MAX_KEY_LEN-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(m_szKey, pStart);
|
|
|
|
|
|
|
|
m_pObject = pObject;
|
|
|
|
memset(&hh, 0, sizeof(hh));
|
|
|
|
}
|
|
|
|
|
|
|
|
CCDictElement::CCDictElement(intptr_t iKey, CCObject* pObject)
|
|
|
|
{
|
|
|
|
m_szKey[0] = '\0';
|
|
|
|
m_iKey = iKey;
|
|
|
|
m_pObject = pObject;
|
|
|
|
memset(&hh, 0, sizeof(hh));
|
|
|
|
}
|
|
|
|
|
|
|
|
CCDictElement::~CCDictElement()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
// CCDictionary
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CCDictionary::CCDictionary()
|
|
|
|
: m_pElements(NULL)
|
|
|
|
, m_eDictType(kCCDictUnknown)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CCDictionary::~CCDictionary()
|
|
|
|
{
|
|
|
|
removeAllObjects();
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int CCDictionary::count()
|
|
|
|
{
|
|
|
|
return HASH_COUNT(m_pElements);
|
|
|
|
}
|
|
|
|
|
|
|
|
CCArray* CCDictionary::allKeys()
|
|
|
|
{
|
|
|
|
int iKeyCount = this->count();
|
|
|
|
if (iKeyCount <= 0) return NULL;
|
2012-06-14 16:05:58 +08:00
|
|
|
|
2012-07-23 22:49:11 +08:00
|
|
|
CCArray* pArray = CCArray::createWithCapacity(iKeyCount);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
CCDictElement *pElement, *tmp;
|
|
|
|
if (m_eDictType == kCCDictStr)
|
|
|
|
{
|
|
|
|
HASH_ITER(hh, m_pElements, pElement, tmp)
|
|
|
|
{
|
|
|
|
CCString* pOneKey = new CCString(pElement->m_szKey);
|
|
|
|
pArray->addObject(pOneKey);
|
2013-01-15 17:09:25 +08:00
|
|
|
CC_SAFE_RELEASE(pOneKey);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (m_eDictType == kCCDictInt)
|
|
|
|
{
|
|
|
|
HASH_ITER(hh, m_pElements, pElement, tmp)
|
|
|
|
{
|
|
|
|
CCInteger* pOneKey = new CCInteger(pElement->m_iKey);
|
|
|
|
pArray->addObject(pOneKey);
|
2013-01-15 17:09:25 +08:00
|
|
|
CC_SAFE_RELEASE(pOneKey);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCArray* CCDictionary::allKeysForObject(CCObject* object)
|
|
|
|
{
|
|
|
|
int iKeyCount = this->count();
|
|
|
|
if (iKeyCount <= 0) return NULL;
|
2012-06-14 16:05:58 +08:00
|
|
|
CCArray* pArray = CCArray::create();
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
CCDictElement *pElement, *tmp;
|
|
|
|
|
|
|
|
if (m_eDictType == kCCDictStr)
|
|
|
|
{
|
|
|
|
HASH_ITER(hh, m_pElements, pElement, tmp)
|
|
|
|
{
|
|
|
|
if (object == pElement->m_pObject)
|
|
|
|
{
|
|
|
|
CCString* pOneKey = new CCString(pElement->m_szKey);
|
|
|
|
pArray->addObject(pOneKey);
|
2013-01-15 17:09:25 +08:00
|
|
|
CC_SAFE_RELEASE(pOneKey);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (m_eDictType == kCCDictInt)
|
|
|
|
{
|
|
|
|
HASH_ITER(hh, m_pElements, pElement, tmp)
|
|
|
|
{
|
|
|
|
if (object == pElement->m_pObject)
|
|
|
|
{
|
|
|
|
CCInteger* pOneKey = new CCInteger(pElement->m_iKey);
|
|
|
|
pArray->addObject(pOneKey);
|
2013-01-15 17:09:25 +08:00
|
|
|
CC_SAFE_RELEASE(pOneKey);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pArray;
|
|
|
|
}
|
|
|
|
|
2012-04-26 11:39:49 +08:00
|
|
|
CCObject* CCDictionary::objectForKey(const std::string& key)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-10-08 14:55:46 +08:00
|
|
|
// if dictionary wasn't initialized, return NULL directly.
|
|
|
|
if (m_eDictType == kCCDictUnknown) return NULL;
|
|
|
|
// CCDictionary only supports one kind of key, string or integer.
|
|
|
|
// This method uses string as key, therefore we should make sure that the key type of this CCDictionary is string.
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAssert(m_eDictType == kCCDictStr, "this dictionary does not use string as key.");
|
|
|
|
|
|
|
|
CCObject* pRetObject = NULL;
|
|
|
|
CCDictElement *pElement = NULL;
|
2012-04-26 11:39:49 +08:00
|
|
|
HASH_FIND_STR(m_pElements, key.c_str(), pElement);
|
2012-04-19 14:35:52 +08:00
|
|
|
if (pElement != NULL)
|
|
|
|
{
|
|
|
|
pRetObject = pElement->m_pObject;
|
|
|
|
}
|
|
|
|
return pRetObject;
|
|
|
|
}
|
|
|
|
|
2013-04-14 16:00:50 +08:00
|
|
|
CCObject* CCDictionary::objectForKey(intptr_t key)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-10-08 14:55:46 +08:00
|
|
|
// if dictionary wasn't initialized, return NULL directly.
|
|
|
|
if (m_eDictType == kCCDictUnknown) return NULL;
|
|
|
|
// CCDictionary only supports one kind of key, string or integer.
|
2012-10-08 14:58:24 +08:00
|
|
|
// This method uses integer as key, therefore we should make sure that the key type of this CCDictionary is integer.
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAssert(m_eDictType == kCCDictInt, "this dictionary does not use integer as key.");
|
|
|
|
|
|
|
|
CCObject* pRetObject = NULL;
|
|
|
|
CCDictElement *pElement = NULL;
|
2013-04-14 16:00:50 +08:00
|
|
|
HASH_FIND_PTR(m_pElements, &key, pElement);
|
2012-04-19 14:35:52 +08:00
|
|
|
if (pElement != NULL)
|
|
|
|
{
|
|
|
|
pRetObject = pElement->m_pObject;
|
|
|
|
}
|
|
|
|
return pRetObject;
|
|
|
|
}
|
|
|
|
|
2012-04-26 11:39:49 +08:00
|
|
|
const CCString* CCDictionary::valueForKey(const std::string& key)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-01-15 17:09:25 +08:00
|
|
|
CCString* pStr = dynamic_cast<CCString*>(objectForKey(key));
|
2012-04-19 14:35:52 +08:00
|
|
|
if (pStr == NULL)
|
|
|
|
{
|
2012-06-14 16:05:58 +08:00
|
|
|
pStr = CCString::create("");
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
return pStr;
|
|
|
|
}
|
|
|
|
|
2013-04-14 16:00:50 +08:00
|
|
|
const CCString* CCDictionary::valueForKey(intptr_t key)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-01-15 17:09:25 +08:00
|
|
|
CCString* pStr = dynamic_cast<CCString*>(objectForKey(key));
|
2012-04-19 14:35:52 +08:00
|
|
|
if (pStr == NULL)
|
|
|
|
{
|
2012-06-14 16:05:58 +08:00
|
|
|
pStr = CCString::create("");
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
return pStr;
|
|
|
|
}
|
|
|
|
|
2012-04-26 11:39:49 +08:00
|
|
|
void CCDictionary::setObject(CCObject* pObject, const std::string& key)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CCAssert(key.length() > 0 && pObject != NULL, "Invalid Argument!");
|
2013-01-15 17:09:25 +08:00
|
|
|
if (m_eDictType == kCCDictUnknown)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-01-15 17:09:25 +08:00
|
|
|
m_eDictType = kCCDictStr;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2013-01-15 17:09:25 +08:00
|
|
|
|
|
|
|
CCAssert(m_eDictType == kCCDictStr, "this dictionary doesn't use string as key.");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
CCDictElement *pElement = NULL;
|
2012-04-26 11:39:49 +08:00
|
|
|
HASH_FIND_STR(m_pElements, key.c_str(), pElement);
|
2012-04-19 14:35:52 +08:00
|
|
|
if (pElement == NULL)
|
|
|
|
{
|
|
|
|
setObjectUnSafe(pObject, key);
|
|
|
|
}
|
|
|
|
else if (pElement->m_pObject != pObject)
|
|
|
|
{
|
|
|
|
CCObject* pTmpObj = pElement->m_pObject;
|
|
|
|
pTmpObj->retain();
|
|
|
|
removeObjectForElememt(pElement);
|
|
|
|
setObjectUnSafe(pObject, key);
|
|
|
|
pTmpObj->release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-14 16:00:50 +08:00
|
|
|
void CCDictionary::setObject(CCObject* pObject, intptr_t key)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CCAssert(pObject != NULL, "Invalid Argument!");
|
2013-01-15 17:09:25 +08:00
|
|
|
if (m_eDictType == kCCDictUnknown)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-01-15 17:09:25 +08:00
|
|
|
m_eDictType = kCCDictInt;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2013-01-15 17:09:25 +08:00
|
|
|
|
|
|
|
CCAssert(m_eDictType == kCCDictInt, "this dictionary doesn't use integer as key.");
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
CCDictElement *pElement = NULL;
|
2013-04-14 16:00:50 +08:00
|
|
|
HASH_FIND_PTR(m_pElements, &key, pElement);
|
2012-04-19 14:35:52 +08:00
|
|
|
if (pElement == NULL)
|
|
|
|
{
|
|
|
|
setObjectUnSafe(pObject, key);
|
|
|
|
}
|
|
|
|
else if (pElement->m_pObject != pObject)
|
|
|
|
{
|
|
|
|
CCObject* pTmpObj = pElement->m_pObject;
|
|
|
|
pTmpObj->retain();
|
|
|
|
removeObjectForElememt(pElement);
|
|
|
|
setObjectUnSafe(pObject, key);
|
|
|
|
pTmpObj->release();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-04-26 11:39:49 +08:00
|
|
|
void CCDictionary::removeObjectForKey(const std::string& key)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-01-15 17:09:25 +08:00
|
|
|
if (m_eDictType == kCCDictUnknown)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2013-01-15 17:09:25 +08:00
|
|
|
|
|
|
|
CCAssert(m_eDictType == kCCDictStr, "this dictionary doesn't use string as its key");
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAssert(key.length() > 0, "Invalid Argument!");
|
|
|
|
CCDictElement *pElement = NULL;
|
2012-04-26 11:39:49 +08:00
|
|
|
HASH_FIND_STR(m_pElements, key.c_str(), pElement);
|
2012-04-19 14:35:52 +08:00
|
|
|
removeObjectForElememt(pElement);
|
|
|
|
}
|
|
|
|
|
2013-04-14 16:00:50 +08:00
|
|
|
void CCDictionary::removeObjectForKey(intptr_t key)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-01-15 17:09:25 +08:00
|
|
|
if (m_eDictType == kCCDictUnknown)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2013-01-15 17:09:25 +08:00
|
|
|
|
|
|
|
CCAssert(m_eDictType == kCCDictInt, "this dictionary doesn't use integer as its key");
|
2012-04-19 14:35:52 +08:00
|
|
|
CCDictElement *pElement = NULL;
|
2013-04-14 16:00:50 +08:00
|
|
|
HASH_FIND_PTR(m_pElements, &key, pElement);
|
2012-04-19 14:35:52 +08:00
|
|
|
removeObjectForElememt(pElement);
|
|
|
|
}
|
|
|
|
|
2012-04-26 11:39:49 +08:00
|
|
|
void CCDictionary::setObjectUnSafe(CCObject* pObject, const std::string& key)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
pObject->retain();
|
2012-04-26 11:39:49 +08:00
|
|
|
CCDictElement* pElement = new CCDictElement(key.c_str(), pObject);
|
2012-04-19 14:35:52 +08:00
|
|
|
HASH_ADD_STR(m_pElements, m_szKey, pElement);
|
|
|
|
}
|
|
|
|
|
2013-04-14 16:00:50 +08:00
|
|
|
void CCDictionary::setObjectUnSafe(CCObject* pObject, const intptr_t key)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
pObject->retain();
|
|
|
|
CCDictElement* pElement = new CCDictElement(key, pObject);
|
2013-04-14 16:00:50 +08:00
|
|
|
HASH_ADD_PTR(m_pElements, m_iKey, pElement);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCDictionary::removeObjectsForKeys(CCArray* pKeyArray)
|
|
|
|
{
|
|
|
|
CCObject* pObj = NULL;
|
|
|
|
CCARRAY_FOREACH(pKeyArray, pObj)
|
|
|
|
{
|
|
|
|
CCString* pStr = (CCString*)pObj;
|
2012-04-26 11:39:49 +08:00
|
|
|
removeObjectForKey(pStr->getCString());
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCDictionary::removeObjectForElememt(CCDictElement* pElement)
|
|
|
|
{
|
|
|
|
if (pElement != NULL)
|
|
|
|
{
|
|
|
|
HASH_DEL(m_pElements, pElement);
|
|
|
|
pElement->m_pObject->release();
|
|
|
|
CC_SAFE_DELETE(pElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCDictionary::removeAllObjects()
|
|
|
|
{
|
|
|
|
CCDictElement *pElement, *tmp;
|
|
|
|
HASH_ITER(hh, m_pElements, pElement, tmp)
|
|
|
|
{
|
|
|
|
HASH_DEL(m_pElements, pElement);
|
|
|
|
pElement->m_pObject->release();
|
|
|
|
CC_SAFE_DELETE(pElement);
|
2013-03-08 04:13:50 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CCObject* CCDictionary::copyWithZone(CCZone* pZone)
|
|
|
|
{
|
2012-09-17 15:02:24 +08:00
|
|
|
CCAssert(pZone == NULL, "CCDictionary should not be inherited.");
|
2012-04-19 14:35:52 +08:00
|
|
|
CCDictionary* pNewDict = new CCDictionary();
|
|
|
|
|
|
|
|
CCDictElement* pElement = NULL;
|
2012-06-14 15:13:16 +08:00
|
|
|
CCObject* pTmpObj = NULL;
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
if (m_eDictType == kCCDictInt)
|
|
|
|
{
|
|
|
|
CCDICT_FOREACH(this, pElement)
|
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
pTmpObj = pElement->getObject()->copy();
|
|
|
|
pNewDict->setObject(pTmpObj, pElement->getIntKey());
|
|
|
|
pTmpObj->release();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (m_eDictType == kCCDictStr)
|
|
|
|
{
|
|
|
|
CCDICT_FOREACH(this, pElement)
|
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
pTmpObj = pElement->getObject()->copy();
|
|
|
|
pNewDict->setObject(pTmpObj, pElement->getStrKey());
|
|
|
|
pTmpObj->release();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pNewDict;
|
|
|
|
}
|
|
|
|
|
2012-12-06 22:56:49 +08:00
|
|
|
CCObject* CCDictionary::randomObject()
|
|
|
|
{
|
|
|
|
if (m_eDictType == kCCDictUnknown)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCObject* key = allKeys()->randomObject();
|
|
|
|
|
|
|
|
if (m_eDictType == kCCDictInt)
|
|
|
|
{
|
|
|
|
return objectForKey(((CCInteger*)key)->getValue());
|
|
|
|
}
|
|
|
|
else if (m_eDictType == kCCDictStr)
|
|
|
|
{
|
|
|
|
return objectForKey(((CCString*)key)->getCString());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-14 16:05:58 +08:00
|
|
|
CCDictionary* CCDictionary::create()
|
2012-04-26 11:39:49 +08:00
|
|
|
{
|
|
|
|
CCDictionary* pRet = new CCDictionary();
|
|
|
|
if (pRet != NULL)
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2012-07-23 22:49:11 +08:00
|
|
|
CCDictionary* CCDictionary::createWithDictionary(CCDictionary* srcDict)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CCDictionary* pNewDict = (CCDictionary*)srcDict->copy();
|
|
|
|
pNewDict->autorelease();
|
|
|
|
return pNewDict;
|
|
|
|
}
|
|
|
|
|
2012-06-14 16:05:58 +08:00
|
|
|
CCDictionary* CCDictionary::createWithContentsOfFileThreadSafe(const char *pFileName)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-02-01 18:48:44 +08:00
|
|
|
return CCFileUtils::sharedFileUtils()->createCCDictionaryWithContentsOfFile(pFileName);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-05-10 15:07:05 +08:00
|
|
|
void CCDictionary::acceptVisitor(CCDataVisitor &visitor)
|
|
|
|
{
|
|
|
|
return visitor.visit(this);
|
|
|
|
}
|
|
|
|
|
2012-07-23 22:49:11 +08:00
|
|
|
CCDictionary* CCDictionary::createWithContentsOfFile(const char *pFileName)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-06-14 16:05:58 +08:00
|
|
|
CCDictionary* pRet = createWithContentsOfFileThreadSafe(pFileName);
|
2012-04-19 14:35:52 +08:00
|
|
|
pRet->autorelease();
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2013-04-13 16:55:24 +08:00
|
|
|
bool CCDictionary::writeToFile(const char *fullPath)
|
|
|
|
{
|
|
|
|
return CCFileUtils::sharedFileUtils()->writeToFile(this, fullPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
NS_CC_END
|