本文整理汇总了C++中TString::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ TString::c_str方法的具体用法?C++ TString::c_str怎么用?C++ TString::c_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TString
的用法示例。
在下文中一共展示了TString::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DeleteFiles
bool DeleteFiles(const TString& directory, const TString& extension)
{
WIN32_FIND_DATA findData;
bool result = true;
TString searchPath = CreatePath(directory, TString(TEXT("*")) + extension);
HANDLE hFind = FindFirstFile(searchPath.c_str(), &findData);
if(hFind != INVALID_HANDLE_VALUE)
{
do
{
TString name = findData.cFileName;
if(name != TEXT(".") && name != TEXT(".."))
{
TString pathForDel = CreatePath(directory, name);
if(!DeleteFile(pathForDel.c_str()))
{
result = false;
break;
}
}
} while(FindNextFile(hFind, &findData));
FindClose(hFind);
}
return result;
}
示例2: super
CEnumPropertyDescription::CEnumPropertyDescription(CSerializer* pSerializer)
: super(eRPT_Enum)
, m_pPropertyData(NULL)
{
int iValue = 0;
if (pSerializer != NULL)
{
TString enumTypeStr;
(*pSerializer) >> iValue;
(*pSerializer) >> enumTypeStr;
std::vector<TString> vecNames;
CStringHelper::GetInstance()->SplitString(enumTypeStr.c_str(), _T("::"), vecNames);
//HACK: Force ignore namespace.
enumTypeStr = vecNames[vecNames.size() - 1];
std::map<TString, SEnumPropertyData*>::iterator iter = m_enumPropertyDataMap.m_data.find(enumTypeStr);
if (iter == m_enumPropertyDataMap.m_data.end())
{
const std::vector<SEnumData*>* pEnumValue = NULL;
bool bFind = CEnumStrGenerator::GetInstance()->GetEnumValueData(enumTypeStr.c_str(), pEnumValue);
BEATS_ASSERT(bFind, _T("Can't find the enum str for type : %s"), enumTypeStr.c_str());
if (bFind)
{
m_pPropertyData = new SEnumPropertyData(pEnumValue);
m_enumPropertyDataMap.m_data[enumTypeStr] = m_pPropertyData;
}
}
else
{
m_pPropertyData = iter->second;
}
}
示例3: binaryOpError
//
// Same error message for all binary operations don't work.
//
void TParseContext::binaryOpError(int line, const char* op, TString left, TString right)
{
error(line, " wrong operand types ", op,
"no operation '%s' exists that takes a left-hand operand of type '%s' and "
"a right operand of type '%s' (or there is no acceptable conversion)",
op, left.c_str(), right.c_str());
}
示例4: ReadServerErrCodeFile
void ReadServerErrCodeFile(std::map<uint32_t, std::map<ELanguageType, TString> >& languageServerErrCodeMap)
{
TString filePath = CResourceManager::GetInstance()->GetResourcePath(eRT_Language);
filePath.append(_T("\\")).append("networkError.xml");
if (CFilePathTool::GetInstance()->Exists(filePath.c_str()))
{
rapidxml::file<> fdoc(filePath.c_str());
rapidxml::xml_document<> errCodeXML;
try
{
errCodeXML.parse<rapidxml::parse_default>(fdoc.data());
}
catch (rapidxml::parse_error err)
{
BEATS_ASSERT(false, _T("Load config file %s faled!/n%s/n"), "errno.xml", err.what());
}
rapidxml::xml_node<>* pRootElement = errCodeXML.first_node("config");
if (pRootElement)
{
for (auto element = pRootElement->first_node(); element; element = element->next_sibling())
{
std::map<ELanguageType, TString> curMap;
curMap[eLT_Chinese] = element->first_attribute("lang_zhCN")->value();
curMap[eLT_English] = element->first_attribute("lang_enUS")->value();
languageServerErrCodeMap[_tstoi(element->first_attribute("code")->value())] = curMap;
}
}
}
}
示例5: CSVString
void CSVString( const TStringVector &sv, TString &string, char adelimiter )
{
TString word;
int i;
int n = sv.size();
int totallength = 0;
// int pos = 0;
char *pos;
if( sv.size()==0 ) {
string = "\"\"";
return;
}
for( unsigned int i=0; i<n; i++ )
{
word = CSVString( sv[i], adelimiter );
totallength += word.Length();
}
if( n>0 )
totallength += n-1;
string.SetLength( totallength );
pos = string.c_str();
for( unsigned int i=0; i<n; i++ )
{
word = CSVString( sv[i], adelimiter );
strcpy( pos, word.c_str() );
pos += word.Length();
if( i<(n-1) ) {
*pos = adelimiter;
pos++;
}
}
}
示例6: LoadCacheFile
bool CEnumStrGenerator::LoadCacheFile(const TCHAR* pszCacheFileName)
{
bool bRet = false;
TString fullPathStr = CFilePathTool::GetInstance()->ParentPath(CUtilityManager::GetInstance()->GetModuleFileName().c_str());
fullPathStr.append(_T("/")).append(pszCacheFileName);
if (CFilePathTool::GetInstance()->Exists(fullPathStr.c_str()))
{
CSerializer serializer(fullPathStr.c_str());
uint32_t enumTypeCount = 0;
serializer >> enumTypeCount;
for(uint32_t i = 0; i < enumTypeCount; ++i)
{
TString enumTypeStr;
serializer >> enumTypeStr;
std::map<TString, SEnumScanData*>::iterator iter = m_enumStrPool.find(enumTypeStr);
if (iter == m_enumStrPool.end())
{
SEnumScanData* pEnumScanData = new SEnumScanData;
serializer >> pEnumScanData->m_enumFilePath;
uint32_t dataStrCount = 0;
serializer >> dataStrCount;
for (uint32_t j = 0; j < dataStrCount; ++j)
{
SEnumData* pEnumData = new SEnumData();
serializer >> pEnumData->m_str;
serializer >> pEnumData->m_value;
pEnumScanData->m_enumValue.push_back(pEnumData);
}
m_enumStrPool[enumTypeStr] = pEnumScanData;
}
else
{
示例7: ScanEnum
bool CEnumStrGenerator::ScanEnum( const TFileData& fileData, const TString& fullDirectoryPath )
{
#if (BEATS_PLATFORM == BEATS_PLATFORM_WIN32)
if ((fileData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0)
{
if ((fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
{
const TCHAR* pReader = &fileData.cFileName[_tcslen(fileData.cFileName) - 4];
if (memcmp(pReader, _T(".cpp"), 4 * sizeof(TCHAR)) == 0 ||
memcmp(pReader + 2, _T(".h"), 2 * sizeof(TCHAR)) == 0)
{
TString fileFullPath = fullDirectoryPath;
fileFullPath.append(_T("/")).append(fileData.cFileName);
ScanEnumInFile(fileFullPath.c_str());
}
}
else
{
if (_tcsicmp(fileData.cFileName, _T(".")) != 0 &&
_tcsicmp(fileData.cFileName, _T("..")) != 0 )
{
TString fileFullPath = fullDirectoryPath;
fileFullPath.append(_T("/")).append(fileData.cFileName);
ScanEnumInDirectory(fileFullPath.c_str());
}
}
}
#endif
return true;
}
示例8: operator
inline void operator()(TVarEntryInfo& ent)
{
ent.newLocation = -1;
ent.newComponent = -1;
ent.newBinding = -1;
ent.newSet = -1;
ent.newIndex = -1;
const bool isValid = resolver.validateBinding(stage, ent.symbol->getName().c_str(), ent.symbol->getType(), ent.live);
if (isValid) {
ent.newBinding = resolver.resolveBinding(stage, ent.symbol->getName().c_str(), ent.symbol->getType(), ent.live);
ent.newSet = resolver.resolveSet(stage, ent.symbol->getName().c_str(), ent.symbol->getType(), ent.live);
if (ent.newBinding != -1) {
if (ent.newBinding >= int(TQualifier::layoutBindingEnd)) {
TString err = "mapped binding out of range: " + ent.symbol->getName();
infoSink.info.message(EPrefixInternalError, err.c_str());
error = true;
}
}
if (ent.newSet != -1) {
if (ent.newSet >= int(TQualifier::layoutSetEnd)) {
TString err = "mapped set out of range: " + ent.symbol->getName();
infoSink.info.message(EPrefixInternalError, err.c_str());
error = true;
}
}
} else {
TString errorMsg = "Invalid binding: " + ent.symbol->getName();
infoSink.info.message(EPrefixInternalError, errorMsg.c_str());
error = true;
}
}
示例9: wcstombs
bool
CSymbolEngine::LoadModuleSymbols(
HANDLE hFile,
const TString& ImageName,
DWORD64 ModBase,
DWORD ModSize
)
{
// Check preconditions
if( m_hProcess == NULL )
{
_ASSERTE( !_T("Symbol engine is not yet initialized.") );
m_LastError = ERROR_INVALID_FUNCTION;
return false;
}
// In Unicode build, ImageName parameter should be translated to ANSI
#ifdef _UNICODE
char* pImageName = 0;
if( !ImageName.empty() )
{
size_t BufSize = 2 * ImageName.length();
pImageName = (char*)_alloca( BufSize + 2 );
size_t res = wcstombs( pImageName, ImageName.c_str(), BufSize );
pImageName[BufSize] = 0;
if( res == -1 )
{
_ASSERTE( !_T("Module name has bad format.") );
m_LastError = ERROR_INVALID_PARAMETER;
return false;
}
}
#else
const char* pImageName = ImageName.empty() ? 0 : ImageName.c_str();
#endif //_UNICODE
// Load symbols for the module
#pragma TODO("replace SymLoadModule64 with SymLoadModuleEx ")
DWORD64 rv = SymLoadModule64( m_hProcess, hFile, pImageName, NULL, ModBase, ModSize );
if( rv == 0 )
{
m_LastError = GetLastError();
_ASSERTE( !_T("SymLoadModule64() failed.") );
return false;
}
// Complete
return true;
}
示例10: RescanEnum
void CEnumStrGenerator::RescanEnum(const TString& strEnumType)
{
auto iter = m_enumStrPool.find(strEnumType);
if (iter != m_enumStrPool.end())
{
TString strFilePath = iter->second->m_enumFilePath;
BEATS_SAFE_DELETE(iter->second);
m_enumStrPool.erase(iter);
ScanEnumInFile(strFilePath.c_str(), strEnumType.c_str());
}
}
示例11: hashName
TString TOutputGLSLBase::hashName(const TString& name)
{
if (mHashFunction == NULL || name.empty())
return name;
NameMap::const_iterator it = mNameMap.find(name.c_str());
if (it != mNameMap.end())
return it->second.c_str();
TString hashedName = TIntermTraverser::hash(name, mHashFunction);
mNameMap[name.c_str()] = hashedName.c_str();
return hashedName;
}
示例12: mapGlobalLongName
TString MapLongVariableNames::mapGlobalLongName(const TString& name)
{
ASSERT(mGlobalMap);
const char* mappedName = mGlobalMap->Find(name.c_str());
if (mappedName != NULL)
return mappedName;
size_t id = mGlobalMap->Size();
TString rt = mapLongName(id, name, true);
mGlobalMap->Insert(name.c_str(), rt.c_str());
return rt;
}
示例13: append
void TInfoSinkBase::append(const TString& t)
{
if (outputStream & EString) {
checkMem(t.size());
sink.append(t.c_str());
}
#ifdef _WIN32
if (outputStream & EDebugger)
OutputDebugString(t.c_str());
#endif
if (outputStream & EStdOut)
fprintf(stdout, "%s", t.c_str());
}
示例14: Load
bool CShader::Load()
{
TString strExtension = CFilePathTool::GetInstance()->Extension(GetFilePath().c_str());
bool bIsVS = strExtension.compare(_T(".vs")) == 0;
m_shaderType = bIsVS ? GL_VERTEX_SHADER : GL_FRAGMENT_SHADER;
if (m_commonHeader.GetWritePos() == 0)
{
#if (BEYONDENGINE_PLATFORM == PLATFORM_ANDROID)
const char* pszPlatformDef = "#define PLATFORM_ANDROID\r\n";
#elif (BEYONDENGINE_PLATFORM == PLATFORM_IOS)
const char* pszPlatformDef = "#define PLATFORM_IOS\r\n";
#else
const char* pszPlatformDef = "#define PLATFORM_WIN32\r\n";
#endif
m_commonHeader.Serialize((const void *)pszPlatformDef, strlen(pszPlatformDef));
TString strPath = CResourceManager::GetInstance()->GetFullPath(_T("commonheader.txt"), eRT_Shader);
m_commonHeader.Serialize(strPath.c_str());
}
BEATS_ASSERT(m_pData == NULL);
m_pData = new CSerializer(m_commonHeader);
BEATS_ASSERT(CFilePathTool::GetInstance()->Exists(m_strPath.m_value.c_str()), "Can't find shader file %s", m_strPath.m_value.c_str())
m_pData->Serialize(m_strPath.m_value.c_str());
super::Load();
return true;
}
示例15: writeBuiltInFunctionTriplet
void TOutputGLSLBase::writeBuiltInFunctionTriplet(
Visit visit, const char *preStr, bool useEmulatedFunction)
{
TString preString = useEmulatedFunction ?
BuiltInFunctionEmulator::GetEmulatedFunctionName(preStr) : preStr;
writeTriplet(visit, preString.c_str(), ", ", ")");
}