本文整理汇总了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;
}
示例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;
}
示例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;
}
示例4:
CCDictionary<std::string, CCObject*> *dictionaryWithContentsOfFile(const char *pFileName)
{
CCSAXParser parser;
parser.init(NULL);
parser.setDelegator(this);
parser.parse(pFileName);
return m_pRootDict;
}
示例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);
}
示例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());
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
}
示例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);
}