当前位置: 首页>>代码示例>>C++>>正文


C++ CString::Get方法代码示例

本文整理汇总了C++中CString::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ CString::Get方法的具体用法?C++ CString::Get怎么用?C++ CString::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CString的用法示例。


在下文中一共展示了CString::Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ProcessInput

void CInput::ProcessInput(CString strInput)
{
	// Get the command and parameters
	size_t sSplit = strInput.Find(' ', 0);
	CString strCommand = strInput.Substring(0, sSplit++);
	CString strParameters = strInput.Substring(sSplit, (strInput.GetLength() - sSplit));

	if(strCommand.IsEmpty())
		return;
	else if(strCommand == "quit" || strCommand == "Quit" || strCommand == "exit") {
		CLogFile::Print("[Server] Server is going to shutdown NOW ....");
		g_bClose = true;
		return;

	} else if(strCommand == "help" || strCommand == "?" || strCommand == "--usage") {
		printf("========== Available console commands: ==========\n");
		printf("say <text>\n");
		printf("uptime\n");
		printf("resources\n");
		printf("players\n");
		printf("loadresource <name>\n");
		printf("reloadresource <name>\n");
		printf("unloadresource <name>\n");
		printf("exit\n");
		return;
	}
	else if (strCommand == "setSyncRate") {
		int rate = atoi(strParameters.Get());
		CServer::GetInstance()->SetSyncRate(rate);
	}
	else if (strCommand == "setMaxFPS") {
		int fps = atoi(strParameters.Get());
		CServer::GetInstance()->SetMaximumFPS(fps);
	}
}
开发者ID:MartinJK,项目名称:IVNetwork,代码行数:35,代码来源:CInput.cpp

示例2: ParseCommandLine

void CSettings::ParseCommandLine(char * szCommandLine)
{
	// Loop until we reach the end of the command line CString
	while(*szCommandLine)
	{
		// Is the current char not a space?
		if(!isspace(*szCommandLine))
		{
			// Is the current char a '-'?
			if(*szCommandLine == '-')
			{
				// Skip the '-'
				szCommandLine++;

				// Collect the setting CString
				CString strSetting;

				while(*szCommandLine && !isspace(*szCommandLine))
				{
					strSetting += *szCommandLine;
					szCommandLine++;
				}

				// If we have run out of command line to process break out of the loop
				if(!(*szCommandLine))
					break;

				// Skip the spaces between the option and the value
				while(*szCommandLine && isspace(*szCommandLine))
					szCommandLine++;

				// If we have run out of command line to process break out of the loop
				if(!(*szCommandLine))
					break;

				// Collect the value CString
				CString strValue;

				while(*szCommandLine && !isspace(*szCommandLine))
				{
					strValue += *szCommandLine;
					szCommandLine++;
				}

				// Set the setting and value
				if(!SetEx(strSetting, strValue))
					CLogFile::Printf("WARNING: Command line setting %s does not exist.", strSetting.Get());

				CLogFile::Printf("argv/argc command line: setting %s value %s", strSetting.Get(), strValue.Get());

				// If we have run out of command line to process break out of the loop
				if(!(*szCommandLine))
					break;
			}
		}

		// Increment the command line string pointer
		szCommandLine++;
	}
}
开发者ID:Rukenshia,项目名称:IV-Network,代码行数:60,代码来源:CSettings.cpp

示例3: CheckAccess

