本文整理汇总了C++中CCString::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ CCString::c_str方法的具体用法?C++ CCString::c_str怎么用?C++ CCString::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCString
的用法示例。
在下文中一共展示了CCString::c_str方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getCurrentLanguageJNI
//////////////////////////////////////////////////////////////////////////
// handle get current language
//////////////////////////////////////////////////////////////////////////
const char* getCurrentLanguageJNI()
{
JniMethodInfo t;
if (JniHelper::getStaticMethodInfo(t
, "org/cocos2dx/lib/Cocos2dxActivity"
, "getCurrentLanguage"
, "()Ljava/lang/String;"))
{
jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID);
t.env->DeleteLocalRef(t.classID);
CCString *ret = new CCString(JniHelper::jstring2string(str).c_str());
ret->autorelease();
t.env->DeleteLocalRef(str);
LOGD("language name %s", ret.c_str());
return ret->m_sString.c_str();
}
return 0;
}
示例2: GetCCObjectValue
void GetCCObjectValue(CCObject * pValueObject, std::string & rValue)
{
assert(pValueObject && pValueObject->isOfClass(CCObject::ClassOfCCString));
CCString * pValue = (CCString *)pValueObject;
rValue = ConvertToAString(pValue->c_str());
}
示例3: RecurseSave
void RecurseSave(TiXmlNode * pParentNode, CCObject * pParentObj)
{
if (pParentObj->isOfClass(CCObject::ClassOfCCDictionary))
{
TiXmlElement * pDictElement = new TiXmlElement("dict");
pParentNode->LinkEndChild(pDictElement);
CCDictionary * pDict = (CCDictionary *)pParentObj;
for (CCDictionary::iterator it = pDict->begin(); it != pDict->end(); it++)
{
TiXmlElement * pKeyElement = new TiXmlElement("key");
{
TiXmlText * pKeyText = new TiXmlText(it->first.c_str());
pKeyElement->LinkEndChild(pKeyText);
}
pDictElement->LinkEndChild(pKeyElement);
CCObject * pObject = it->second;
RecurseSave(pDictElement, pObject);
}
}
else if (pParentObj->isOfClass(CCObject::ClassOfCCArray))
{
TiXmlElement * pArrayElement = new TiXmlElement("array");
pParentNode->LinkEndChild(pArrayElement);
CCArray * pValue = (CCArray *)pParentObj;
for (CCArray::iterator it = pValue->begin(); it != pValue->end(); it++)
{
CCObject * pObject = *it;
RecurseSave(pArrayElement, pObject);
}
}
else if (pParentObj->isOfClass(CCObject::ClassOfCCString))
{
CCString * pValue = (CCString *)pParentObj;
TiXmlElement * pValueElement = new TiXmlElement("string");
{
TiXmlText * pValueText = new TiXmlText(ConvertToAString(pValue->c_str()).c_str());
pValueElement->LinkEndChild(pValueText);
}
pParentNode->LinkEndChild(pValueElement);
}
else if (pParentObj->isOfClass(CCObject::ClassOfCCBool))
{
CCBool * pValue = (CCBool *)pParentObj;
TiXmlElement * pValueElement = new TiXmlElement(*pValue ? "true" : "false");
pParentNode->LinkEndChild(pValueElement);
}
else if (pParentObj->isOfClass(CCObject::ClassOfCCInteger))
{
CCInteger * pValue = (CCInteger *)pParentObj;
TiXmlElement * pValueElement = new TiXmlElement("integer");
{
char szBuf[64] = {0};
sprintf(szBuf, "%d", (int)(*pValue));
TiXmlText * pValueText = new TiXmlText(szBuf);
pValueElement->LinkEndChild(pValueText);
}
pParentNode->LinkEndChild(pValueElement);
}
else if (pParentObj->isOfClass(CCObject::ClassOfCCReal))
{
CCReal * pValue = (CCReal *)pParentObj;
TiXmlElement * pValueElement = new TiXmlElement("real");
{
TiXmlText * pValueText = new TiXmlText(FloatToString((double)(*pValue)));
pValueElement->LinkEndChild(pValueText);
}
pParentNode->LinkEndChild(pValueElement);
}
else if (pParentObj->isOfClass(CCObject::ClassOfCCDate))
{
CCDate * pValue = (CCDate *)pParentObj;
TiXmlElement * pValueElement = new TiXmlElement("date");
{
char szBuf[64] = {0};
getTimeString(*pValue, szBuf);
TiXmlText * pValueText = new TiXmlText(szBuf);
pValueElement->LinkEndChild(pValueText);
}
pParentNode->LinkEndChild(pValueElement);
}
}