当前位置: 首页>>代码示例>>C++>>正文


C++ CCSAXParser类代码示例

本文整理汇总了C++中CCSAXParser的典型用法代码示例。如果您正苦于以下问题:C++ CCSAXParser类的具体用法?C++ CCSAXParser怎么用?C++ CCSAXParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CCSAXParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CJPsdParser

void CJPsdParser::parseToPsdXML(std::string strPsdFileName,
                                cocos2d::CCDictionary **pPsdDict,
                                bool bIsCommonPath /* = false */)
{
    CJPsdParser *psdParser = new CJPsdParser();
    psdParser->_setPsdData(pPsdDict);
    
    std::string rootPath;
    if (!bIsCommonPath) {
        rootPath = CJUtils::getInstance()->getResourcePath();
    }
    else
    {
        rootPath = CJUtils::getInstance()->getCommonResourcePath();
    }
    std::string tempFileName = rootPath.append("xml/");
    tempFileName.append(strPsdFileName);

    
    CCSAXParser xmlParser;
    xmlParser.init(ENCODE_TYPE_UTF8);
    xmlParser.setDelegator(psdParser);
    xmlParser.parse(tempFileName.c_str());
    
    delete psdParser;
}
开发者ID:JeonJonguk,项目名称:e002_c010,代码行数:26,代码来源:CJPSDParser.cpp

示例2: CCLog

element_list_t* RSimpleHTMLParser::parseHTMLString(const char* utf8_str)
{
	CCSAXParser parser;
	if ( !parser.init("UTF-8") )
	{
		CCLog("[CCRich] CCSAXParser.init failed!");
		return NULL;
	}

	parser.setDelegator(this);

	element_list_t* elelist = new element_list_t;
	m_rElements = elelist;
	m_rCurrentElement = NULL;

	if ( !parser.parse(utf8_str, strlen(utf8_str)) || elelist->empty() )
	{
		CC_SAFE_DELETE(elelist);
	}

	m_rCurrentElement = NULL;
	m_rElements = NULL;

	return elelist;
}
开发者ID:BackMountainBird,项目名称:cocos2dx-ext,代码行数:25,代码来源:CCRichParser.cpp

示例3: loadAnimations

void AnimatePacker::loadAnimations(const char *path )
{
	const char *pszPath = CCFileUtils::sharedFileUtils()->fullPathForFilename(path).c_str();

	CCSAXParser parser;
	AnimateSaxDelegator delegator;

	if (false == parser.init("UTF-8"))
	{
		//TODO
		return;
	}
	parser.setDelegator(&delegator);
	parser.parse(pszPath);

	//load plist
	vector<string> plists=delegator.plists;
	for (unsigned int i=0;i<plists.size();i++)
	{
	    string plistPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(plists[i].c_str(), pszPath);
		CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(plistPath.c_str());
	}

	//load animate
	vector<Animate> animates=delegator.animates;
	CCArray *spriteFramesArray = new CCArray();

	set<string> animateNames;
	for (unsigned int i=0;i<animates.size();i++)
	{
		Animate animate=animates[i];
		vector<string> spriteFrames=animate.spriteFrames;

		for (unsigned int j=0;j<spriteFrames.size();j++)
		{
			animateNames.insert(spriteFrames[j]);
			CCSpriteFrame *spriteFrame=CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(spriteFrames[j].c_str());
			spriteFramesArray->addObject(spriteFrame);
		}

		CCAnimation *animation = CCAnimation::createWithSpriteFrames(spriteFramesArray);
        animation->setDelayPerUnit(animate.delay);
		CCAnimationCache::sharedAnimationCache()->addAnimation(animation,animate.name.c_str());

		spriteFramesArray->removeAllObjects();
	}
	
	//record animate
	for(unsigned int i=0;i<animates.size();i++){
		Animate animate=animates[i];
		nameToAnimateMap[animate.name]=animate;
	}

	//record plist
	pathToPlistsMap[path]=plists;

	//record CCAnimate name
	pathToNameMap[path]=animateNames;
}
开发者ID:Ghost233,项目名称:GAnimate,代码行数:59,代码来源:AnimatePacker.cpp

示例4:

	CCDictionary<std::string, CCObject*> *dictionaryWithContentsOfFile(const char *pFileName)
	{
		CCSAXParser parser;
		parser.init(NULL);
		parser.setDelegator(this);
		parser.parse(pFileName);
		return m_pRootDict;
	}
开发者ID:flyingpacer,项目名称:cocos2d-x-samples,代码行数:8,代码来源:CCFileUtils_airplay.cpp

示例5: CCSAXParser

bool MyXmlParser::initWithFilename(const char *filename)
{
    dic = CCDictionary::create();
    dic->retain();
    CCSAXParser *parser = new CCSAXParser();
    parser->setDelegator(this);
    parser->init("UTF_8");
    parser->parse(filename);
}
开发者ID:KuaiFaMaster,项目名称:KuaifaCppDemo,代码行数:9,代码来源:MyXmlParser.cpp

示例6: parseXMLFile

bool CCTMXMapInfo::parseXMLFile(const char *xmlFilename)
{
    CCSAXParser parser;
    
    if (false == parser.init("UTF-8") )
    {
        return false;
    }
    
    parser.setDelegator(this);

    return parser.parse(CCFileUtils::sharedFileUtils()->fullPathForFilename(xmlFilename).c_str());
}
开发者ID:gydihl,项目名称:cocos2d-x-2.2.3,代码行数:13,代码来源:CCTMXXMLParser.cpp

示例7: parseXMLFile

bool CCTMXMapInfo::parseXMLFile(const char *xmlFilename)
{
    CCSAXParser parser;
    
    if (false == parser.init("UTF-8") )
    {
        return false;
    }
    
    parser.setDelegator(this);

    return parser.parse(xmlFilename);    
}
开发者ID:Atomz,项目名称:super-animation-samples,代码行数:13,代码来源:CCTMXXMLParser.cpp