rc_t CKDirectory::CheckAccess(const CString &path,
    bool &updated, bool isPrivate, bool verbose) const
{
    updated = false;
    const String *str = path.Get();
    if (str == NULL) {
        return 0;
    }
    uint32_t access = 0;
    if (verbose) {
        OUTMSG(("checking %S file mode... ", path.Get()));
    }
    rc_t rc = KDirectoryAccess(m_Self, &access, str->addr);
    if (rc != 0) {
        OUTMSG(("failed\n"));
    }
    else {
        if (verbose) {
            OUTMSG(("%o\n", access));
        }
        if (isPrivate) {
            if (access != m_PrivateAccess) {
                uint32_t access = 0777;
                if (verbose) {
                    OUTMSG(("updating %S to %o... ", str, access));
                }
                rc = KDirectorySetAccess(m_Self, false,
                    m_PrivateAccess, access, str->addr);
                if (rc == 0) {
                    OUTMSG(("ok\n"));
                    updated = true;
                }
                else {
                    OUTMSG(("failed\n"));
                }
            }
        }
        else {
            if ((access & m_PrivateAccess) != m_PrivateAccess) {
                uint32_t access = 0700;
                if (verbose) {
                    OUTMSG(("updating %S to %o... ", str, access));
                }
                rc = KDirectorySetAccess(m_Self, false,
                    m_PrivateAccess, access, str->addr);
                if (rc == 0) {
                    OUTMSG(("ok\n"));
                    updated = true;
                }
                else {
                    OUTMSG(("failed\n"));
                }
            }
        }
    }
    return rc;
}
开发者ID:ncbi,项目名称:sra-tools,代码行数:57,代码来源:util.cpp

示例4: LoadScript

bool CSquirrel::LoadScript(CString script)
{
	CString scriptPath( "%s/%s", m_pResource->GetPath().Get(), script.Get());
	if(SQ_FAILED(sqstd_dofile( m_pVM, scriptPath.Get(), SQFalse, SQTrue )))
	{
		CLogFile::Printf("[%s] Failed to load file %s.", m_pResource->GetName().Get(), script.Get());
		return false;
	}
	CLogFile::Printf("\t[%s] Loaded file %s.", m_pResource->GetName().Get(), script.Get());
	return true;
}
开发者ID:B2O,项目名称:IV-Network,代码行数:11,代码来源:CSquirrel.cpp

示例5: Connect

void CNetworkManager::Connect(CString strHost, unsigned short usPort, CString strPass)
{
	// Are we already connected?
	if(IsConnected())
	{
		// Disconnect
		Disconnect();
	}

	// Store the connection info
	SetLastConnection(strHost, usPort, strPass);

	// Attempt to connect
	int iConnectionResult = m_pRakPeer->Connect(strHost.Get(), usPort, strPass.Get(), strPass.GetLength());

	// Set the network state
	SetNetworkState(NETSTATE_CONNECTING);

	// Create the string for the connection message
	CString strMessage("Failed to connected!");

	// Get the result from the connection
	switch(iConnectionResult)
	{
		case 0: strMessage.Format("Connecting to %s:%d...", strHost.Get(), usPort); break;
		case 1: strMessage.Set("Failed to connect! (Invalid parameter)"); break;
		case 2: strMessage.Set("Failed to connect! (Cannot resolve domain name)"); break;
		case 3: strMessage.Set("Failed to connect! (Already connected)"); break;
		case 4: strMessage.Set("Failed to connect! (Connection attempt already in progress)"); break;
		case 5: strMessage.Set("Failed to connect! (Security initialization failed)"); break;
		case 6: strMessage.Set("Failed to connect! (No host set)"); break;
	}

	// Did we fail to connect?
	if(iConnectionResult != 0)
	{
		// Set the network state
		SetNetworkState(NETSTATE_DISCONNECTED);

		// Set the last connection try
		m_uiLastConnectionTry = (unsigned int)SharedUtility::GetTime();
	}

	CGUI* pGUI = g_pCore->GetGUI();
	if (pGUI)
	{
		//pGUI->ClearView(CGUI::GUI_SERVER);
		//pGUI->SetView(CGUI::GUI_SERVER);
	}

	// Output the connection message
	g_pCore->GetChat()->Outputf(true, "#16C5F2%s", strMessage.Get());
}
开发者ID:Rukenshia,项目名称:IV-Network,代码行数:53,代码来源:CNetworkManager.cpp

示例6: LoadScript

bool CSquirrelVM::LoadScript(CString script)
{
		
	CString scriptPath( "%s/%s", GetResource()->GetResourceDirectoryPath().Get(), script.Get());
	
	if(!SharedUtility::Exists(script.Get()) && SQ_FAILED(sqstd_dofile( m_pVM, scriptPath.Get(), SQFalse, SQTrue )))
	{
		CLogFile::Printf("[%s] Failed to load file %s.", GetResource()->GetName().Get(), script.Get());
		return false;
	}
	CLogFile::Printf("\t[%s] Loaded file %s.", GetResource()->GetName().Get(), script.Get());
	return true;
}
开发者ID:RAG20,项目名称:IV-Network,代码行数:13,代码来源:CSquirrelVM.cpp

