本文整理汇总了C++中tString::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ tString::c_str方法的具体用法?C++ tString::c_str怎么用?C++ tString::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tString
的用法示例。
在下文中一共展示了tString::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadResourceDirsFile
bool cResources::LoadResourceDirsFile(const tString &asFile)
{
TiXmlDocument* pXmlDoc = hplNew( TiXmlDocument, (asFile.c_str()) );
if(pXmlDoc->LoadFile()==false)
{
Error("Couldn't load XML file '%s'!\n",asFile.c_str());
hplDelete( pXmlDoc);
return false;
}
//Get the root.
TiXmlElement* pRootElem = pXmlDoc->RootElement();
TiXmlElement* pChildElem = pRootElem->FirstChildElement();
for(; pChildElem != NULL; pChildElem = pChildElem->NextSiblingElement())
{
tString sPath = cString::ToString(pChildElem->Attribute("Path"),"");
if(sPath==""){
continue;
}
if(sPath[0]=='/' || sPath[0]=='\\') sPath = sPath.substr(1);
AddResourceDir(sPath);
}
hplDelete(pXmlDoc);
return true;
}
示例2: ReceiveLeagueMessage
// called on the master server when the league message is received
void nKrawall::ReceiveLeagueMessage(const tString& message)
{
// con << message;
if (message[0] == 'K')
{
tString killer(message.c_str()+1);
tString victim(message.c_str()+1+killer.Len());
MasterFrag(killer, victim);
}
else if (message[0] == 'R')
{
tString numP(message.c_str()+1);
int pos = 1 + numP.Len();
int numPlayers = atoi(numP);
tArray<tString> players(numPlayers);
for (int i = numPlayers-1; i>=0; i--)
{
players(i) = tString(message.c_str()+pos);
pos += players(i).Len();
}
MasterRoundEnd(&players[0], numPlayers);
}
}
示例3: CreateFromFile
bool cSqScript::CreateFromFile(const tString& asFileName)
{
CScriptBuilder builder;
builder.StartNewModule(mpScriptEngine,msModuleName.c_str());
if(builder.AddSectionFromFile(asFileName.c_str())<0)
{
Error("Couldn't add script '%s'!\n",asFileName.c_str());
return false;
}
if(builder.BuildModule()<0)
{
Error("Couldn't build script '%s'!\n",asFileName.c_str());
Log("------- SCRIPT OUTPUT BEGIN --------------------------\n");
mpScriptOutput->Display();
mpScriptOutput->Clear();
Log("------- SCRIPT OUTPUT END ----------------------------\n");
return false;
}
mpScriptOutput->Clear();
return true;
}
示例4: AddScriptVar
bool cLowLevelSystemSDL::AddScriptVar(const tString& asVarDecl, void *pVar)
{
if(mpScriptEngine->RegisterGlobalProperty(asVarDecl.c_str(),pVar)<0)
{
Error("Couldn't add var '%s'\n",asVarDecl.c_str());
return false;
}
return true;
}
示例5: CreateFromFile
bool cSoundEntityData::CreateFromFile(const tString &a_sFile)
{
tString sType;
TiXmlDocument *pDoc = efeNew(TiXmlDocument, ());
if (pDoc->LoadFile(a_sFile.c_str()) == false)
{
Error("Couldn't load '%s'!\n", a_sFile.c_str());
efeDelete(pDoc);
return false;
}
TiXmlElement *pRootElem = pDoc->FirstChildElement();
TiXmlElement *pMainElem = pRootElem->FirstChildElement("MAIN");
if (pMainElem == NULL)
{
Error("Couldn't find MAIN element in '%s'!\n", a_sFile.c_str());
efeDelete(pDoc);
return false;
}
m_sMainSound = cString::ToString(pMainElem->Attribute("MainSound"),"");
m_sStartSound = cString::ToString(pMainElem->Attribute("StartSound"),"");
m_sStopSound = cString::ToString(pMainElem->Attribute("StopSound"),"");
TiXmlElement *pPropElem = pRootElem->FirstChildElement("PROPERTIES");
if (pPropElem == NULL)
{
Error("Couldn't find PROPERTIES element in '%s'!\n", a_sFile.c_str());
efeDelete(pDoc);
return false;
}
m_bUse3D = cString::ToBool(pPropElem->Attribute("Use3D"),true);
m_bLoop = cString::ToBool(pPropElem->Attribute("Loop"),true);
m_bStream = cString::ToBool(pPropElem->Attribute("Stream"),true);
m_bBlockable = cString::ToBool(pPropElem->Attribute("Blockable"),false);
m_fBlockVolumeMul = cString::ToFloat(pPropElem->Attribute("BlockVolumeMul"),0.6f);
m_fVolume = cString::ToFloat(pPropElem->Attribute("Volume"),1);
m_fMaxDistance = cString::ToFloat(pPropElem->Attribute("MaxDistance"),1);
m_fMinDistance = cString::ToFloat(pPropElem->Attribute("MinDistance"),1);
m_bFadeStart = cString::ToBool(pPropElem->Attribute("FadeStart"),true);
m_bFadeStop = cString::ToBool(pPropElem->Attribute("FadeStop"),true);
m_fRandom = cString::ToFloat(pPropElem->Attribute("Random"),1);
m_fInterval = cString::ToFloat(pPropElem->Attribute("Interval"),0);
m_lPriority = cString::ToInt(pPropElem->Attribute("Priority"),0);
efeDelete(pDoc);
return true;
}
示例6: AddScriptFunc
bool cLowLevelSystemSDL::AddScriptFunc(const tString& asFuncDecl, void* pFunc, int callConv)
{
if(mpScriptEngine->RegisterGlobalFunction(asFuncDecl.c_str(),
asFUNCTION(pFunc),callConv)<0)
{
Error("Couldn't add func '%s'\n",asFuncDecl.c_str());
return false;
}
return true;
}
示例7: CreateFromFile
bool cOpenALSoundEnvironment::CreateFromFile(const tString &asFile)
{
tString strType;
TiXmlDocument doc;
if (!doc.LoadFile(asFile.c_str()))
return false;
TiXmlElement* pMain = doc.FirstChildElement("SoundEnvironment")->FirstChildElement("Main");
if (pMain)
{
strType = pMain->Attribute("Type");
mstrName = pMain->Attribute("Name");
}
float* pfTemp;
TiXmlElement* pParams = doc.FirstChildElement("SoundEnvironment")->FirstChildElement("Parameters");
if ( (pParams == NULL) || (strType.compare("OpenAL")!=0) )
{
doc.Clear();
return false;
}
mfDensity = cString::ToFloat(pParams->Attribute("Density"),0);
mfDiffusion = cString::ToFloat(pParams->Attribute("Diffusion"),0);
mfGain = cString::ToFloat(pParams->Attribute("Gain"),0);
mfGainHF = cString::ToFloat(pParams->Attribute("GainHF"),0);
mfGainLF = cString::ToFloat(pParams->Attribute("GainLF"),0);
mfDecayTime = cString::ToFloat(pParams->Attribute("DecayTime"),0);
mfDecayHFRatio = cString::ToFloat (pParams->Attribute("DecayHFRatio"),0);
mfDecayLFRatio = cString::ToFloat (pParams->Attribute("DecayLFRatio"),0);
mfReflectionsGain = cString::ToFloat(pParams->Attribute("ReflectionsGain"),0);
mfReflectionsDelay = cString::ToFloat(pParams->Attribute("ReflectionsDelay"),0);
pfTemp = cString::ToVector3f(pParams->Attribute("ReflectionsPan"),cVector3f(0)).v;
mfReflectionsPan[0] = pfTemp[0];
mfReflectionsPan[1] = pfTemp[1];
mfReflectionsPan[2] = pfTemp[2];
mfLateReverbGain = cString::ToFloat(pParams->Attribute("LateReverbGain"),0);
mfLateReverbDelay = cString::ToFloat(pParams->Attribute("LateReverbDelay"),0);
pfTemp = cString::ToVector3f(pParams->Attribute("LateReverbPan"),cVector3f(0)).v;
mfLateReverbPan[0] = pfTemp[0];
mfLateReverbPan[1] = pfTemp[1];
mfLateReverbPan[2] = pfTemp[2];
mfEchoTime = cString::ToFloat(pParams->Attribute("EchoTime"),0);
mfEchoDepth = cString::ToFloat(pParams->Attribute("EchoDepth"),0);
mfModulationTime = cString::ToFloat(pParams->Attribute("ModulationTime"),0);
mfModulationDepth = cString::ToFloat(pParams->Attribute("ModulationDepth"),0);
mfAirAbsorptionGainHF = cString::ToFloat(pParams->Attribute("AirAbsorptionGainHF"),0);
mfHFReference = cString::ToFloat(pParams->Attribute("HFReference"),0);
mfLFReference = cString::ToFloat(pParams->Attribute("LFReference"),0);
mfRoomRolloffFactor =cString::ToFloat(pParams->Attribute("RoomRolloffFactor"),0);
mbDecayHFLimit = cString::ToInt(pParams->Attribute("DecayHFLimit"),0);
doc.Clear();
pParams = NULL;
return true;
}
示例8: AddResourceDir
/**
* \todo File searcher should check so if the dir is allready added and if so return false and not add
* \param &asDir
* \param &asMask
* \return
*/
bool cResources::AddResourceDir(const tString &asDir, const tString &asMask)
{
mpFileSearcher->AddDirectory(asDir, asMask);
if(iResourceBase::GetLogCreateAndDelete())
Log(" Added resource directory '%s'\n",asDir.c_str());
return true;
}
示例9: LoadLibraryA
//---------------------------------------------load
bool SharedLibraryImplWIN32::loadLibrary(const tString& sFilename)
{
m_aInstance = LoadLibraryA(sFilename.c_str());
if(!m_aInstance)
return false;
return true;
}
示例10: RemoveCollideScript
void iGameEntity::RemoveCollideScript(eGameCollideScriptType aType,const tString &asEntity)
{
tGameCollideScriptMapIt it = m_mapCollideCallbacks.find(asEntity);
if(it != m_mapCollideCallbacks.end())
{
cGameCollideScript *pCallback = it->second;
pCallback->msFuncName[aType] = "";
//if there are no functions left, erase
if(pCallback->msFuncName[0]=="" && pCallback->msFuncName[1]=="" && pCallback->msFuncName[2]=="")
{
if(mbUpdatingCollisionCallbacks)
{
pCallback->mbDeleteMe = true;
}
else
{
hplDelete( pCallback );
m_mapCollideCallbacks.erase(it);
}
}
}
else
{
Warning("Entity '%s' callback doesn't exist in '%s'\n",asEntity.c_str(),msName.c_str());
}
}
示例11: AddCollideScript
void iGameEntity::AddCollideScript(eGameCollideScriptType aType,const tString &asFunc, const tString &asEntity)
{
cGameCollideScript *pCallback;
//Check if the function already exist
tGameCollideScriptMapIt it = m_mapCollideCallbacks.find(asEntity);
if(it != m_mapCollideCallbacks.end())
{
pCallback = it->second;
}
else
{
pCallback = hplNew( cGameCollideScript, () );
//Get the entity
iGameEntity *pEntity = mpInit->mpMapHandler->GetGameEntity(asEntity);
if(pEntity==NULL)
{
Warning("Couldn't find entity '%s'\n",asEntity.c_str());
hplDelete( pCallback );
return;
}
//Set the entity
pCallback->mpEntity = pEntity;
//Add to container
m_mapCollideCallbacks.insert(tGameCollideScriptMap::value_type(asEntity,pCallback));
}
pCallback->msFuncName[aType] = asFunc;
}
示例12: iGameEntity
cGameLamp::cGameLamp(cInit *apInit,const tString& asName) : iGameEntity(apInit,asName)
{
mType = eGameEntityType_Lamp;
mbHasInteraction = true;
mbLit = true;
mfMaxInteractDist = 2.1f;
mfAlpha = 1;
mfTurnOnTime = 2;
mfTurnOffTime = 1;
mbInteractOff = true;
mbInteractOn = true;
msTurnOnSound = "";
msTurnOffSound = "";
msOnItem = "";
msOffItem = "";
mpOffMaterial = NULL;
mpOnMaterial = NULL;
mpSubMesh = NULL;
mbSaveLights = false;
mOpenILLight = new openil::IL_LightSource();
Log("Game lamp %s created\n", asName.c_str());
}
示例13: tStringToString
void tStringToString(std::string& strDest, const tString& tstrSrc)
{
char* pszStr = NULL;
T2C(&pszStr, tstrSrc.c_str());
strDest = pszStr;
SAFE_ARRYDELETE(pszStr);
}
示例14: BrokenScramblePassword
// scramble a password locally (so it does not have to be stored on disk)
void nKrawall::BrokenScramblePassword(const tString& password,
nScrambledPassword &scrambled)
{
md5_state_t state;
md5_init(&state);
md5_append(&state, (md5_byte_t const *)(password.c_str()), password.Len());
md5_finish(&state, scrambled.content);
}
示例15: CPPUnitReporter
explicit CPPUnitReporter(const tString &filename = _T("testResult.xml"))
: failedTests_(),
passedTests_(),
filename_(filename),
stream_(new tOfstream(filename_.c_str()))
{
if( !stream_->good())
throw TutError(_T("Cannot open output file `") + filename_ + _T("`"));
}