コード例 #1
0
CCDictionary<std::string, CCObject*> *CCFileUtils::dictionaryWithContentsOfFile(const char *pFileName)
{
	CCDictionary<std::string, CCObject*> *ret = dictionaryWithContentsOfFileThreadSafe(pFileName);
	ret->autorelease();

	return ret;
}
コード例 #2
0
ファイル: CCFileUtils.cpp プロジェクト: QiMa/Cocos2dWindows
CCDictionary *CCFileUtils::dictionaryWithContentsOfFile(const char *pFileName)
{
	//convert to full path
	std::string fileFullPath;
	fileFullPath = CCFileUtils::fullPathFromRelativePath(pFileName);
	CCDictionary *ret = dictionaryWithContentsOfFileThreadSafe(fileFullPath.c_str());
	ret->autorelease();

	return ret;
}
コード例 #3
0
ファイル: GridElementProperty.cpp プロジェクト: sgeniusd/DR
void GridElementProperty::saveToDictionary(CCDictionary *dict)
{
    stringstream strStream;
    strStream << mIndex.rIndex << "_" << mIndex.vIndex;
    
    CCDictionary *gridDict = new CCDictionary();
    
    gridDict->setObject(DRUtility::getCCStringWithInt(mType), "mType");
    gridDict->setObject(DRUtility::getCCStringWithInt(mID), "mID");
    gridDict->setObject(DRUtility::getCCStringWithInt(mIndex.rIndex), "rIndex");
    gridDict->setObject(DRUtility::getCCStringWithInt(mIndex.vIndex), "vIndex");
    dict->setObject(gridDict, strStream.str());
    gridDict->autorelease();
}
コード例 #4
0
CCDictionary* createCCDictionaryWithData(unsigned char* data)
{
    CCAssert((data),"data must not be NULL!!!");
    
    CCDictMaker tMaker;
	CCDictionary* dict = tMaker.dictionaryWithData(data);
	
    if (dict != NULL)
    {
        dict->autorelease();
    }
	CC_SAFE_DELETE_ARRAY(data);
	
	return dict;
}
コード例 #5
0
void startElement(void *ctx, const XML_Char *name, const XML_Char **atts)
{
	std::string sName((char*)name);
	if( sName == "dict" )
	{
		CCDictionary<std::string, CCObject*> *pNewDict = new CCDictionary<std::string, CCObject*>();
		if(! m_pRootDict)
		{
			m_pRootDict = pNewDict;
			pNewDict->autorelease();
		}
		else
		{
			CCAssert(m_pCurDict && !m_sCurKey.empty(), "");
			m_pCurDict->setObject(pNewDict, m_sCurKey);
			pNewDict->release();
			m_sCurKey.clear();
		}
		m_pCurDict = pNewDict;
		m_tDictStack.push(m_pCurDict);
		m_tState = SAX_DICT;
	}
	else if(sName == "key")
	{
		m_tState = SAX_KEY;
	}
	else if(sName == "integer")
	{
		m_tState = SAX_INT;
	}
	else if(sName == "real")
	{
		m_tState = SAX_REAL;
	}
	else if(sName == "string")
	{
		m_tState = SAX_STRING;
	}
	else
	{
        if (sName == "array")
        {
            m_bInArray = true;
            m_pArray = new CCMutableArray<CCObject*>();
        }
		m_tState = SAX_NONE;
	}	
}
コード例 #6
0
void plist_startElement(void *ctx, const xmlChar *name, const xmlChar **atts)
{
	CCDictMaker *pMaker = (CCDictMaker*)(ctx);
	std::string sName((char*)name);
	if( sName == "dict" )
	{
		CCDictionary<std::string, CCObject*> *pNewDict = new CCDictionary<std::string, CCObject*>();
		if(! pMaker->m_pRootDict)
		{
			pMaker->m_pRootDict = pNewDict;
			pNewDict->autorelease();
		}
		else
		{
			CCAssert(pMaker->m_pCurDict && !pMaker->m_sCurKey.empty(), "");
			pMaker->m_pCurDict->setObject(pNewDict, pMaker->m_sCurKey);
			pNewDict->release();
			pMaker->m_sCurKey.clear();
		}
		pMaker->m_pCurDict = pNewDict;
		pMaker->m_tDictStack.push(pMaker->m_pCurDict);
		pMaker->m_tState = SAX_DICT;
	}
	else if(sName == "key")
	{
		pMaker->m_tState = SAX_KEY;
	}
	else if(sName == "integer")
	{
		pMaker->m_tState = SAX_INT;
	}
	else if(sName == "real")
	{
		pMaker->m_tState = SAX_REAL;
	}
	else if(sName == "string")
	{
		pMaker->m_tState = SAX_STRING;
	}
	else
	{
		pMaker->m_tState = SAX_NONE;
	}
}
コード例 #7
0
    void startElement(void *ctx, const char *name, const char **atts)
    {
        CC_UNUSED_PARAM(ctx);
        CC_UNUSED_PARAM(atts);
        std::string sName((char*)name);
        if( sName == "dict" )
        {
            m_pCurDict = new CCDictionary<std::string, CCObject*>();
            if(! m_pRootDict)
            {
                m_pRootDict = m_pCurDict;
            }
            m_tState = SAX_DICT;

            CCSAXState preState = SAX_NONE;
            if (! m_tStateStack.empty())
            {
                preState = m_tStateStack.top();
            }

            if (SAX_ARRAY == preState)
            {
                // add the dictionary into the array
                m_pArray->addObject(m_pCurDict);
            }
            else if (SAX_DICT == preState)
            {
                // add the dictionary into the pre dictionary
                CCAssert(! m_tDictStack.empty(), "The state is wrong!");
                CCDictionary<std::string, CCObject*>* pPreDict = m_tDictStack.top();
                pPreDict->setObject(m_pCurDict, m_sCurKey);
            }
            m_pCurDict->autorelease();

            // record the dict state
            m_tStateStack.push(m_tState);
            m_tDictStack.push(m_pCurDict);
        }
        else if(sName == "key")
        {
            m_tState = SAX_KEY;
        }
        else if(sName == "integer")
        {
            m_tState = SAX_INT;
        }
        else if(sName == "real")
        {
            m_tState = SAX_REAL;
        }
        else if(sName == "string")
        {
            m_tState = SAX_STRING;
        }
        else if (sName == "array")
        {
            m_tState = SAX_ARRAY;
            m_pArray = new CCMutableArray<CCObject*>();

            CCSAXState preState = m_tStateStack.empty() ? SAX_DICT : m_tStateStack.top();
            if (preState == SAX_DICT)
            {
                m_pCurDict->setObject(m_pArray, m_sCurKey);
            }
            else if (preState == SAX_ARRAY)
            {
                CCAssert(! m_tArrayStack.empty(), "The state is worng!");
                CCMutableArray<CCObject*>* pPreArray = m_tArrayStack.top();
                pPreArray->addObject(m_pArray);
            }
            m_pArray->release();
            // record the array state
            m_tStateStack.push(m_tState);
            m_tArrayStack.push(m_pArray);
        }
        else
        {
            m_tState = SAX_NONE;
        }
    }