示例7: Post

bool CHttpClient::Post(bool bHasResponse, CString strPath, CString strData, CString strContentType)
{
    // Connect to the host
    if (!Connect())
    {
        // Connect failed
        return false;
    }

    // Reset the header and data
    m_headerMap.clear();
    m_strData.Clear();

    // Prepare the POST command
    CString strGet("POST %s HTTP/1.0\r\n" \
                   "Host: %s\r\n" \
                   "User-Agent: %s\r\n\r\n" \
                   "Referer: %s\r\n" \
                   "Content-Type: %s\r\n" \
                   "Content-Length: %d\r\n" \
                   "Connection: close\r\n" \
                   "\r\n" \
                   "%s",
                   strPath.Get(), m_strHost.Get(), m_strUserAgent.Get(),
                   m_strReferer.Get(), strContentType.Get(), strData.GetLength(),
                   strData.Get());

    // Send the POST command
    if (!Write(strGet.C_String(), strGet.GetLength()))
    {
        // Send failed
        return false;
    }

    // Do we have a response
    if (bHasResponse)
    {
        // Set the status to get data
        m_status = HTTP_STATUS_GET_DATA;

        // Set the request start
        m_uiRequestStart = SharedUtility::GetTime();
    }
    else
    {
        // Disconnect from the host
        Disconnect();
    }

    return true;
}
开发者ID:Rukenshia,项目名称:IV-Network,代码行数:51,代码来源:CHttpClient.cpp

示例8:

const char *getValue<const char *>(CScriptVM* pVM, int idx)
{
	CString str;
	pVM->SetStackIndex(idx - (pVM->GetVMType() == LUA_VM ? 0 : 1));
	pVM->Pop(str);
	return str.Get();
}
开发者ID:andrefsantos,项目名称:IVMultiplayer-1,代码行数:7,代码来源:ApplyTuple.cpp

示例9: Startup

bool CNetworkModule::Startup(void)
{
	// Create the socket descriptor
	RakNet::SocketDescriptor socketDescriptor(CVAR_GET_INTEGER("port"), CVAR_GET_STRING("hostaddress").Get());

	// Attempt to startup raknet
	bool bReturn = (m_pRakPeer->Startup(CVAR_GET_INTEGER("maxplayers"), &socketDescriptor, 1, 0) == RakNet::RAKNET_STARTED);

	// Did it start?
	if(bReturn)
	{
		// Set the maximum incoming connections
		m_pRakPeer->SetMaximumIncomingConnections(CVAR_GET_INTEGER("maxplayers"));

		// Get the password string
		CString strPassword = CVAR_GET_STRING("password");

		// Do we have a password?
		if(strPassword.GetLength() > 0)
		{
			// Set the server password
			m_pRakPeer->SetIncomingPassword(strPassword.Get(), strPassword.GetLength());
		}
	}

	// Return
	return bReturn;
}
开发者ID:balika011,项目名称:IVMultiplayer,代码行数:28,代码来源:CNetworkModule.cpp

示例10: CException

