本文整理汇总了C++中CvString::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ CvString::c_str方法的具体用法?C++ CvString::c_str怎么用?C++ CvString::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvString
的用法示例。
在下文中一共展示了CvString::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadCivXml
//------------------------------------------------------------------------------------------------------
//
// FUNCTION: LoadCivXml(FXml* pFXml, TCHAR* szFilename)
//
// PURPOSE : Gets the full pathname for the xml file from the FileManager .
// If it is succesful we return true
// from the function and a valid FXml pointer to the pFXml parameter.
//
//------------------------------------------------------------------------------------------------------
bool CvXMLLoadUtility::LoadCivXml(FXml* pFXml, const TCHAR* szFilename)
{
char szLog[256];
sprintf(szLog, "LoadCivXml (%s)", szFilename);
PROFILE(szLog);
OutputDebugString(szLog);
OutputDebugString("\n");
CvString szPath = szFilename;
CvString fsFilename = szFilename;
if (!gDLL->fileManagerEnabled())
{
szPath = "Assets//" + szPath;
}
logMsg("Loading XML file %s\n", szPath.c_str());
if (!gDLL->getXMLIFace()->LoadXml(pFXml, szPath))
{
logMsg("Load XML file %s FAILED\n", szPath.c_str());
return false;
}
logMsg("Load XML file %s SUCCEEDED\n", szPath.c_str());
GC.setCurrentXMLFile(szFilename);
return true; // success
}
示例2: ReadDBLookup
/// Helper function to read a single type (as a string) and find its ID in a database table.
/// Assumes the type is in the table's field "Type"
int ReadDBLookup(FDataStream& kStream, const char* szTable, bool* bValid /*= NULL*/)
{
FStringFixedBuffer(sTemp, 256);
kStream >> sTemp;
if (bValid) *bValid = true;
if(sTemp.GetLength() > 0 && sTemp != "NO_TYPE")
{
Database::Connection* pDB = GC.GetGameDatabase();
if(pDB)
{
Database::Results kResults;
CvString szCommand;
szCommand.Format("SELECT ID from %s where Type = ? LIMIT 1", szTable);
if(pDB->Execute(kResults, szCommand.c_str()))
{
kResults.Bind(1, sTemp.c_str());
if(kResults.Step())
{
return kResults.GetInt(0);
}
else
if (bValid) *bValid = false;
}
}
else
if (bValid) *bValid = false;
}
return -1;
}
示例3: LogIdeologyChoice
/// Logging function to write out info on Ideology choices
void CvPolicyAI::LogIdeologyChoice(CvString &decisionState, int iWeightFreedom, int iWeightAutocracy, int iWeightOrder)
{
if(GC.getLogging() && GC.getAILogging())
{
CvString strOutBuf;
CvString strBaseString;
CvString strTemp;
CvString playerName;
// Find the name of this civ
playerName = m_pCurrentPolicies->GetPlayer()->getCivilizationShortDescription();
FILogFile* pLog;
pLog = LOGFILEMGR.GetLog(GetLogFileName(playerName), FILogFile::kDontTimeStamp);
// Get the leading info for this line
strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());
strBaseString += playerName + ", ";
strTemp.Format("%s, Freedom: %d, Order: %d, Autocracy: %d", decisionState.c_str(), iWeightFreedom, iWeightOrder, iWeightAutocracy);
strOutBuf = strBaseString + strTemp;
pLog->Msg(strOutBuf);
}
}
示例4: lGetGreatPersonRateModifierDetails
//------------------------------------------------------------------------------
//string GetGreatPersonRateModifierDetails(UnitClassTypes eGreatPersonClass);
int CvLuaLeague::lGetGreatPersonRateModifierDetails(lua_State* L)
{
CvLeague* pLeague = GetInstance(L);
const UnitClassTypes eGreatPersonClass = (UnitClassTypes) lua_tointeger(L, 2);
CvString sValue = pLeague->GetGreatPersonRateModifierDetails(eGreatPersonClass);
lua_pushstring(L, sValue.c_str());
return 1;
}
示例5: lGetLeagueSplashNextEraDetails
//------------------------------------------------------------------------------
//string GetLeagueSplashNextEraDetails(LeagueSpecialSessionTypes eGoverningSpecialSession, bool bJustFounded);
int CvLuaLeague::lGetLeagueSplashNextEraDetails(lua_State* L)
{
CvLeague* pLeague = GetInstance(L);
const LeagueSpecialSessionTypes eGoverningSpecialSession = (LeagueSpecialSessionTypes) lua_tointeger(L, 2);
const bool bJustFounded = lua_toboolean(L, 3);
CvString sValue = pLeague->GetLeagueSplashNextEraDetails(eGoverningSpecialSession, bJustFounded);
lua_pushstring(L, sValue.c_str());
return 1;
}
示例6: lGetProjectDetails
//------------------------------------------------------------------------------
//string GetProjectDetails(LeagueProjectTypes eProject, PlayerTypes eObserver);
int CvLuaLeague::lGetProjectDetails(lua_State* L)
{
CvLeague* pLeague = GetInstance(L);
const LeagueProjectTypes eProject = (LeagueProjectTypes) lua_tointeger(L, 2);
const PlayerTypes eObserver = (PlayerTypes) luaL_optint(L, 3, NO_PLAYER);
CvString sValue = pLeague->GetProjectDetails(eProject, eObserver);
lua_pushstring(L, sValue.c_str());
return 1;
}
示例7: lGetMemberDetails
//------------------------------------------------------------------------------
//string GetMemberDetails(PlayerTypes eMember, PlayerTypes eObserver);
int CvLuaLeague::lGetMemberDetails(lua_State* L)
{
CvLeague* pLeague = GetInstance(L);
const PlayerTypes eMember = (PlayerTypes) lua_tointeger(L, 2);
const PlayerTypes eObserver = (PlayerTypes) lua_tointeger(L, 3);
CvString sValue = pLeague->GetMemberDetails(eMember, eObserver);
lua_pushstring(L, sValue.c_str());
return 1;
}
示例8: lGetResolutionName
//------------------------------------------------------------------------------
//string GetResolutionName(ResolutionTypes eResolution, int iResolutionID, int iProposerChoice, bool bIncludePrefix);
int CvLuaLeague::lGetResolutionName(lua_State* L)
{
CvLeague* pLeague = GetInstance(L);
const ResolutionTypes eResolution = (ResolutionTypes) lua_tointeger(L, 2);
const int iResolutionID = lua_tointeger(L, 3);
const int iProposerChoice = lua_tointeger(L, 4);
const bool bIncludePrefix = lua_toboolean(L, 5);
CvString sValue = pLeague->GetResolutionName(eResolution, iResolutionID, iProposerChoice, bIncludePrefix);
lua_pushstring(L, sValue.c_str());
return 1;
}
示例9: lGetResolutionDetails
//------------------------------------------------------------------------------
//string GetResolutionDetails(ResolutionTypes eResolution, PlayerTypes eObserver, int iResolutionID, int iProposerChoice);
int CvLuaLeague::lGetResolutionDetails(lua_State* L)
{
CvLeague* pLeague = GetInstance(L);
const ResolutionTypes eResolution = (ResolutionTypes) lua_tointeger(L, 2);
const PlayerTypes eObserver = (PlayerTypes) lua_tointeger(L, 3);
const int iResolutionID = lua_tointeger(L, 4);
const int iProposerChoice = lua_tointeger(L, 5);
CvString sValue = pLeague->GetResolutionDetails(eResolution, eObserver, iResolutionID, iProposerChoice);
lua_pushstring(L, sValue.c_str());
return 1;
}
示例10: Dump
void CvTacticalAnalysisMap::Dump()
{
if (m_ePlayer==NO_PLAYER)
return;
bool bLogging = GC.getLogging() && GC.getAILogging() && (GET_PLAYER(m_ePlayer).isMajorCiv() || GET_PLAYER(m_ePlayer).isBarbarian()) && GET_PLAYER(m_ePlayer).IsAtWar();
if (bLogging)
{
CvString fname = CvString::format( "TacticalCells_%s_%03d.txt", GET_PLAYER(m_ePlayer).getCivilizationAdjective(), GC.getGame().getGameTurn() );
FILogFile* pLog=LOGFILEMGR.GetLog( fname.c_str(), FILogFile::kDontTimeStamp );
if (pLog)
{
pLog->Msg( "#x,y,visible,terrain,owner,enemy,targettype,underattack,zoneid,dominance,zonetype,fstrength,estrength,city\n" );
for (int i=0; i<GC.getMap().numPlots(); i++)
{
CvTacticalAnalysisCell* pCell = GetCell(i);
if (!pCell->IsRevealed())
continue;
CvTacticalDominanceZone* pZone = GetZoneByID( pCell->GetDominanceZone() );
int iZoneFriendlyStrength = pZone ? pZone->GetFriendlyRangedStrength() + pZone->GetOverallFriendlyStrength() : -1;
int iZoneEnemyStrength = pZone ? pZone->GetEnemyRangedStrength() + pZone->GetOverallEnemyStrength() : -1;
CvCity* pCity = pZone ? pZone->GetZoneCity() : NULL;
CvString dump = CvString::format( "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%s\n",
GC.getMap().plotByIndex(i)->getX(), GC.getMap().plotByIndex(i)->getY(),
pCell->IsVisible(), (int)GC.getMap().plotByIndex(i)->getTerrainType(), (int)GC.getMap().plotByIndex(i)->getOwner(),
(int)pCell->IsEnemyTerritory(), (int)pCell->GetTargetType(), (int)pCell->IsSubjectToAttack(),
pZone ? pZone->GetDominanceZoneID() : -1, pZone ? pZone->GetOverallDominanceFlag() : -1, pZone ? pZone->GetTerritoryType() : -1,
iZoneFriendlyStrength, iZoneEnemyStrength, pCity ? pCity->getName().c_str() : "no city" );
pLog->Msg( dump.c_str() );
}
pLog->Close();
}
}
}
示例11: GetDefineSTRING
//------------------------------------------------------------------------------
bool CvDllGameContext::GetDefineSTRING(char* szBuffer, size_t lenBuffer, const char* szName, bool bReportErrors)
{
if(szBuffer != NULL && lenBuffer > 0)
{
CvString strDefine = GC.getDefineSTRING(szName, bReportErrors);
if(strDefine.size() < lenBuffer)
{
strncpy_s(szBuffer, lenBuffer, strDefine.c_str(), strDefine.size());
return true;
}
}
return false;
}
示例12: isModularArt
bool CvXMLLoadUtilityModTools::isModularArt(const char* szLocationName)
{
/************************************************************************************************/
/* DEBUG_IS_MODULAR_ART 05/12/08 Faichele */
/* */
/* */
/************************************************************************************************/
#if (DEBUG_IS_MODULAR_ART == 1)
CvString szDebugBuffer;
szDebugBuffer.Format("=== isModularArt BEGIN ===");
gDLL->logMsg("CvXMLLoadUtilityModTools_isModularArt.log", szDebugBuffer.c_str());
szDebugBuffer.Format(" Location name: '%s'", szLocationName);
gDLL->logMsg("CvXMLLoadUtilityModTools_isModularArt.log", szDebugBuffer.c_str());
#endif
//the passed is crap, we don't want to continue anything with it
if (szLocationName == NULL || szLocationName == "" || szLocationName == "None" || szLocationName == "NONE" )
{
#if (DEBUG_IS_MODULAR_ART == 1)
szDebugBuffer.Format(" EMPTY location, aborting.");
gDLL->logMsg("CvXMLLoadUtilityModTools_isModularArt.log", szDebugBuffer.c_str());
#endif
return false;
}
// Dir where the Civ4BeyondSword.exe is started from
/************************************************************************************************/
/* Afforess Start 06/15/10 */
/* */
/* */
/************************************************************************************************/
CvString m_szFolderPath = GC.getInitCore().getDLLPath() + "\\";
/************************************************************************************************/
/* Afforess END */
/************************************************************************************************/
#if (DEBUG_IS_MODULAR_ART == 1)
szDebugBuffer.Format(" Complete path (with Assets dir): %s", m_szFolderPath.c_str());
gDLL->logMsg("CvXMLLoadUtilityModTools_isModularArt.log", szDebugBuffer.c_str());
#endif
m_szFolderPath += szLocationName; // where the tag points to, usually "Art\filename.xxx"
#if (DEBUG_IS_MODULAR_ART == 1)
szDebugBuffer.Format(" Path WITH given location: '%s'", m_szFolderPath.c_str());
gDLL->logMsg("CvXMLLoadUtilityModTools_isModularArt.log", szDebugBuffer.c_str());
#endif
int iReplaced = 0;
iReplaced = m_szFolderPath.Replace('/','\\');
#if (DEBUG_IS_MODULAR_ART == 1)
szDebugBuffer.Format(" Replaced %i occurrences of '/' with '\\'.", iReplaced);
gDLL->logMsg("CvXMLLoadUtilityModTools_isModularArt.log", szDebugBuffer.c_str());
#endif
iReplaced = m_szFolderPath.Replace(CvString("\\\\"),CvString("\\"));
#if (DEBUG_IS_MODULAR_ART == 1)
szDebugBuffer.Format(" Replaced %i occurrences of '\\\\' with '\\'.", iReplaced);
gDLL->logMsg("CvXMLLoadUtilityModTools_isModularArt.log", szDebugBuffer.c_str());
szDebugBuffer.Format(" Path WITH given location: '%s'", m_szFolderPath.c_str());
gDLL->logMsg("CvXMLLoadUtilityModTools_isModularArt.log", szDebugBuffer.c_str());
#endif
FILE *file;
DWORD dwAttr = GetFileAttributes(m_szFolderPath.c_str());
if(dwAttr != 0xffffffff && (dwAttr & FILE_ATTRIBUTE_DIRECTORY))
{
#if (DEBUG_IS_MODULAR_ART == 1)
szDebugBuffer.Format(" '%s' is a DIRECTORY, no modular art?", m_szFolderPath.c_str());
gDLL->logMsg("CvXMLLoadUtilityModTools_isModularArt.log", szDebugBuffer.c_str());
#endif
return false;
}
else
{
file = fopen(m_szFolderPath.c_str(), "rb");
}
/************************************************************************************************/
/* DEBUG_IS_MODULAR_ART END */
/************************************************************************************************/
if (file == NULL)
{
return false;
}
fclose(file);
#if (DEBUG_IS_MODULAR_ART == 1)
szDebugBuffer.Format("=== isModularArt END ===");
gDLL->logMsg("CvXMLLoadUtilityModTools_isModularArt.log", szDebugBuffer.c_str());
#endif
return true;
}
示例13: isCommaFile
bool CvXMLLoadUtilityModTools::isCommaFile(CvString *pszTextVal, const char* szDirName)
{
#if (DEBUG_IS_MODULAR_ART == 1)
CvString szDebugBuffer;
szDebugBuffer.Format("=== isCommaFile BEGIN ===");
gDLL->logMsg("CvXMLLoadUtilityModTools_isCommaFile.log", szDebugBuffer.c_str());
szDebugBuffer.Format(" Text value: %s, Directory name: '%s'", pszTextVal->c_str(), szDirName);
gDLL->logMsg("CvXMLLoadUtilityModTools_isCommaFile.log", szDebugBuffer.c_str());
#endif
string::size_type posComma = (*pszTextVal).find_first_of(',');
if(posComma != string::npos) //if no comma found at all, return false
{
#if (DEBUG_IS_MODULAR_ART == 1)
szDebugBuffer.Format(" Found a ',' at position %i (total length %i)", (int)posComma, (*pszTextVal).GetLength());
gDLL->logMsg("CvXMLLoadUtilityModTools_isCommaFile.log", szDebugBuffer.c_str());
#endif
CvString szTempLocation;
CvString szAppend = " ";
int iCountComma = 0;
CvString szLocationNameStripComma;
// Check how many comma's we have in the string and how many Button Files
#if (DEBUG_IS_MODULAR_ART == 1)
std::vector<CvString> asTagParts;
pszTextVal->getTokens(CvString(","), asTagParts);
iCountComma = asTagParts.size();
szDebugBuffer.Format(" Total number of ',' in pszTextVal: %i", iCountComma);
gDLL->logMsg("CvXMLLoadUtilityModTools_isCommaFile.log", szDebugBuffer.c_str());
for (std::vector<CvString>::iterator it = asTagParts.begin(); it != asTagParts.end(); it++)
{
szDebugBuffer.Format(" - Token %s", (*it).c_str());
gDLL->logMsg("CvXMLLoadUtilityModTools_isCommaFile.log", szDebugBuffer.c_str());
}
#else
szLocationNameStripComma = *pszTextVal;
for ( int i = 0; i < szLocationNameStripComma.GetLength(); i++)
{
if (szLocationNameStripComma[i] == 44) // "," = 44 (ASCII)
{
iCountComma++;
}
}
#endif
#if (DEBUG_IS_MODULAR_ART == 1)
CvString szButtonsString;
for (std::vector<CvString>::iterator it = asTagParts.begin(); it != asTagParts.end(); it++)
{
bool bDigitsOnly = true;
for (int i = 0; i < (*it).GetLength(); i++)
{
if (!isdigit((*it)[i]))
bDigitsOnly = false;
}
if (!bDigitsOnly)
szButtonsString += ((*it) + ",");
}
// Eliminate comma at end of string, if there is one
if (szButtonsString.GetLength() > 0 && szButtonsString[szButtonsString.GetLength()] == ',')
szButtonsString = szButtonsString.substr(0, szButtonsString.GetLength() - 1);
szDebugBuffer.Format(" Button art string after eliminating numerical indices: %s", szButtonsString.c_str());
gDLL->logMsg("CvXMLLoadUtilityModTools_isCommaFile.log", szDebugBuffer.c_str());
#else
// determine the append string at the end of the tag
bool bContinue = true;
szTempLocation = *pszTextVal;
while ( bContinue)
{
posComma = szTempLocation.find_first_of(',');
if(posComma != string::npos) //Prevent Null pointer deletion
{
szTempLocation = szTempLocation.substr(szTempLocation.find(",")+1);
if (isdigit(szTempLocation[0])) //We found the Append
{
bContinue = false;
}
}
else break;
}
if (!bContinue )
{
szAppend = "," + szTempLocation;
}
#endif
std::vector<CvString> vecButtonArtFile;
#if (DEBUG_IS_MODULAR_ART == 1)
szButtonsString.getTokens(CvString(","), vecButtonArtFile);
szDebugBuffer.Format(" Button art vector size after tokenizing by ',': %i", vecButtonArtFile.size());
gDLL->logMsg("CvXMLLoadUtilityModTools_isCommaFile.log", szDebugBuffer.c_str());
#else
//.........这里部分代码省略.........
示例14: setLocationName
// WARNING WARNING WARNING WARNING
// the p_szLogWrite->XmlArtTagVerification can cause CTD because of memory overflow
// If too much is parsed into the XmlArtTagVerification method!!
void CvXMLLoadUtilityModTools::setLocationName( CvString *pszTextVal, const char* szDirName)
{
#if (DEBUG_IS_MODULAR_ART == 1)
CvString szDebugBuffer;
szDebugBuffer.Format("=== setLocationName BEGIN ===");
gDLL->logMsg("CvXMLLoadUtilityModTools_setLocationName.log", szDebugBuffer.c_str());
szDebugBuffer.Format(" Text value: '%s', Directory name: '%s'", pszTextVal->c_str(), szDirName);
gDLL->logMsg("CvXMLLoadUtilityModTools_setLocationName.log", szDebugBuffer.c_str());
#endif
std::string szFiraxisLoad = "NONE";
if (szDirName == szFiraxisLoad) //non modular loading doesn't need this method
{
//#if (DEBUG_IS_MODULAR_ART == 1)
// szDebugBuffer.Format("DirName == NONE, exiting?");
// gDLL->logMsg("CvXMLLoadUtilityModTools_setLocationName.log", szDebugBuffer.c_str());
//
// szDebugBuffer.Format("=== setLocationName END ===");
// gDLL->logMsg("CvXMLLoadUtilityModTools_setLocationName.log", szDebugBuffer.c_str());
//#endif
return;
}
CvString szModular = szDirName;
CvString szTextVal = *pszTextVal;
szModular = szModular + szTextVal;
CvXMLLoadUtility* p_szLogWrite = new CvXMLLoadUtility;
if (isExcludedFile(szTextVal)) // These are special files that are relative to the Directory of Civ4BeyondSword.exe
{
if ( isModularArt(szModular))
{
szTextVal = gDLL->getModName();
szTextVal += "Assets\\";
szTextVal += szModular;
writeThm(szTextVal);
}
else
{
#ifdef _DEBUG
//the passed is crap, we don't want to continue anything with it
/*
if ( szTextVal == "" ) // this shouldn't exist
{
p_szLogWrite->XmlArtTagVerification("CRASH WARNING, Your theme <Path> tag is found emtpy in: %s\\%s", szDirName.GetCString(), GC.getCurrentXMLFile().GetCString());
}
else if (szTextVal == "None") // this shouldn't exist!
{
p_szLogWrite->XmlArtTagVerification("CRASH WARNING, Your theme <Path> tag is set to: %s in: %s\\%s", szTextVal.GetCString(), szDirName.GetCString(), GC.getCurrentXMLFile().GetCString());
}
else
{
}
*/
p_szLogWrite->XmlArtTagVerification("CRASH WARNING, Your theme <Path> %s, seems not to be relative to the Module path: %s", szTextVal.GetCString(), szDirName);
#endif
}
}
else if (isCommaFile(&szTextVal, szDirName)) // These are tags with a comma, mostly having 2button types even
{
#ifdef _DEBUG
//the passed is crap, we don't want to continue anything with it
if ( szTextVal == "" )
{
p_szLogWrite->XmlArtTagVerification("One art tag is found emtpy in: %s", GC.getCurrentXMLFile().GetCString());
}
else if (szTextVal == "None")
{
p_szLogWrite->XmlArtTagVerification("One art tag is set to: %s in: %s", szTextVal.GetCString(), GC.getCurrentXMLFile().GetCString());
}
else
{
p_szLogWrite->XmlArtTagVerification("One art tag: %s, seems not to be relative to the module path in: %s", szTextVal.GetCString(), GC.getCurrentXMLFile().GetCString());
}
#endif
}
else
{
if ( isModularArt(szModular))
{
szTextVal = szModular;
}
else
{
#ifdef _DEBUG
//the passed is crap, we don't want to continue anything with it
if ( szTextVal == "" )
{
p_szLogWrite->XmlArtTagVerification("One art tag is found emtpy in: %s", GC.getCurrentXMLFile().GetCString());
}
else if (szTextVal == "None")
{
p_szLogWrite->XmlArtTagVerification("One art tag is set to: %s in: %s", szTextVal.GetCString(), GC.getCurrentXMLFile().GetCString());
}
else
//.........这里部分代码省略.........
示例15:
kStream << kPopupInfo.eButtonPopupType;
CvString strDummy = kPopupInfo.szText;
kStream << strDummy;
return kStream;
}
//------------------------------------------------------------------------------
FDataStream & operator>>(FDataStream& kStream, CvPopupInfo& kPopupInfo)
{
// Version number to maintain backwards compatibility
uint uiVersion;
kStream >> uiVersion;
kStream >> kPopupInfo.iData1;
kStream >> kPopupInfo.iData2;
kStream >> kPopupInfo.iData3;
kStream >> kPopupInfo.iFlags;
kStream >> kPopupInfo.bOption1;
kStream >> kPopupInfo.bOption2;
kStream >> kPopupInfo.eButtonPopupType;
CvString strDummy;
kStream >> strDummy;
strcpy_s(kPopupInfo.szText, strDummy.c_str());
return kStream;
}