本文整理汇总了C++中vsString类的典型用法代码示例。如果您正苦于以下问题:C++ vsString类的具体用法?C++ vsString怎么用?C++ vsString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vsString类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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!");
}
}
开发者ID:,项目名称:,代码行数:33,代码来源:
示例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()) );
}
}
开发者ID:,项目名称:,代码行数:10,代码来源:
示例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
}
}
开发者ID:,项目名称:,代码行数:13,代码来源:
示例4: RemoveLeadingWhitespace
static void RemoveLeadingWhitespace( vsString &string )
{
bool done = false;
while(!done)
{
done = true;
if ( !string.empty() && IsWhitespace(string[0]) )
{
string.erase(0,1);
done = false;
}
}
}
开发者ID:,项目名称:,代码行数:15,代码来源:
示例5: vsFormatString
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);
}
}
}
}
开发者ID:vectorstorm,项目名称:vectorstorm,代码行数:26,代码来源:VS_LocalisationTable.cpp
示例6: 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;
}
开发者ID:vectorstorm,项目名称:petition-damsel,代码行数:30,代码来源:VS_Font.cpp
示例7: DirectoryContents
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;
}
开发者ID:,项目名称:,代码行数:27,代码来源:
示例8: 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;
}
开发者ID:,项目名称:,代码行数:8,代码来源:
示例9: ExtractStringToken
static vsString ExtractStringToken( vsString &string )
{
vsAssert(string[0] == '\"', "Tried to extract a string that didn't start with \"!");
vsString result;
//result.append( 1, string[0] ); // get first '"'
string.erase(0,1);
bool escaped = false;
while( !string.empty() && string[0] ){
if ( escaped )
{
if ( string[0] == 'n' )
{
result.append( 1, '\n' );
}
else
{
result.append( 1, string[0] );
}
escaped = false;
}
else
{
if ( string[0] == '\"' )
{
break; // end of string!
}
else if ( string[0] == '\\' )
{
escaped = true;
}
else
{
result.append( 1, string[0] );
}
}
string.erase(0,1);
}
//result.append( 1, string[0] ); // get last '"'
string.erase(0,1);
return result;
}
开发者ID:,项目名称:,代码行数:45,代码来源:
示例10: ExtractStringToken
static vsString ExtractStringToken( vsString &string )
{
vsString token;
size_t index = string.find(' ');
if ( index == vsString::npos )
{
token = string;
string = "";
}
else
{
token = string.substr(0, index);
string.erase(0,index+1);
// string = string.substr(index, vsString::npos);
}
return token;
}
开发者ID:vectorstorm,项目名称:petition-damsel,代码行数:19,代码来源:FS_Record.cpp
示例11: 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 );
}
}
开发者ID:,项目名称:,代码行数:55,代码来源:
示例12: ExtractWhitespaceStringToken
static vsString ExtractWhitespaceStringToken( vsString &string ) // pull out a string defined by whitespace
{
vsString label;
size_t len = string.length();
size_t index = 0;
for ( index = 0; index < len; index++ )
{
if ( IsWhitespace(string[index]) ) // this character isn't alphabetic, so isn't part of the label
{
index--; // back up one character
break; // exit the loop
}
}
label = string.substr(0, index+1);
string.erase(0,index+1);
return label;
}
开发者ID:,项目名称:,代码行数:21,代码来源:
示例13: ExtractNumberToken
static vsString ExtractNumberToken( vsString &string )
{
vsAssert(IsNumeric(string[0]), "Tried to extract a number from something that isn't a number!");
// okay. We need to find
vsString numberString;
size_t len = string.length();
size_t index = 0;
for ( index = 0; index < len; index++ )
{
if ( !IsNumeric(string[index]) ) // this character isn't alphabetic, so isn't part of the label
{
index--; // back up one character
break; // exit the loop
}
}
numberString = string.substr(0, index+1);
string.erase(0,index+1);
return numberString;
}
开发者ID:,项目名称:,代码行数:23,代码来源:
示例14: 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;
}
开发者ID:vectorstorm,项目名称:vectorstorm,代码行数:14,代码来源:VS_NetClient.cpp
示例15: 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();
}
开发者ID:,项目名称:,代码行数:19,代码来源:
示例16: vsFormatString
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));
}
}
}
开发者ID:vectorstorm,项目名称:petition-damsel,代码行数:20,代码来源:VS_Preferences.cpp
示例17: vsLog
void vsLog(const vsString &str)
{
printf("%s\n", str.c_str() );
}
开发者ID:vectorstorm,项目名称:petition-damsel,代码行数:4,代码来源:VS_Log.cpp
示例18: PHYSFS_exists
bool
vsFile::DirectoryExists( const vsString &filename ) // static method
{
return PHYSFS_exists(filename.c_str()) && PHYSFS_isDirectory(filename.c_str());
}
开发者ID:,项目名称:,代码行数:5,代码来源:
注:本文中的vsString类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论