//----------------------------------------------------------------------------------------------------------------------------------------
// constructor
//----------------------------------------------------------------------------------------------------------------------------------------
CSocketServer::CSocketServer (const CString &inFile, const CSocketServerListener *inListener)
	      :CSocket	     (inFile, inListener),
	       m_ListenTh    (::pthread_self()),
	       m_File	     (inFile)
{
	// when we try to write on a closed socket, the SIGPIPE signal is emitted and the process exists returing EPIPE... It is not
	// sended if the flag MSG_NOSIGNAL was specified when sending the data over the socket. As this definition stands for SSL too
	// and as I did not find any bypassing in the ssl api, just overwritte the default system behaviour and keep on listening
	// if such an event occurs...
	struct sigaction sa; sa.sa_handler = ::DummySigPipe; sa.sa_flags = SA_NOCLDSTOP; ::sigaction (SIGPIPE, &sa, NULL);

        // bind the address to the local socket, remove it before if any and be sure to chmod it...
	if (m_File != CString()) ::remove (m_File.Get());
        if (::bind (m_Desc, m_SockAddr, sizeof(struct sockaddr_un)) < 0)
                throw new CException ("could\'t bind to \"" + inFile + "\"");
	::chmod (inFile.Get(), S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH);

        // prepare socket to listen for connections
        if (::listen (m_Desc, SOMAXCONN) < 0)
                throw new CException ("couldn\'t listen on \"" + inFile + "\"");

	// try to create our listener thread
	int res; if ((inListener != NULL) && ((res = ::pthread_create (&m_ListenTh, NULL, CSocketServer::m_ListenCallBack, this)) != 0))
                throw new CException ("couldn\'t create pthread");
}
开发者ID:EyesOfNetworkCommunity,项目名称:ged,代码行数:28,代码来源:csocketserver.c

示例11: if

//----------------------------------------------------------------------------------------------------------------------------------------
// constructor
//----------------------------------------------------------------------------------------------------------------------------------------
CSocketServer::CSocketServer (const CString &inAddress, const UInt16 inPort, const CSocketServerListener *inListener)
	      :CSocket	     (inAddress, inPort, inListener),
	       m_ListenTh    (::pthread_self())
{
	// when we try to write on a closed socket, the SIGPIPE signal is emitted and the process exists returing EPIPE... It is not
	// sended if the flag MSG_NOSIGNAL was specified when sending the data over the socket. As this definition stands for SSL too
	// and as I did not find any bypassing in the ssl api, just overwritte the default system behaviour and keep on listening
	// if such an event occurs...
	struct sigaction sa; sa.sa_handler = ::DummySigPipe; sa.sa_flags = SA_NOCLDSTOP; ::sigaction (SIGPIPE, &sa, NULL);

	// what address should we bind to ?
	if (inAddress == CString())
		((struct sockaddr_in*)m_SockAddr)->sin_addr.s_addr = INADDR_ANY;
	else if (!::inet_aton (inAddress.Get(), &((struct sockaddr_in*)m_SockAddr)->sin_addr))
		throw new CException ("invalid address \"" + inAddress + "\"");

	// set the reuse address flag so we don't get errors if restarting and keep socket alive
	int flag=1; ::setsockopt (m_Desc, SOL_SOCKET, SO_REUSEADDR, (char*)&flag, sizeof(int));

        // bind the address to the Internet socket
        if (::bind (m_Desc, m_SockAddr, sizeof(struct sockaddr_in)) < 0)
                throw new CException ("could\'t bind to \"" + inAddress + "\"");

        // prepare socket to listen for connections
        if (::listen (m_Desc, SOMAXCONN) < 0)
                throw new CException ("couldn\'t listen on \"" + inAddress + "\"");

	// try to create our listener thread
	int res; if ((inListener != NULL) && ((res = ::pthread_create (&m_ListenTh, NULL, CSocketServer::m_ListenCallBack, this)) != 0))
                throw new CException ("couldn\'t create pthread");
}
开发者ID:EyesOfNetworkCommunity,项目名称:ged,代码行数:34,代码来源:csocketserver.c

示例12: UpdateUserRepositoryRootPath

rc_t CKConfig::UpdateUserRepositoryRootPath(const CString &path) {
    const String *str = path.Get();

    if (str == NULL) {
        return 0;
    }
    return UpdateUserRepositoryRootPath(str->addr, str->size);
}
开发者ID:ncbi,项目名称:sra-tools,代码行数:8,代码来源:util.cpp

示例13: Exists

bool CKDirectory::Exists(const CString &path) const {
    const String *str = path.Get();

    if (str == NULL) {
        return false;
    }
    return Exists(str->addr);
}
开发者ID:ncbi,项目名称:sra-tools,代码行数:8,代码来源:util.cpp

示例14: strModulePath

