remove "using namespace" from header files

This commit is contained in:
honghui 2014-11-24 17:13:24 +08:00
parent 84a8c75ad5
commit 0e73301fc4
6 changed files with 43 additions and 38 deletions

View File

@ -29,6 +29,8 @@ THE SOFTWARE.
#include "VisibleRect.h"
#include "ResData.h"
using namespace cocos2d;
ConnectWaitLayer::ConnectWaitLayer()
{
int designWidth = 1280;
@ -76,7 +78,7 @@ ConnectWaitLayer::ConnectWaitLayer()
shineSprite->runAction(RepeatForever::create(Sequence::create(arrayOfActions)));
addChild(shineSprite, 9998);
string strip = getIPAddress();
std::string strip = getIPAddress();
char szIPAddress[64] = {0};
sprintf(szIPAddress, "IP: %s", strip.c_str());
auto IPlabel = Label::createWithSystemFont(szIPAddress, "", 72);
@ -86,7 +88,7 @@ ConnectWaitLayer::ConnectWaitLayer()
IPlabel->setPosition(Point(VisibleRect::leftTop().x + spaceSizex, VisibleRect::top().y - spaceSizey));
addChild(IPlabel, 9001);
string transferTip = "waiting for file transfer ...";
std::string transferTip = "waiting for file transfer ...";
if (CC_PLATFORM_WIN32 == CC_TARGET_PLATFORM || CC_PLATFORM_MAC == CC_TARGET_PLATFORM)
{
transferTip = "waiting for debugger to connect ...";
@ -142,7 +144,7 @@ ConnectWaitLayer::ConnectWaitLayer()
// clean up: ignore stdin, stdout and stderr
void ConnectWaitLayer::update(float fDelta)
{
string transferTip = FileServer::getShareInstance()->getTransingFileName();
std::string transferTip = FileServer::getShareInstance()->getTransingFileName();
if (transferTip.empty()){
return;
}

View File

@ -27,16 +27,14 @@ THE SOFTWARE.
#include "cocos2d.h"
using namespace cocos2d;
class ConnectWaitLayer: public Layer
class ConnectWaitLayer: public cocos2d::Layer
{
public:
ConnectWaitLayer();
void update(float fDelta);
private:
Label* _labelUploadFile;
cocos2d::Label* _labelUploadFile;
};
#endif // _CONNECT_WAIT_LAYER__H_

View File

@ -33,6 +33,8 @@ THE SOFTWARE.
#include <sys/stat.h>
#endif
USING_NS_CC;
//1M size
#define MAXPROTOLENGTH 1048576
@ -41,7 +43,7 @@ THE SOFTWARE.
FileServer* FileServer::s_sharedFileServer = nullptr;
void FileServer::readResFileFinfo()
{
string filecfg = _writePath + "/fileinfo_debug.json";
std::string filecfg = _writePath + "/fileinfo_debug.json";
FILE * pFile = fopen (filecfg.c_str() , "r");
if(pFile)
{
@ -59,7 +61,7 @@ void FileServer::readResFileFinfo()
rapidjson::Writer< rapidjson::StringBuffer > writer(buffer);
_filecfgjson.Accept(writer);
const char* str = buffer.GetString();
string filecfg = _writePath + "/fileinfo_debug.json";
std::string filecfg = _writePath + "/fileinfo_debug.json";
FILE * pFile = fopen(filecfg.c_str(), "w");
if (!pFile) return ;
fwrite(str, sizeof(char), strlen(str), pFile);
@ -88,15 +90,15 @@ void FileServer::removeResFileInfo(const char *filename)
}
}
string FileServer::getTransingFileName()
std::string FileServer::getTransingFileName()
{
_fileNameMutex.lock();
string filename = _strFileName;
std::string filename = _strFileName;
_fileNameMutex.unlock();
return filename;
}
void FileServer::setTransingFileName(const string &filename)
void FileServer::setTransingFileName(const std::string &filename)
{
_fileNameMutex.lock();
_strFileName = filename;
@ -139,7 +141,12 @@ bool FileServer::listenOnTCP(int port)
if (::bind(listenfd, res->ai_addr, res->ai_addrlen) == 0)
break; /* success */
close(listenfd); /* bind error, close and try next one */
/* bind error, close and try next one */
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
closesocket(listenfd);
#else
close(listenfd);
#endif
} while ((res = res->ai_next) != NULL);
if (res == NULL)
@ -340,8 +347,8 @@ void FileServer::loopWriteFile()
RecvBufStruct recvDataBuf = _recvBufList.front();
_recvBufList.pop_front();
_recvBufListMutex.unlock();
string filename = recvDataBuf.fileProto.file_name();
string fullfilename = _writePath;
std::string filename = recvDataBuf.fileProto.file_name();
std::string fullfilename = _writePath;
fullfilename += filename;
_fileNameMutex.lock();
_strFileName = filename;
@ -387,7 +394,7 @@ void FileServer::loopWriteFile()
}
}
void FileServer::addResponse(int fd, string filename, int errortype, int errornum)
void FileServer::addResponse(int fd, std::string filename, int errortype, int errornum)
{
switch (errortype)
{
@ -433,7 +440,7 @@ void FileServer::loopResponse()
_responseBufList.pop_front();
_responseBufListMutex.unlock();
//send response
string responseString;
std::string responseString;
runtime::FileSendComplete fileSendProtoComplete;
fileSendProtoComplete.set_file_name(responseBuf.fileResponseProto.file_name());
fileSendProtoComplete.set_result(responseBuf.fileResponseProto.result());
@ -474,11 +481,13 @@ bool createDir(const char *sPathName)
if(DirName[i] == '/')
{
DirName[i] = 0;
if(access(DirName, NULL) != 0)
{
#ifdef _WIN32
if(_access(DirName, NULL) != 0)
{
if(_mkdir(DirName/*, 0755*/) == -1)
#else
if (access(DirName, NULL) != 0)
{
if(mkdir(DirName, 0755) == -1)
#endif
{

View File

@ -33,9 +33,6 @@ THE SOFTWARE.
#include "Protos.pb.h"
#include <string>
using namespace std;
using namespace cocos2d;
// header files for socket
#ifdef _WIN32
#include <io.h>
@ -75,9 +72,9 @@ public:
void addResFileInfo(const char* filename,uint64_t u64);
void removeResFileInfo(const char *filename);
rapidjson::Document* getFileCfgJson() { return &_filecfgjson; }
string getWritePath() { return _writePath; }
string getTransingFileName();
void setTransingFileName(const string& filename);
std::string getWritePath() { return _writePath; }
std::string getTransingFileName();
void setTransingFileName(const std::string& filename);
protected:
FileServer();
~FileServer();
@ -85,7 +82,7 @@ private:
void loopReceiveFile();
void loopWriteFile();
void loopResponse();
void addResponse(int fd, string filename,int errortype,int errornum);
void addResponse(int fd, std::string filename,int errortype,int errornum);
enum PROTONUM
{
FILEPROTO = 1,
@ -126,13 +123,13 @@ private:
rapidjson::Document _filecfgjson;
string _strFileName;
std::string _strFileName;
std::mutex _fileNameMutex;
string _recvErrorFile;
string _writeErrorFile;
std::string _recvErrorFile;
std::string _writeErrorFile;
string _writePath;
std::string _writePath;
};
bool createDir(const char *sPathName);

View File

@ -36,7 +36,7 @@ THE SOFTWARE.
static std::string g_projectPath;
void startScript(string strDebugArg)
void startScript(std::string strDebugArg)
{
// register lua engine
auto engine = LuaEngine::getInstance();
@ -81,13 +81,13 @@ void sendBuf(int fd, const char *pbuf, unsigned long bufsize)
}
}
string& replaceAll(string& str, const string& old_value, const string& new_value)
std::string& replaceAll(std::string& str, const std::string& old_value, const std::string& new_value)
{
size_t start = 0;
while(true)
{
size_t pos = 0;
if((pos = str.find(old_value, start)) != string::npos) {
if((pos = str.find(old_value, start)) != std::string::npos) {
str.replace(pos, old_value.length(), new_value);
start = pos + new_value.length();
}

View File

@ -26,19 +26,18 @@ THE SOFTWARE.
#define _RUNTIME__H_
#include <string>
using namespace std;
void recvBuf(int fd, char *pbuf, unsigned long bufsize);
void sendBuf(int fd, const char *pbuf, unsigned long bufsize);
string& replaceAll(string& str, const string& old_value, const string& new_value);
std::string& replaceAll(std::string& str, const std::string& old_value, const std::string& new_value);
string getIPAddress();
std::string getIPAddress();
const char* getRuntimeVersion();
void startScript(string strDebugArg);
void startScript(std::string strDebugArg);
void initRuntime();