Move StringUtils functions from deprecated header file to ccUTF8.h (#15835)

* Move StringUtils functions outside of deprecated header

* Replace deprecated headers with 'base/ccUTF8.h'
This commit is contained in:
mogemimi 2016-06-15 16:01:26 +09:00 committed by minggo
parent dd6fed7928
commit a348cbda8b
44 changed files with 71 additions and 97 deletions

View File

@ -29,7 +29,7 @@ THE SOFTWARE.
#include "2d/CCActionInterval.h"
#include "2d/CCNode.h"
#include "base/CCDirector.h"
#include "deprecated/CCString.h"
#include "base/ccUTF8.h"
NS_CC_BEGIN
//

View File

@ -44,7 +44,7 @@ THE SOFTWARE.
#include "renderer/CCRenderer.h"
#include "renderer/CCVertexIndexBuffer.h"
#include "base/CCDirector.h"
#include "deprecated/CCString.h"
#include "base/ccUTF8.h"
NS_CC_BEGIN
namespace experimental {

View File

@ -26,7 +26,7 @@ THE SOFTWARE.
****************************************************************************/
#include "2d/CCFastTMXTiledMap.h"
#include "2d/CCFastTMXLayer.h"
#include "deprecated/CCString.h"
#include "base/ccUTF8.h"
NS_CC_BEGIN
namespace experimental {

View File

@ -31,10 +31,9 @@
#include "base/CCConfiguration.h"
#include "base/CCDirector.h"
#include "base/CCMap.h"
#include "base/ccUTF8.h"
#include "renderer/CCTextureCache.h"
#include "deprecated/CCString.h"
using namespace std;
NS_CC_BEGIN

View File

@ -28,10 +28,9 @@ THE SOFTWARE.
#include "renderer/CCTextureAtlas.h"
#include "platform/CCFileUtils.h"
#include "base/CCDirector.h"
#include "base/ccUTF8.h"
#include "renderer/CCTextureCache.h"
#include "deprecated/CCString.h"
#if CC_LABELATLAS_DEBUG_DRAW
#include "renderer/CCRenderer.h"
#endif

View File

@ -32,7 +32,7 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only)
****************************************************************************/
#include "2d/CCLabelBMFont.h"
#include "deprecated/CCString.h"
#include "base/ccUTF8.h"
#include "2d/CCSprite.h"
#if CC_LABELBMFONT_DEBUG_DRAW

View File

@ -25,7 +25,7 @@ THE SOFTWARE.
****************************************************************************/
#include "2d/CCLabelTTF.h"
#include "2d/CCLabel.h"
#include "deprecated/CCString.h"
#include "base/ccUTF8.h"
NS_CC_BEGIN

View File

@ -40,9 +40,7 @@ THE SOFTWARE.
#include "base/CCEventListenerKeyboard.h"
#include "base/CCEventAcceleration.h"
#include "base/CCEventListenerAcceleration.h"
#include "deprecated/CCString.h"
#include "base/ccUTF8.h"
NS_CC_BEGIN

View File

@ -29,8 +29,8 @@ THE SOFTWARE.
#include "base/CCTouch.h"
#include "base/CCEventListenerTouch.h"
#include "base/CCEventDispatcher.h"
#include "base/ccUTF8.h"
#include "platform/CCStdC.h"
#include "deprecated/CCString.h"
#include <vector>

View File

@ -30,7 +30,7 @@ THE SOFTWARE.
#include "2d/CCSprite.h"
#include "2d/CCLabelAtlas.h"
#include "2d/CCLabel.h"
#include "deprecated/CCString.h"
#include "base/ccUTF8.h"
#include <stdarg.h>
NS_CC_BEGIN

View File

@ -35,6 +35,7 @@ THE SOFTWARE.
#include "base/CCDirector.h"
#include "base/CCScheduler.h"
#include "base/CCEventDispatcher.h"
#include "base/ccUTF8.h"
#include "2d/CCCamera.h"
#include "2d/CCActionManager.h"
#include "2d/CCScene.h"
@ -43,7 +44,6 @@ THE SOFTWARE.
#include "renderer/CCGLProgramState.h"
#include "renderer/CCMaterial.h"
#include "math/TransformUtils.h"
#include "deprecated/CCString.h"
#if CC_NODE_RENDER_SUBPIXEL

View File

@ -36,7 +36,7 @@
#include "renderer/CCRenderer.h"
#include "renderer/CCTextureAtlas.h"
#include "base/CCProfiling.h"
#include "deprecated/CCString.h"
#include "base/ccUTF8.h"
NS_CC_BEGIN

View File

@ -52,8 +52,8 @@ THE SOFTWARE.
#include "base/ZipUtils.h"
#include "base/CCDirector.h"
#include "base/CCProfiling.h"
#include "base/ccUTF8.h"
#include "renderer/CCTextureCache.h"
#include "deprecated/CCString.h"
#include "platform/CCFileUtils.h"
using namespace std;

View File

@ -41,8 +41,7 @@ THE SOFTWARE.
#include "base/CCConfiguration.h"
#include "base/CCEventListenerCustom.h"
#include "base/CCEventDispatcher.h"
#include "deprecated/CCString.h"
#include "base/ccUTF8.h"
NS_CC_BEGIN

View File

@ -30,9 +30,9 @@ THE SOFTWARE.
#include "2d/CCCamera.h"
#include "base/CCEventDispatcher.h"
#include "base/CCEventListenerCustom.h"
#include "base/ccUTF8.h"
#include "renderer/CCRenderer.h"
#include "renderer/CCFrameBuffer.h"
#include "deprecated/CCString.h"
#if CC_USE_PHYSICS
#include "physics/CCPhysicsWorld.h"

View File

@ -37,11 +37,9 @@ THE SOFTWARE.
#include "renderer/CCTexture2D.h"
#include "renderer/CCRenderer.h"
#include "base/CCDirector.h"
#include "base/ccUTF8.h"
#include "2d/CCCamera.h"
#include "deprecated/CCString.h"
NS_CC_BEGIN
// MARK: create, init, dealloc

View File

@ -30,13 +30,11 @@ THE SOFTWARE.
#include "2d/CCSprite.h"
#include "base/CCDirector.h"
#include "base/CCProfiling.h"
#include "base/ccUTF8.h"
#include "renderer/CCTextureCache.h"
#include "renderer/CCRenderer.h"
#include "renderer/CCQuadCommand.h"
#include "deprecated/CCString.h" // For StringUtils::format
NS_CC_BEGIN
/*

View File

@ -37,14 +37,12 @@ THE SOFTWARE.
#include "platform/CCFileUtils.h"
#include "base/CCNS.h"
#include "base/ccMacros.h"
#include "base/ccUTF8.h"
#include "base/CCDirector.h"
#include "renderer/CCTexture2D.h"
#include "renderer/CCTextureCache.h"
#include "base/CCNinePatchImageParser.h"
#include "deprecated/CCString.h"
using namespace std;
NS_CC_BEGIN

View File

@ -29,9 +29,9 @@ THE SOFTWARE.
#include "2d/CCTMXTiledMap.h"
#include "2d/CCSprite.h"
#include "base/CCDirector.h"
#include "base/ccUTF8.h"
#include "renderer/CCTextureCache.h"
#include "renderer/CCGLProgram.h"
#include "deprecated/CCString.h" // For StringUtils::format
NS_CC_BEGIN

View File

@ -28,7 +28,7 @@ THE SOFTWARE.
#include "2d/CCTMXXMLParser.h"
#include "2d/CCTMXLayer.h"
#include "2d/CCSprite.h"
#include "deprecated/CCString.h" // For StringUtils::format
#include "base/ccUTF8.h"
NS_CC_BEGIN

View File

@ -29,8 +29,7 @@ THE SOFTWARE.
#include "renderer/CCTextureAtlas.h"
#include "base/TGAlib.h"
#include "base/CCDirector.h"
#include "deprecated/CCString.h"
#include "base/ccUTF8.h"
NS_CC_BEGIN

View File

@ -32,6 +32,7 @@
#include "base/CCDirector.h"
#include "base/CCAsyncTaskPool.h"
#include "base/ccUTF8.h"
#include "2d/CCLight.h"
#include "2d/CCCamera.h"
#include "base/ccMacros.h"
@ -45,8 +46,6 @@
#include "renderer/CCTechnique.h"
#include "renderer/CCPass.h"
#include "deprecated/CCString.h" // For StringUtils::format
NS_CC_BEGIN
static Sprite3DMaterial* getSprite3DMaterialForAttribs(MeshVertexData* meshVertexData, bool usesLight);

View File

@ -32,8 +32,6 @@
#include "math/Mat4.h"
#include "base/ccUTF8.h"
#include "base/CCData.h"
#include "deprecated/CCString.h"
USING_NS_CC;

View File

@ -32,6 +32,27 @@ NS_CC_BEGIN
namespace StringUtils {
std::string format(const char* format, ...)
{
#define CC_MAX_STRING_LENGTH (1024*100)
std::string ret;
va_list ap;
va_start(ap, format);
char* buf = (char*)malloc(CC_MAX_STRING_LENGTH);
if (buf != nullptr)
{
vsnprintf(buf, CC_MAX_STRING_LENGTH, format, ap);
ret = buf;
free(buf);
}
va_end(ap);
return ret;
}
/*
* @str: the string to search through.
* @c: the character to not look for.

View File

@ -29,6 +29,7 @@
#include "platform/CCPlatformMacros.h"
#include <vector>
#include <string>
#include <sstream>
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include "platform/android/jni/JniHelper.h"
@ -38,6 +39,16 @@ NS_CC_BEGIN
namespace StringUtils {
template<typename T>
std::string toString(T arg)
{
std::stringstream ss;
ss << arg;
return ss.str();
}
std::string CC_DLL format(const char* format, ...) CC_FORMAT_PRINTF(1, 2);
/**
* @brief Converts from UTF8 string to UTF16 string.
*

View File

@ -26,6 +26,7 @@ THE SOFTWARE.
#include "deprecated/CCArray.h"
#include "deprecated/CCString.h"
#include "base/ccUTF8.h"
#include "platform/CCFileUtils.h"
NS_CC_BEGIN

View File

@ -25,6 +25,7 @@
#include "deprecated/CCDictionary.h"
#include <type_traits>
#include "base/ccUTF8.h"
#include "platform/CCFileUtils.h"
#include "deprecated/CCString.h"
#include "deprecated/CCBool.h"

View File

@ -272,30 +272,5 @@ __String* __String::clone() const
{
return __String::create(_string);
}
namespace StringUtils {
std::string format(const char* format, ...)
{
#define CC_MAX_STRING_LENGTH (1024*100)
std::string ret;
va_list ap;
va_start(ap, format);
char* buf = (char*)malloc(CC_MAX_STRING_LENGTH);
if (buf != nullptr)
{
vsnprintf(buf, CC_MAX_STRING_LENGTH, format, ap);
ret = buf;
free(buf);
}
va_end(ap);
return ret;
}
} // namespace StringUtils {
NS_CC_END

View File

@ -34,10 +34,13 @@ THE SOFTWARE.
#include <stdarg.h>
#include <string>
#include <functional>
#include <sstream>
#include "deprecated/CCArray.h"
#include "base/CCRef.h"
// We need to include `StringUtils::format()` and `StringUtils::toString()`
// for keeping the backward compatibility
#include "base/ccUTF8.h"
NS_CC_BEGIN
/**
@ -207,20 +210,6 @@ struct StringCompare : public std::binary_function<__String *, __String *, bool>
#define StringMake(str) String::create(str)
#define ccs StringMake
namespace StringUtils {
template<typename T>
std::string toString(T arg)
{
std::stringstream ss;
ss << arg;
return ss.str();
}
std::string CC_DLL format(const char* format, ...) CC_FORMAT_PRINTF(1, 2);
} // namespace StringUtils {
// end of data_structure group
/// @}

View File

@ -26,12 +26,12 @@
#include "base/ObjectFactory.h"
#include "base/CCDirector.h"
#include "base/ccUTF8.h"
#include "ui/CocosGUI.h"
#include "2d/CCSpriteFrameCache.h"
#include "2d/CCParticleSystemQuad.h"
#include "2d/CCTMXTiledMap.h"
#include "platform/CCFileUtils.h"
#include "deprecated/CCString.h"
#include "editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.h"
#include "editor-support/cocostudio/ActionTimeline/CCActionTimeline.h"

View File

@ -25,7 +25,7 @@
#include "network/CCDownloader-apple.h"
#include "network/CCDownloader.h"
#include "deprecated/CCString.h"
#include "base/ccUTF8.h"
#include <queue>
////////////////////////////////////////////////////////////////////////////////

View File

@ -29,7 +29,6 @@ THE SOFTWARE.
#include "platform/android/jni/JniHelper.h"
#include "platform/android/CCFileUtils-android.h"
#include "android/asset_manager_jni.h"
#include "deprecated/CCString.h"
#include "platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h"
#include "base/ccUTF8.h"

View File

@ -33,7 +33,6 @@ THE SOFTWARE.
#include <stack>
#include "base/CCDirector.h"
#include "deprecated/CCString.h"
#include "deprecated/CCDictionary.h"
#include "platform/CCFileUtils.h"
#include "platform/CCSAXParser.h"

View File

@ -37,7 +37,6 @@ THE SOFTWARE.
#include "base/ccUtils.h"
#include "base/ccUTF8.h"
#include "2d/CCCamera.h"
#include "deprecated/CCString.h"
NS_CC_BEGIN

View File

@ -30,7 +30,7 @@ THE SOFTWARE.
#include "platform/linux/CCApplication-linux.h"
#include "platform/CCCommon.h"
#include "base/ccMacros.h"
#include "deprecated/CCString.h"
#include "base/ccUTF8.h"
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>

View File

@ -33,12 +33,11 @@ THE SOFTWARE.
#endif
#include "base/CCDirector.h"
#include "base/ccUTF8.h"
#include "base/uthash.h"
#include "renderer/ccGLStateCache.h"
#include "platform/CCFileUtils.h"
#include "deprecated/CCString.h"
// helper functions
static void replaceDefines(const std::string& compileTimeDefines, std::string& out)

View File

@ -39,7 +39,6 @@ THE SOFTWARE.
#include "base/CCDirector.h"
#include "base/CCEventDispatcher.h"
#include "2d/CCCamera.h"
#include "deprecated/CCString.h"
NS_CC_BEGIN

View File

@ -39,6 +39,7 @@ THE SOFTWARE.
#include "platform/CCDevice.h"
#include "base/ccConfig.h"
#include "base/ccMacros.h"
#include "base/ccUTF8.h"
#include "base/CCConfiguration.h"
#include "platform/CCPlatformMacros.h"
#include "base/CCDirector.h"
@ -46,8 +47,6 @@ THE SOFTWARE.
#include "renderer/ccGLStateCache.h"
#include "renderer/CCGLProgramCache.h"
#include "base/CCNinePatchImageParser.h"
#include "deprecated/CCString.h"
#if CC_ENABLE_CACHE_TEXTURE_DATA
#include "renderer/CCTextureCache.h"

View File

@ -30,6 +30,7 @@ THE SOFTWARE.
#include <stdlib.h>
#include "base/ccMacros.h"
#include "base/ccUTF8.h"
#include "base/CCEventType.h"
#include "base/CCDirector.h"
#include "base/CCConfiguration.h"
@ -42,9 +43,6 @@ THE SOFTWARE.
#include "renderer/CCTexture2D.h"
#include "platform/CCGL.h"
#include "deprecated/CCString.h"
//According to some tests GL_TRIANGLE_STRIP is slower, MUCH slower. Probably I'm doing something very wrong
// implementation TextureAtlas

View File

@ -34,12 +34,11 @@ THE SOFTWARE.
#include "renderer/CCTexture2D.h"
#include "base/ccMacros.h"
#include "base/ccUTF8.h"
#include "base/CCDirector.h"
#include "base/CCScheduler.h"
#include "platform/CCFileUtils.h"
#include "base/ccUtils.h"
#include "deprecated/CCString.h"
#include "base/CCNinePatchImageParser.h"

View File

@ -23,7 +23,7 @@
#include "scripting/js-bindings/manual/network/jsb_websocket.h"
#include "deprecated/CCString.h"
#include "base/ccUTF8.h"
#include "network/WebSocket.h"
#include "platform/CCPlatformMacros.h"
#include "scripting/js-bindings/manual/ScriptingCore.h"

View File

@ -28,8 +28,8 @@
#include "ui/UIEditBox/UIEditBoxImpl-mac.h"
#include "base/CCDirector.h"
#include "base/ccUTF8.h"
#include "ui/UIEditBox/UIEditBox.h"
#include "deprecated/CCString.h"
#include "ui/UIEditBox/Mac/CCUIEditBoxMac.h"
NS_CC_BEGIN

View File

@ -23,7 +23,7 @@
****************************************************************************/
#include "AssetsManagerEx.h"
#include "CCEventListenerAssetsManagerEx.h"
#include "deprecated/CCString.h"
#include "base/ccUTF8.h"
#include "base/CCDirector.h"
#include <stdio.h>

View File

@ -25,7 +25,7 @@
#include "CCEventListenerAssetsManagerEx.h"
#include "CCEventAssetsManagerEx.h"
#include "AssetsManagerEx.h"
#include "deprecated/CCString.h"
#include "base/ccUTF8.h"
NS_CC_EXT_BEGIN