CModule::CModule(CString strName)
{
	// Remove any illegal characters from the module name
	SharedUtility::RemoveIllegalCharacters(strName);

	// Get the module path string
	CString strModulePath(SharedUtility::GetAbsolutePath("multiplayer/modules/%s", strName.Get()));

	// Replace '/' with '\\'
	strModulePath.Substitute("/", "\\");

	// Create the libray instance
	m_pLibrary = new CLibrary();

	// Is the library instance invalid?
	if(!m_pLibrary)
		return;

	// Did the module fail to load?
	if(!m_pLibrary->Load(strModulePath.Get()))
	{
		// Delete the library instance
		SAFE_DELETE(m_pLibrary);

		return;
	}

	// Assign module name
	m_strName = strName;

	// Get the module function pointers
	m_moduleFunctions.pfnSetupFunctions = (SetupFunctions_t)m_pLibrary->GetProcedureAddress("SetupFunctions");
	m_moduleFunctions.pfnSetupInterfaces = (SetupInterfaces_t)m_pLibrary->GetProcedureAddress("SetupInterfaces");
	m_moduleFunctions.pfnSetupNewInterfaces = (SetupNewInterfaces_t)m_pLibrary->GetProcedureAddress("SetupNewInterfaces");
	m_moduleFunctions.pfnInitialiseModule = (InitialiseModule_t)m_pLibrary->GetProcedureAddress("InitModule");
	m_moduleFunctions.pfnPulse = (Pulse_t)m_pLibrary->GetProcedureAddress("Pulse");

	// Are the pointers invalid?
	if(!IsValid())
	{
		// Delete the library instance
		SAFE_DELETE(m_pLibrary);

		return;
	}

	// Setup the functions
	m_moduleFunctions.pfnSetupFunctions(FunctionContainer);

	// Setup the pointers
	InterfacesContainer[0] = (void *)g_pCore->GetNetworkManager();
	InterfacesContainer[1] = (void *)g_pCore->GetGame()->GetPlayerManager();
	InterfacesContainer[2] = (void *)g_pCore->GetGame()->GetVehicleManager();

	// Setup the container functions with the module
	m_moduleFunctions.pfnSetupInterfaces(InterfacesContainer);
}
开发者ID:DarkSlim,项目名称:IVMultiplayer-1,代码行数:57,代码来源:CModule.cpp

示例15: ProcessInput

void CInput::ProcessInput(CString strInput)
{
	// Get the command and parameters
	size_t sSplit = strInput.Find(' ', 0);
	CString strCommand = strInput.Substring(0, sSplit++);
	CString strParameters = strInput.Substring(sSplit, (strInput.GetLength() - sSplit));

	if(strCommand.IsEmpty())
		return;
	else if(strCommand == "quit" || strCommand == "Quit" || strCommand == "exit") {
		CLogFile::Print("[Server] Server is going to shutdown NOW ....");
		g_bClose = true;
		return;

	} else if(strCommand == "help" || strCommand == "?" || strCommand == "--usage") {
		printf("========== Available console commands: ==========\n");
		printf("say <text>\n");
		printf("uptime\n");
		printf("resources\n");
		printf("players\n");
		printf("loadresource <name>\n");
		printf("reloadresource <name>\n");
		printf("unloadresource <name>\n");
		printf("exit\n");
		return;
	}
	else if (strCommand == "setSyncRate") {
		int rate = atoi(strParameters.Get());
		CServer::GetInstance()->SetSyncRate(rate);
	}
	else if (strCommand == "setMaxFPS") {
		int fps = atoi(strParameters.Get());
		CServer::GetInstance()->SetMaximumFPS(fps);
	}
	else if (strCommand == "test") {
		CScriptArguments args;
		CScriptPlayer* player = new CScriptPlayer();
		player->SetEntity(new CPlayerEntity());
		args.push(player);
		CEvents::GetInstance()->Call("Test", &args, CEventHandler::eEventType::GLOBAL_EVENT, 0);
		delete player;
	}
}
开发者ID:Rukenshia,项目名称:IV-Network,代码行数:43,代码来源:CInput.cpp


注:本文中的CString::Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。