示例8:

    CCDictionary *dictionaryWithContentsOfFile(const char *pFileName)
    {
        m_eResultType = SAX_RESULT_DICT;
        CCSAXParser parser;

        if (false == parser.init("UTF-8"))
        {
            return NULL;
        }
        parser.setDelegator(this);

        parser.parse(pFileName);
        return m_pRootDict;
    }
开发者ID:QiMa,项目名称:Cocos2dWindows,代码行数:14,代码来源:CCFileUtils.cpp

示例9: arrayWithContentsOfFile

    CCArray* arrayWithContentsOfFile(const char* pFileName)
    {
        m_eResultType = SAX_RESULT_ARRAY;
        CCSAXParser parser;

        if (false == parser.init("UTF-8"))
        {
            return NULL;
        }
        parser.setDelegator(this);

        parser.parse(pFileName);
        return m_pArray;
    }
开发者ID:QiMa,项目名称:Cocos2dWindows,代码行数:14,代码来源:CCFileUtils.cpp

示例10: dictionaryWithData

	//2013.5.31 wangtiwei
	CCDictionary* dictionaryWithData(unsigned char* data)
	{
		m_eResultType = SAX_RESULT_DICT;
		CCSAXParser parser;
        
		if (false == parser.init("UTF-8"))
		{
			return NULL;
		}
		parser.setDelegator(this);
		unsigned int udataLength = strlen((char*)data);
		parser.parse((char*)data, udataLength);
		return m_pRootDict;
	}
开发者ID:QiuleiWang,项目名称:cocos2d-x-2.x-utils,代码行数:15,代码来源:EncryptUtils.cpp

示例11: memset

void HelloWorld::saxDelegatorParse()
{
	char filePath[1024]= {'\0'};
	memset(filePath,0,sizeof(filePath));
	strcat(filePath,CCFileUtils::sharedFileUtils()->getWriteablePath().c_str());
	strcat(filePath,"CreatedXml.xml");

	CCSAXParser *parser = new CCSAXParser();
	parser->setDelegator(this);
	parser->init("UTF-8");
	parser->parse(filePath);

	delete parser;
}
开发者ID:YarinYang,项目名称:cocos2d-x-test,代码行数:14,代码来源:HelloWorldScene.cpp

示例12: arrayWithData

	///2013.5.31
	CCArray* arrayWithData(unsigned char* data)
	{
		m_eResultType = SAX_RESULT_ARRAY;
		CCSAXParser parser;
        
		if (false == parser.init("UTF-8"))
		{
			return NULL;
		}
		parser.setDelegator(this);
        
		unsigned int udataLength = strlen((char*)data);
		parser.parse((char*)data, udataLength);
		return m_pArray;
	}
开发者ID:QiuleiWang,项目名称:cocos2d-x-2.x-utils,代码行数:16,代码来源:EncryptUtils.cpp

示例13: parseXMLFile

bool XMLLevelLoader::parseXMLFile(const char *xmlFilename)
{
    CCSAXParser parser;
    
    if (false == parser.init("UTF-8") )
    {
        return false;
    }
    
    parser.setDelegator(this);
    
    xObjectoffset = 0.0f;
    yObjectoffset = 0.0f;

    return parser.parse(xmlFilename);
}
开发者ID:ryanmcbride,项目名称:CrashTestMonkeysDroid,代码行数:16,代码来源:XMLLevelLoader.cpp

示例14: loadAnimate

void AnimatePacker::loadAnimate( char *path )
{
	//解析xml////////////////////////////////////
	const char *pszPath = CCFileUtils::fullPathFromRelativePath(path);//从相对路径得到绝对全路径

	CCSAXParser parser;
	AnimateSaxDelegator delegator;

	if (false == parser.init("UTF-8"))
	{
		//TODO
		return;
	}
	parser.setDelegator(&delegator);
	parser.parse(pszPath);

	//加载plist////////////////////////////////////
	vector<string> plists=delegator.plists;
	for (int i=0;i<plists.size();i++)
	{
		CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(plists[i].c_str());
	}

	//缓冲animate////////////////////////////////////
	vector<Animate> animates=delegator.animates;
	CCMutableArray<CCSpriteFrame*> *spriteFramesArray = new CCMutableArray<CCSpriteFrame*>();

	for (int i=0;i<animates.size();i++)
	{
		Animate animate=animates[i];
		vector<string> spriteFrames=animate.spriteFrames;

		for (int j=0;j<spriteFrames.size();j++)
		{
			CCSpriteFrame *spriteFrame=CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(spriteFrames[j].c_str());
			spriteFramesArray->addObject(spriteFrame);
		}

		CCAnimation *animation=CCAnimation::animationWithFrames(spriteFramesArray,animate.delay);
		CCAnimationCache::sharedAnimationCache()->addAnimation(animation,animate.name.c_str());

		spriteFramesArray->removeAllObjects();
	}
	
}
开发者ID:cacls,项目名称:cacls,代码行数:45,代码来源:AnimatePacker.cpp

示例15: strlen

bool CCTMXMapInfo::parseXMLString(const char *xmlString)
{
    int len = strlen(xmlString);
    if (xmlString == NULL || len <= 0) 
    {
        return false;
    }

    CCSAXParser parser;

    if (false == parser.init("UTF-8") )
    {
        return false;
    }

    parser.setDelegator(this);

    return parser.parse(xmlString, len);
}
开发者ID:gydihl,项目名称:cocos2d-x-2.2.3,代码行数:19,代码来源:CCTMXXMLParser.cpp


注:本文中的CCSAXParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。