Error[8]: Undefined offset: 6, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述1、继承自CCObject class CC_DLL CCString : public CCObject 2、如果通过create创建,会加入自动释放池,通过new创建则不会,所以使用时要记得retain,然后释放时 使用release。 CCString* CCString::create(const std::string& str){ CCString* pRet = new C

1、继承自CCObject

class CC_DLL CCString : public CCObject

2、如果通过create创建,会加入自动释放池,通过new创建则不会,所以使用时要记得retain,然后释放时
使用release。

CCString* CCString::create(const std::string& str){    CCString* pRet = new CCString(str);    pRet->autorelease();    return pRet;}-->>CCString::CCString(const std::string& str)    :m_sstring(str){}
3、通过字节数组CCString* CCString::createWithData(const unsigned char* pData,unsigned long nLen){    CCString* pRet = NulL;    if (pData != NulL)    {        char* pStr = (char*)malloc(nLen+1);        if (pStr != NulL)        {            pStr[nLen] = '[+++]';            if (nLen > 0)            {                memcpy(pStr,pData,nLen);            }                        pRet = CCString::create(pStr);            free(pStr);        }    }    return pRet;}4、格式化创建CCString::createWithFormat("%s%02d.png",c,1);CCString* CCString::createWithFormat(const char* format,...){    CCString* pRet = CCString::create("");    va_List ap;    va_start(ap,format);    pRet->initWithFormatandVaList(format,ap);    va_end(ap);    return pRet;}5、读取文件创建CCString* CCString::createWithContentsOffile(const char* pszfilename){    unsigned long size = 0;    unsigned char* pData = 0;    CCString* pRet = NulL;    pData = CCfileUtils::sharedfileUtils()->getfileData(pszfilename,"rb",&size);    pRet = CCString::createWithData(pData,size);    CC_SAFE_DELETE_ARRAY(pData);    return pRet;}6、获取C类型的字符const char* CCString::getCString() const{    return m_sstring.c_str();}7、获取长度unsigned int CCString::length() const{    return m_sstring.length();}8、相等比较bool CCString::isEqual(const CCObject* pObject){    bool bRet = false;    const CCString* pStr = dynamic_cast<const CCString*>(pObject);    if (pStr != NulL)    {        if (0 == m_sstring.compare(pStr->m_sstring))        {            bRet = true;        }    }    return bRet;}9、析构CCString::~CCString(){     m_sstring.clear();}
总结

以上是内存溢出为你收集整理的cocos2dx-2.x CCString代码全部内容,希望文章能够帮你解决cocos2dx-2.x CCString代码所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
cocos2dx-2.x CCString代码_app_内存溢出

cocos2dx-2.x CCString代码

cocos2dx-2.x CCString代码,第1张

概述1、继承自CCObject class CC_DLL CCString : public CCObject 2、如果通过create创建,会加入自动释放池,通过new创建则不会,所以使用时要记得retain,然后释放时 使用release。 CCString* CCString::create(const std::string& str){ CCString* pRet = new C

1、继承自CCObject

class CC_DLL CCString : public CCObject

2、如果通过create创建,会加入自动释放池,通过new创建则不会,所以使用时要记得retain,然后释放时
使用release。

CCString* CCString::create(const std::string& str){    CCString* pRet = new CCString(str);    pRet->autorelease();    return pRet;}-->>CCString::CCString(const std::string& str)    :m_sstring(str){}
3、通过字节数组CCString* CCString::createWithData(const unsigned char* pData,unsigned long nLen){    CCString* pRet = NulL;    if (pData != NulL)    {        char* pStr = (char*)malloc(nLen+1);        if (pStr != NulL)        {            pStr[nLen] = '';            if (nLen > 0)            {                memcpy(pStr,pData,nLen);            }                        pRet = CCString::create(pStr);            free(pStr);        }    }    return pRet;}4、格式化创建CCString::createWithFormat("%s%02d.png",c,1);CCString* CCString::createWithFormat(const char* format,...){    CCString* pRet = CCString::create("");    va_List ap;    va_start(ap,format);    pRet->initWithFormatandVaList(format,ap);    va_end(ap);    return pRet;}5、读取文件创建CCString* CCString::createWithContentsOffile(const char* pszfilename){    unsigned long size = 0;    unsigned char* pData = 0;    CCString* pRet = NulL;    pData = CCfileUtils::sharedfileUtils()->getfileData(pszfilename,"rb",&size);    pRet = CCString::createWithData(pData,size);    CC_SAFE_DELETE_ARRAY(pData);    return pRet;}6、获取C类型的字符const char* CCString::getCString() const{    return m_sstring.c_str();}7、获取长度unsigned int CCString::length() const{    return m_sstring.length();}8、相等比较bool CCString::isEqual(const CCObject* pObject){    bool bRet = false;    const CCString* pStr = dynamic_cast<const CCString*>(pObject);    if (pStr != NulL)    {        if (0 == m_sstring.compare(pStr->m_sstring))        {            bRet = true;        }    }    return bRet;}9、析构CCString::~CCString(){     m_sstring.clear();}
总结

以上是内存溢出为你收集整理的cocos2dx-2.x CCString代码全部内容,希望文章能够帮你解决cocos2dx-2.x CCString代码所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1052081.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存