本文整理汇总了C++中vsString::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ vsString::c_str方法的具体用法?C++ vsString::c_str怎么用?C++ vsString::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vsString
的用法示例。
在下文中一共展示了vsString::c_str方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vsFailedAssert
void vsFailedAssert( const vsString &conditionStr, const vsString &msg, const char *file, int line )
{
if ( !bAsserted )
{
// failed assertion.. trace out some information and then crash.
bAsserted = true;
vsString trimmedFile(file);
size_t pos = trimmedFile.rfind('/');
if ( pos )
{
trimmedFile = trimmedFile.substr(pos+1);
}
vsLog("Failed assertion: %s", msg.c_str());
vsLog("Failed condition: (%s)", conditionStr.c_str());
vsLog("at %s:%d", trimmedFile.c_str(), line);
vsLog_End();
{
#if defined(_DEBUG)
DEBUG_BREAK;
#else
vsString mbString = vsFormatString("Failed assertion: %s\nFailed condition: (%s)\nat %s:%d", msg.c_str(), conditionStr.c_str(), trimmedFile.c_str(), line);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Failed assertion", mbString.c_str(), NULL);
#endif
CRASH;
}
}
else
{
vsLog("Error: Asserted while handling assertion!");
}
}
示例2: vsFormatString
void
vsFile::EnsureWriteDirectoryExists( const vsString &writeDirectoryName ) // static method
{
if ( !DirectoryExists(writeDirectoryName) )
{
int mkdirResult = PHYSFS_mkdir( writeDirectoryName.c_str() );
vsAssert( mkdirResult != 0, vsFormatString("Failed to create directory '%s%s%s': %s",
PHYSFS_getWriteDir(), PHYSFS_getDirSeparator(), writeDirectoryName.c_str(), PHYSFS_getLastError()) );
}
}
示例3: vsErrorLog
void vsErrorLog(const vsString &str)
{
fprintf(stderr, "%s\n", str.c_str() );
if ( s_log )
{
PHYSFS_write( s_log, str.c_str(), 1, str.size() );
#ifdef _WIN32
PHYSFS_write( s_log, "\r\n", 1, 2 );
#else
PHYSFS_write( s_log, "\n", 1, 1 );
#endif
}
}
示例4: if
float
vsBuiltInFont::GetStringWidth( const vsString &string, float size, float capSize )
{
if ( capSize == 0.f )
capSize = size;
float width = 0.f;
size_t len = strlen(string.c_str());
for ( size_t i = 0; i < len; i++ )
{
char thisChar = string[i];
char upperChar = toupper(thisChar);
float thisSize = size;
if ( thisChar == ' ' )
{
// half width spaces, because that looks better.
thisSize *= c_spaceKerning;
}
else if ( upperChar >= 'A' && upperChar <= 'Z' && thisChar == upperChar && capSize > 0.f )
{
thisSize = capSize;
}
width += 2.0f * c_kerningFactor * thisSize;
}
return width;
}
示例5: table
void
vsLocalisationTable::Init(const vsString &language)
{
s_localisationTable = new vsHashTable<vsString>( 128 );
vsString filename = vsFormatString("%s.xlat", language.c_str());
if ( vsFile::Exists(filename) )
{
vsFile table(filename);
vsString str;
vsRecord r;
while( table.Record(&r) )
{
if ( r.GetTokenCount() > 0 )
{
vsString label = r.GetLabel().AsString();
vsString string = r.GetToken(0).AsString();
s_localisationTable->AddItemWithKey(string, label);
}
}
}
}
示例6: DeleteEmptyDirectory
bool
vsFile::DeleteDirectory( const vsString &filename )
{
if ( DirectoryExists(filename) )
{
vsArray<vsString> files;
DirectoryContents(&files, filename);
for ( int i = 0; i < files.ItemCount(); i++ )
{
vsString ff = vsFormatString("%s/%s", filename.c_str(), files[i].c_str());
if ( vsFile::DirectoryExists( ff ) )
{
// it's a directory; remove it!
DeleteDirectory( ff );
}
else
{
// it's a file, delete it.
Delete( ff );
}
}
// I should now be empty, so delete me.
return DeleteEmptyDirectory( filename );
}
return false;
}
示例7: PHYSFS_delete
bool
vsFile::Delete( const vsString &filename ) // static method
{
if ( DirectoryExists(filename) ) // This file is a directory, don't delete it!
return false;
return PHYSFS_delete(filename.c_str()) != 0;
}
示例8: offset
void
vsBuiltInFont::CreateStringInDisplayList(vsDisplayList *list, const vsString &string, float size, float capSize, JustificationType j, float maxWidth)
{
if ( maxWidth > 0.f )
{
WrapLine(string, size, capSize, j, maxWidth);
float lineHeight = capSize;
float lineMargin = capSize * c_lineMarginFactor;
// float baseOffsetDown = lineHeight * (m_wrappedLineCount * 0.5f);
float totalHeight = (lineHeight * s_wrappedLineCount) + (lineMargin * (s_wrappedLineCount-1));
float baseOffsetDown = totalHeight * 0.5f;
float topLinePosition = baseOffsetDown - totalHeight + lineHeight;
// float halfTotalHeight = totalHeight * 0.5f;
list->Clear();
vsVector2D offset(0.f,topLinePosition);
for ( int i = 0; i < s_wrappedLineCount; i++ )
{
offset.y = topLinePosition + (i*(lineHeight+lineMargin));
s_tempFontList.Clear();
BuildDisplayListFromString( &s_tempFontList, s_wrappedLine[i].c_str(), size, capSize, j, offset );
list->Append(s_tempFontList);
}
vsVector2D tl,br;
list->GetBoundingBox(tl,br);
/*
float height = br.y-tl.y;
list->Clear();
for ( int i = 0; i < m_wrappedLineCount; i++ )
{
offset.Set(0.f,lineHeight*i - 0.5f*height);
s_tempFontList.Clear();
BuildDisplayListFromString( &s_tempFontList, m_wrappedLine[i].c_str(), size, capSize, j, offset );
list->Append(s_tempFontList);
}*/
}
else
{
float lineHeight = capSize;
float totalHeight = lineHeight;
float baseOffsetDown = totalHeight * 0.5f;
float topLinePosition = baseOffsetDown - totalHeight + lineHeight;
list->Clear();
vsVector2D offset(0.f,topLinePosition);
list->Clear();
BuildDisplayListFromString( list, string.c_str(), size, capSize, j, offset );
}
}
示例9: gethostbyname
vsNetClient::vsNetClient(const vsString &address, uint16_t port)
{
hostent *h = gethostbyname( address.c_str() );
if (h == NULL)
{
#if !defined(_WIN32) // todo: Network errors under WinSock!
herror("gethostbyname");
#endif
vsAssert( h != NULL, vsFormatString("Gethostbyname error: See console output for details" ) );
}
m_privateIP = ((struct in_addr *)h->h_addr)->s_addr;
m_privatePort = port;
}
示例10: vsFormatString
vsString
vsLocalisationTable::GetTranslation( const vsString &key )
{
vsString *str = s_localisationTable->FindItem(key);
if ( str )
{
return *str;
}
else
{
return vsFormatString("<<%s>>", key.c_str());
}
}
示例11: sortFilesByModificationDate
int
vsFile::DirectoryContents( vsArray<vsString>* result, const vsString &dirName ) // static method
{
result->Clear();
char **files = PHYSFS_enumerateFiles(dirName.c_str());
char **i;
std::vector<char*> s;
for (i = files; *i != NULL; i++)
s.push_back(*i);
std::sort(s.begin(), s.end(), sortFilesByModificationDate(dirName));
for (size_t i = 0; i < s.size(); i++)
result->AddItem( s[i] );
PHYSFS_freeList(files);
return result->ItemCount();
}
示例12: prefsFile
vsPreferences::vsPreferences(const vsString &filename_in)
{
vsString filename = vsFormatString("%s.prefs",filename_in.c_str());
m_filename = filename;
m_preferenceList = new vsPreferenceObject;
if ( fsFile::Exists(filename) ) // if the file exists, then read the current pref values out of it.
{
fsRecord record;
fsFile prefsFile(filename);
while( prefsFile.Record(&record) )
{
vsAssert( record.GetArgCount() == 3, vsFormatString("%s preference has wrong number of arguments!", record.GetLabel().c_str() ));
AddPreference( record.GetLabel(), record.GetArgAsInt(0), record.GetArgAsInt(1), record.GetArgAsInt(2));
}
}
}
示例13: PHYSFS_exists
bool
vsFile::DirectoryExists( const vsString &filename ) // static method
{
return PHYSFS_exists(filename.c_str()) && PHYSFS_isDirectory(filename.c_str());
}
示例14: vsLog
void vsLog(const vsString &str)
{
printf("%s\n", str.c_str() );
}