Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cocos/2d/CCFontAtlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,9 @@ std::string FontAtlas::getFontName() const
{
std::string fontName = _fontFreeType ? _fontFreeType->getFontName() : "";
if(fontName.empty()) return fontName;
auto idx = fontName.rfind("/");
auto idx = fontName.rfind('/');
if (idx != std::string::npos) { return fontName.substr(idx + 1); }
idx = fontName.rfind("\\");
idx = fontName.rfind('\\');
if (idx != std::string::npos) { return fontName.substr(idx + 1); }
return fontName;
}
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/CCFontCharMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ NS_CC_BEGIN
FontCharMap * FontCharMap::create(const std::string& plistFile)
{
std::string pathStr = FileUtils::getInstance()->fullPathForFilename(plistFile);
std::string relPathStr = pathStr.substr(0, pathStr.find_last_of("/"))+"/";
std::string relPathStr = pathStr.substr(0, pathStr.find_last_of('/'))+"/";

ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(pathStr);

Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/CCLabelAtlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ LabelAtlas* LabelAtlas::create(const std::string& string, const std::string& fnt
bool LabelAtlas::initWithString(const std::string& theString, const std::string& fntFile)
{
std::string pathStr = FileUtils::getInstance()->fullPathForFilename(fntFile);
std::string relPathStr = pathStr.substr(0, pathStr.find_last_of("/"))+"/";
std::string relPathStr = pathStr.substr(0, pathStr.find_last_of('/'))+"/";

ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(pathStr);

Expand Down
4 changes: 2 additions & 2 deletions cocos/2d/CCSpriteFrameCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist)
texturePath = plist;

// remove .xxx
size_t startPos = texturePath.find_last_of(".");
size_t startPos = texturePath.find_last_of('.');
texturePath = texturePath.erase(startPos);

// append .png
Expand Down Expand Up @@ -712,7 +712,7 @@ bool SpriteFrameCache::reloadTexture(const std::string& plist)
texturePath = plist;

// remove .xxx
size_t startPos = texturePath.find_last_of(".");
size_t startPos = texturePath.find_last_of('.');
texturePath = texturePath.erase(startPos);

// append .png
Expand Down
10 changes: 5 additions & 5 deletions cocos/2d/CCTMXXMLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts
_externalTilesetFilename = externalTilesetFilename;

// Tileset file will be relative to the map file. So we need to convert it to an absolute path
if (_TMXFileName.find_last_of("/") != string::npos)
if (_TMXFileName.find_last_of('/') != string::npos)
{
string dir = _TMXFileName.substr(0, _TMXFileName.find_last_of("/") + 1);
string dir = _TMXFileName.substr(0, _TMXFileName.find_last_of('/') + 1);
externalTilesetFilename = dir + externalTilesetFilename;
}
else
Expand Down Expand Up @@ -434,12 +434,12 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char *name, const char **atts

if (!_externalTilesetFullPath.empty())
{
string dir = _externalTilesetFullPath.substr(0, _externalTilesetFullPath.find_last_of("/") + 1);
string dir = _externalTilesetFullPath.substr(0, _externalTilesetFullPath.find_last_of('/') + 1);
tileset->_sourceImage = dir + imagename;
}
else if (_TMXFileName.find_last_of("/") != string::npos)
else if (_TMXFileName.find_last_of('/') != string::npos)
{
string dir = _TMXFileName.substr(0, _TMXFileName.find_last_of("/") + 1);
string dir = _TMXFileName.substr(0, _TMXFileName.find_last_of('/') + 1);
tileset->_sourceImage = dir + imagename;
}
else
Expand Down
2 changes: 1 addition & 1 deletion cocos/3d/CCBundle3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas, MaterialDatas& materialdatas, NodeD
int i = 0;
char str[20];
std::string dir = "";
auto last = fullPath.rfind("/");
auto last = fullPath.rfind('/');
if (last != std::string::npos)
dir = fullPath.substr(0, last + 1);
for (auto& material : materials) {
Expand Down
2 changes: 1 addition & 1 deletion cocos/base/CCConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ void Console::Command::commandGeneric(int fd, const std::string& args)
{
// The first argument (including the empty)
std::string key(args);
auto pos = args.find(" ");
auto pos = args.find(' ');
if ((pos != std::string::npos) && (0 < pos)) {
key = args.substr(0, pos);
}
Expand Down
4 changes: 2 additions & 2 deletions cocos/base/CCProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,12 +1117,12 @@ void calculateNamespacePath(const std::string& urlString, std::string& fileStrin
{
// If the url references a specific namespace within the file,
// calculate the full namespace path to the final namespace.
size_t loc = urlString.rfind("#");
size_t loc = urlString.rfind('#');
if (loc != std::string::npos)
{
fileString = urlString.substr(0, loc);
std::string namespacePathString = urlString.substr(loc + 1);
while ((loc = namespacePathString.find("/")) != std::string::npos)
while ((loc = namespacePathString.find('/')) != std::string::npos)
{
namespacePath.push_back(namespacePathString.substr(0, loc));
namespacePathString = namespacePathString.substr(loc + 1);
Expand Down
2 changes: 1 addition & 1 deletion cocos/base/ZipUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ std::vector<std::string> ZipFile::listFiles(const std::string &pathname) const
if(filename.substr(0, dirname.length()) == dirname)
{
std::string suffix = filename.substr(dirname.length());
auto pos = suffix.find("/");
auto pos = suffix.find('/');
if (pos == std::string::npos)
{
fileSet.insert(suffix);
Expand Down
2 changes: 1 addition & 1 deletion cocos/base/ccUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void onCaptureScreen(const std::function<void(bool, const std::string&)>& afterC
}
else
{
CCASSERT(filename.find("/") == std::string::npos, "The existence of a relative path is not guaranteed!");
CCASSERT(filename.find('/') == std::string::npos, "The existence of a relative path is not guaranteed!");
outputFile = FileUtils::getInstance()->getWritablePath() + filename;
}

Expand Down
4 changes: 2 additions & 2 deletions cocos/editor-support/cocosbuilder/CCBReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ bool CCBReader::readSequences()

std::string CCBReader::lastPathComponent(const char* pPath) {
std::string path(pPath);
size_t slashPos = path.find_last_of("/");
size_t slashPos = path.find_last_of('/');
if(slashPos != std::string::npos) {
return path.substr(slashPos + 1, path.length() - slashPos);
}
Expand All @@ -960,7 +960,7 @@ std::string CCBReader::lastPathComponent(const char* pPath) {

std::string CCBReader::deletePathExtension(const char* pPath) {
std::string path(pPath);
size_t dotPos = path.find_last_of(".");
size_t dotPos = path.find_last_of('.');
if(dotPos != std::string::npos) {
return path.substr(0, dotPos);
}
Expand Down
6 changes: 3 additions & 3 deletions cocos/editor-support/cocostudio/CCActionManagerEx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::V
{
std::string path = jsonName;
this->_studioVersionNumber = version;
ssize_t pos = path.find_last_of("/");
ssize_t pos = path.find_last_of('/');
std::string fileName = path.substr(pos+1,path.length());
cocos2d::Vector<ActionObject*> actionList;
int actionCount = DICTOOL->getArrayCount_json(dic, "actionlist");
Expand All @@ -83,7 +83,7 @@ void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::V
stExpCocoNode* pCocoNode)
{
std::string path = file;
ssize_t pos = path.find_last_of("/");
ssize_t pos = path.find_last_of('/');
std::string fileName = path.substr(pos+1,path.length());
cocos2d::Vector<ActionObject*> actionList;

Expand Down Expand Up @@ -116,7 +116,7 @@ void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::V
ActionObject* ActionManagerEx::getActionByName(const char* jsonName,const char* actionName)
{
std::string path = jsonName;
ssize_t pos = path.find_last_of("/");
ssize_t pos = path.find_last_of('/');
std::string fileName = path.substr(pos+1,path.length());
auto iterator = _actionDic.find(fileName);
if (iterator == _actionDic.end())
Expand Down
8 changes: 4 additions & 4 deletions cocos/editor-support/cocostudio/CCDataReaderHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ void DataReaderHelper::addDataFromFile(const std::string& filePath)

//! find the base file path
std::string basefilePath = filePath;
size_t pos = basefilePath.find_last_of("/");
size_t pos = basefilePath.find_last_of('/');

if (pos != std::string::npos)
{
Expand Down Expand Up @@ -362,7 +362,7 @@ void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const

//! find the base file path
std::string basefilePath = filePath;
size_t pos = basefilePath.find_last_of("/");
size_t pos = basefilePath.find_last_of('/');

if (pos != std::string::npos)
{
Expand Down Expand Up @@ -1305,7 +1305,7 @@ void DataReaderHelper::addDataFromJsonCache(const std::string& fileContent, Data
}

std::string filePath = path;
filePath = filePath.erase(filePath.find_last_of("."));
filePath = filePath.erase(filePath.find_last_of('.'));

if (dataInfo->asyncStruct)
{
Expand Down Expand Up @@ -1844,7 +1844,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
}

std::string filePath = path;
filePath = filePath.erase(filePath.find_last_of("."));
filePath = filePath.erase(filePath.find_last_of('.'));

if (dataInfo->asyncStruct)
{
Expand Down
2 changes: 1 addition & 1 deletion cocos/editor-support/cocostudio/CCDatas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ std::string DisplayData::changeDisplayToTexture(const std::string& displayName)
{
// remove .xxx
std::string textureName = displayName;
size_t startPos = textureName.find_last_of(".");
size_t startPos = textureName.find_last_of('.');

if(startPos != std::string::npos)
{
Expand Down
4 changes: 2 additions & 2 deletions cocos/editor-support/cocostudio/CCDisplayFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void DisplayFactory::createSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisp
SpriteDisplayData *displayData = (SpriteDisplayData *)decoDisplay->getDisplayData();

std::string textureName = displayData->displayName;
size_t startPos = textureName.find_last_of(".");
size_t startPos = textureName.find_last_of('.');

if(startPos != std::string::npos)
{
Expand Down Expand Up @@ -191,7 +191,7 @@ void DisplayFactory::initSpriteDisplay(Bone *bone, DecorativeDisplay *decoDispla
{
//! remove .xxx
std::string textureName = displayName;
size_t startPos = textureName.find_last_of(".");
size_t startPos = textureName.find_last_of('.');

if(startPos != std::string::npos)
{
Expand Down
8 changes: 4 additions & 4 deletions cocos/editor-support/cocostudio/CCSGUIReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,19 @@ int GUIReader::getVersionInteger(const char *str)
{
return 0;
}
size_t pos = strVersion.find_first_of(".");
size_t pos = strVersion.find_first_of('.');
std::string t = strVersion.substr(0,pos);
strVersion = strVersion.substr(pos+1,strVersion.length()-1);

pos = strVersion.find_first_of(".");
pos = strVersion.find_first_of('.');
std::string h = strVersion.substr(0,pos);
strVersion = strVersion.substr(pos+1,strVersion.length()-1);

pos = strVersion.find_first_of(".");
pos = strVersion.find_first_of('.');
std::string te = strVersion.substr(0,pos);
strVersion = strVersion.substr(pos+1,strVersion.length()-1);

pos = strVersion.find_first_of(".");
pos = strVersion.find_first_of('.');
std::string s = strVersion.substr(0,pos);

int it = atoi(t.c_str());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void ArmatureNodeReader::setPropsWithFlatBuffers(cocos2d::Node *node,

std::string fullpath = FileUtils::getInstance()->fullPathForFilename(filepath);

std::string dirpath = fullpath.substr(0, fullpath.find_last_of("/"));
std::string dirpath = fullpath.substr(0, fullpath.find_last_of('/'));
FileUtils::getInstance()->addSearchPath(dirpath);

ArmatureDataManager::getInstance()->addArmatureFileInfo(fullpath);
Expand Down Expand Up @@ -201,9 +201,9 @@ cocos2d::Node* ArmatureNodeReader::createNodeWithFlatBuffers(const flatbuffers:
std::string ArmatureNodeReader::getArmatureName(const std::string& exporJsonPath)
{
//FileUtils.getFileData(exporJsonPath, "r", size) // need read armature name in exportJsonPath
size_t end = exporJsonPath.find_last_of(".");
size_t start = exporJsonPath.find_last_of("\\") + 1;
size_t start1 = exporJsonPath.find_last_of("/") + 1;
size_t end = exporJsonPath.find_last_of('.');
size_t start = exporJsonPath.find_last_of('\\') + 1;
size_t start1 = exporJsonPath.find_last_of('/') + 1;
if (start < start1)
start = start1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ namespace cocostudio
{
ILocalizationManager* lm = LocalizationHelper::getCurrentManager();
std::string localizedTxt = lm->getLocalizationString(text);
std::string::size_type newlineIndex = localizedTxt.find("\n");
std::string::size_type newlineIndex = localizedTxt.find('\n');
if (newlineIndex != std::string::npos)
localizedTxt = localizedTxt.substr(0, newlineIndex);
textField->setString(localizedTxt);
Expand Down
Loading