本文整理汇总了C++中String::C_String方法的典型用法代码示例。如果您正苦于以下问题:C++ String::C_String方法的具体用法?C++ String::C_String怎么用?C++ String::C_String使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::C_String方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
_MEMBER_FUNCTION_IMPL(GUIElement, constructor)
{
const char * name;
sq_getstring(pVM, -1, &name);
String szName = name;
if(szName.IsEmpty())
_SET_RELEASE_HOOK(GUIElement);
// Get our GUI instance
CGUI * pGUI = g_pClient->GetGUI();
try
{
pGUI->GetWindowManager()->getWindow(szName.C_String());
}
catch(CEGUI::Exception &e)
{
e;
_SET_RELEASE_HOOK(GUIElement);
}
CEGUI::Window * pWindow = pGUI->GetWindowManager()->getWindow(szName.C_String());
if(!pWindow || SQ_FAILED(sq_setinstance(pVM, pWindow)))
{
CLogFile::Printf("Can't create GUIElement.");
sq_pushbool(pVM, false);
return 1;
}
SubscribeGuiEvents(pWindow);
sq_pushbool(pVM, true);
return 1;
}
示例2: ftell
// GUIImage
_MEMBER_FUNCTION_IMPL(GUIImage, constructor)
{
const char * filename;
sq_getstring(pVM, -1, &filename);
// check file size
/*FILE* pFile = fopen(filename, "rb");
fseek(pFile, 0L, SEEK_END);
int len = ftell(pFile);
if(len == 0) {
sq_pushbool(pVM, false);
fclose(pFile);
return 1;
}
fclose(pFile);*/
// Get our GUI
CGUI * pGUI = g_pClient->GetGUI();
String szName = pGUI->GetUniqueName();
// Try to load the image
try
{
CEGUI::ImagesetManager::getSingleton().createFromImageFile(szName.C_String(), filename, "resources");
CGUIStaticImage * pImage = pGUI->CreateGUIStaticImage(CEGUI::String(szName.C_String()));
pImage->setProperty("FrameEnabled", "false");
pImage->setProperty("BackgroundEnabled", "false");
pImage->setProperty("Image", String("set:%s image:full_image", szName.C_String()).C_String());
if(!pImage || SQ_FAILED(sq_setinstance(pVM, pImage)))
{
CLogFile::Printf("Can't create GUIImage.");
sq_pushbool(pVM, false);
return 1;
}
//_SET_RELEASE_HOOK(GUIElement);
CClientScriptManager * pClientScriptManager = g_pClient->GetClientScriptManager();
pClientScriptManager->GetGUIManager()->Add(pImage, pClientScriptManager->GetScriptingManager()->Get(pVM));
SubscribeGuiEvents(pImage);
pImage->setVisible(true);
sq_pushbool(pVM, true);
return 1;
}
catch(CEGUI::Exception e)
{
// Failed to load, might not exist
CLogFile::Printf("Can't create GUIImage (%s does not exist)", filename);
sq_pushbool(pVM, false);
return 1;
}
}
示例3: Startup
void CNetworkManager::Startup(int iPort, int iMaxPlayers, String strPassword, String strHostAddress)
{
// Start up the net server
m_pNetServer->Startup(iPort, iMaxPlayers, strHostAddress.C_String());
// Do we have a password?
if(!strPassword.IsEmpty())
{
// Set the RakServer password
m_pNetServer->SetPassword(strPassword.C_String());
}
// Register the packets
m_pServerPacketHandler->Register();
// Register the rpcs
m_pServerRPCHandler->Register();
}
示例4: GetConfigBoolean
bool CServer::GetConfigBoolean(String strKey, bool bDefaultValue)
{
bool bValue = false;
if(!(g_pConfig && g_pConfig->GetValueAsBoolean(strKey, bDefaultValue, &bValue)))
{
CLogFile::Printf("Failed to get '%s' value from config, defaulting to '%s'", strKey.C_String(), (bDefaultValue ? "true" : "false"));
}
return bValue;
}
示例5: GetConfigFloat
float CServer::GetConfigFloat(String strKey, float fDefaultValue)
{
float fValue = 0.0f;
if(!(g_pConfig && g_pConfig->GetValueAsFloat(strKey, fDefaultValue, &fValue)))
{
CLogFile::Printf("Failed to get '%s' value from config, defaulting to '%f'", strKey.C_String(), fDefaultValue);
}
return fValue;
}
示例6: GetConfigInteger
int CServer::GetConfigInteger(String strKey, int iDefaultValue)
{
int iValue = 0;
if(!(g_pConfig && g_pConfig->GetValueAsInteger(strKey, iDefaultValue, &iValue)))
{
CLogFile::Printf("Failed to get '%s' value from config, defaulting to '%d'", strKey.C_String(), iDefaultValue);
}
return iValue;
}
示例7: GetConfigString
String CServer::GetConfigString(String strKey, String strDefaultValue)
{
String strValue;
if(!(g_pConfig && g_pConfig->GetValueAsString(strKey, strDefaultValue, &strValue)))
{
CLogFile::Printf("Failed to get '%s' value from config, defaulting to '%s'", strKey.C_String(), strDefaultValue.C_String());
}
return strValue;
}
示例8: InitialData
void CServerRPCHandler::InitialData(CBitStream * pBitStream, CPlayerSocket senderSocket)
{
CLogFile::Printf("Got InitialData RPC from player %d", senderSocket.playerId);
// Ensure we have a valid bitstream
if(!pBitStream)
{
CLogFile::Printf("Warning: Invalid bitstream for InitialData RPC");
return;
}
// Read the data they sent us
String strName;
// Read the name
if(!pBitStream->Read(strName))
return;
// Add them to the player manager
g_pServer->GetPlayerManager()->Add(senderSocket.playerId, strName, senderSocket.GetSerial());
// Construct the initial data bit stream
CBitStream bitStream;
// Write their player id
bitStream.WriteCompressed(senderSocket.playerId);
// Send the initial data bit stream
g_pServer->GetNetworkManager()->RPC(RPC_INITIAL_DATA, &bitStream, PRIORITY_HIGH, RELIABILITY_RELIABLE_ORDERED, senderSocket.playerId, false);
// Send them all current players
g_pServer->GetPlayerManager()->HandlePlayerJoin(senderSocket.playerId);
// Send them all current vehicles
g_pServer->GetVehicleManager()->HandlePlayerJoin(senderSocket.playerId);
// Spawn them for all current players
g_pServer->GetPlayerManager()->Get(senderSocket.playerId)->SpawnForWorld();
CLogFile::Printf("Player %d has joined the game (Name: %s)", senderSocket.playerId, strName.C_String());
}
示例9: ParseHeaders
bool CHttpClient::ParseHeaders(String& strBuffer, int& iBufferSize)
{
// Find the header size, testing code, but should work
mg_request_info info;
char* buf = new char[iBufferSize];
memcpy(buf, strBuffer.C_String(), iBufferSize);
parse_http_response(buf, strBuffer.GetLength(), &info);
String buf_header;
int iHeaderSize = 0;
for(int i = 0; i < info.num_headers; ++i)
{
buf_header.AppendF("%s: %s\r\n", info.http_headers[i].name, info.http_headers[i].value);
}
iHeaderSize = buf_header.GetLength();
iHeaderSize += (info.request_method != NULL ? strlen(info.request_method) : 0) + (info.uri != NULL ? strlen(info.uri) : 0) + (info.http_version != NULL ? strlen(info.http_version) : 0) + strlen("\r\n\r\n\r\n");
iBufferSize -= iHeaderSize;
strBuffer.Erase(0, iHeaderSize);
m_headerMap["HeaderSize"] = iHeaderSize;
// ADAMIX/JENKSTA: commented out this code because doesn't work properly. Are we really need to parse headers?
/*// Ignore all initial whitespace
unsigned int uiWhiteSpace = 0;
for(unsigned int i = 0; i < (unsigned int)iBufferSize; i++)
{
// Is this whitespace?
if(strBuffer[i] == ' ')
{
// Increment the whitespace amount
uiWhiteSpace++;
continue;
}
// Finished
break;
}
// Remove whitespace
if(uiWhiteSpace > 0)
strBuffer.Erase(0, uiWhiteSpace);
// Ignore the version, status code and status message
// TODO: Use this information?
// Will be in format 'HTTP/1.0 200 OK\r\n'
unsigned int uiIgnore = strBuffer.Find("\r\n");
if(uiIgnore == String::nPos)
return false;
strBuffer.Erase(0, (uiIgnore + 2));
iBufferSize -= (uiIgnore + 2);
// Find all headers
unsigned int uiContentLength = String::nPos;
unsigned int uiNameSplit;
unsigned int uiValueSplit;
while((uiNameSplit = strBuffer.Find(": ")) != String::nPos)
{
// Do we have a content length?
if(uiContentLength != String::nPos)
{
// Get the content start
unsigned int uiContentStart = (iBufferSize - uiContentLength);
// Is the find over the content start?
if(uiNameSplit >= uiContentStart)
break;
}
// Find the value end
uiValueSplit = strBuffer.Find("\r\n");
// Did we not find a value end?
if(uiValueSplit == String::nPos)
return false;
// Get the header name
String strName = strBuffer.SubStr(0, uiNameSplit);
// If this is an accept-ranges header get the value from the next header
// jenksta: not sure if this is right, but this is how it works with 'accept-ranges: bytes'
// in mongoose
if(!strName.ICompare("accept-ranges"))
{
// Find the value end
uiValueSplit = strBuffer.Find("\r\n", (uiValueSplit + 2));
// Did we not find a value end?
if(uiValueSplit == String::nPos)
return false;
}
// Get the header value
String strValue = strBuffer.SubStr((uiNameSplit + 2), (uiValueSplit - (uiNameSplit + 2)));
//.........这里部分代码省略.........
示例10: GetPassword
// getServerPassword()
SQInteger CServerNatives::GetPassword(SQVM * pVM)
{
String sPass = CVAR_GET_STRING("password");
sq_pushstring(pVM, sPass.C_String(), sPass.GetLength());
return 1;
}
示例11: GetPassword
// getServerPassword()
int CServerNatives::GetPassword(lua_State * pVM)
{
String sPass = CVAR_GET_STRING("password");
script_pushlstring(pVM, sPass.C_String(), sPass.GetLength());
return 1;
}
示例12: Substitute
size_t String::Substitute(const String strString, const String strSubstitute)
{
return Substitute(strString.C_String(), strSubstitute);
}
示例13: ChatInput
void CServerRPCHandler::ChatInput(CBitStream * pBitStream, CPlayerSocket senderSocket)
{
CLogFile::Printf("Got ChatInput RPC from player %d", senderSocket.playerId);
// Ensure we have a valid bitstream
if(!pBitStream)
{
CLogFile::Printf("Warning: Invalid bitstream for ChatInput RPC");
return;
}
// Get the player pointer
CPlayer * pPlayer = g_pServer->GetPlayerManager()->Get(senderSocket.playerId);
// Is the player pointer valid?
if(pPlayer)
{
// Read the data they sent us
bool bIsCommand;
String strInput;
// Read if its a command or not
bIsCommand = pBitStream->ReadBit();
// Read the input
if(!pBitStream->Read(strInput))
return;
// Prepare the event arguments
CSquirrelArguments arguments;
arguments.push(strInput);
// Is it not a command?
if(!bIsCommand)
{
// Trigger the event, if it is canceled, don't output the line to other players
if(pPlayer->CallEvent("playerChat", &arguments))
{
// Construct the chat input bit stream
CBitStream bitStream;
// Write the player id
bitStream.WriteCompressed(senderSocket.playerId);
// Write the input
bitStream.Write(strInput);
// Send it to all other players
g_pServer->GetNetworkManager()->RPC(RPC_CHAT_INPUT, &bitStream, PRIORITY_HIGH, RELIABILITY_RELIABLE_ORDERED, INVALID_ENTITY_ID, true);
}
}
else
{
// Trigger the event
pPlayer->CallEvent("playerCommand", &arguments);
}
CLogFile::Printf("Recieved chat input from player %d (Command?: %s, Input: %s)", senderSocket.playerId, bIsCommand ? "Yes" : "No", strInput.C_String());
}
}