本文整理汇总了C++中SimpleString函数的典型用法代码示例。如果您正苦于以下问题:C++ SimpleString函数的具体用法?C++ SimpleString怎么用?C++ SimpleString使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VStringFromFormat
SimpleString VStringFromFormat(const char* format, va_list args)
{
va_list argsCopy;
va_copy(argsCopy, args);
enum
{
sizeOfdefaultBuffer = 100
};
char defaultBuffer[sizeOfdefaultBuffer];
SimpleString resultString;
int size = PlatformSpecificVSNprintf(defaultBuffer, sizeOfdefaultBuffer,
format, args);
if (size < sizeOfdefaultBuffer) {
resultString = SimpleString(defaultBuffer);
}
else {
char* newBuffer = new char[size + 1];
PlatformSpecificVSNprintf(newBuffer, size + 1, format, argsCopy);
resultString = SimpleString(newBuffer);
delete[] newBuffer;
}
return resultString;
}
示例2: VStringFromFormat
SimpleString VStringFromFormat(const char* format, va_list args)
{
va_list argsCopy;
va_copy(argsCopy, args);
enum
{
sizeOfdefaultBuffer = 100
};
char defaultBuffer[sizeOfdefaultBuffer];
SimpleString resultString;
size_t size = (size_t)PlatformSpecificVSNprintf(defaultBuffer, sizeOfdefaultBuffer, format, args);
if (size < sizeOfdefaultBuffer) {
resultString = SimpleString(defaultBuffer);
}
else {
size_t newBufferSize = size + 1;
char* newBuffer = SimpleString::allocStringBuffer(newBufferSize, __FILE__, __LINE__);
PlatformSpecificVSNprintf(newBuffer, newBufferSize, format, argsCopy);
resultString = SimpleString(newBuffer);
SimpleString::deallocStringBuffer(newBuffer, __FILE__, __LINE__);
}
va_end(argsCopy);
return resultString;
}
示例3: StringFrom
static SimpleString StringFrom(const Vec2D & v)
{
SimpleString s = SimpleString();
s += SimpleString("(");
s += StringFrom(v.get_x());
s += SimpleString(",");
s += StringFrom(v.get_y());
s += SimpleString(")");
return s;
}
示例4: testName
Failure::Failure (const SimpleString& theTestName,
const SimpleString& theFileName,
long theLineNumber,
const SimpleString& expected,
const SimpleString& actual)
: testName (theTestName),
fileName (theFileName),
lineNumber (theLineNumber)
{
TCHAR *part1 = TEXT("expected ");
TCHAR *part3 = TEXT(" but was: ");
//[guyu modify
size_t buflen = _tcslen (part1)
+ expected.size ()
+ _tcslen (part3)
+ actual.size ()
+ 1;
TCHAR *stage = new TCHAR [buflen];
_stprintf_s (stage, buflen, TEXT("%s%s%s%s"),
part1,
expected.asCharString(),
part3,
actual.asCharString());
//]guyu
message = SimpleString(stage);
delete stage;
}
示例5: SimpleString
SimpleString ConsoleInput::GetUserInput() const
{
char Buffer[256];
DWORD OutNum = 0;
if( ReadConsole( m_hConsoleInput, Buffer, 256, &OutNum, NULL ) )
{
// The last two characters should be a CRLF, unless we Ctrl+C or Ctrl+Break out of the zinput.
OutNum = OutNum >= 2 ? OutNum - 2 : OutNum;
Buffer[ OutNum ] = '\0';
return SimpleString( Buffer );
}
return SimpleString( "" );
}
示例6: testName
Failure::Failure (const SimpleString& theTestName,
const SimpleString& theFileName,
long theLineNumber,
const SimpleString& expected,
const SimpleString& actual)
: testName (theTestName),
fileName (theFileName),
lineNumber (theLineNumber)
{
char *part1 = "expected ";
char *part3 = " but was: ";
char *stage = new char [strlen (part1)
+ expected.size ()
+ strlen (part3)
+ actual.size ()
+ 1];
sprintf(stage, "%s%s%s%s",
part1,
expected.asCharString(),
part3,
actual.asCharString());
message = SimpleString(stage);
delete stage;
}
示例7: TEST
TEST(SimpleString, CollectionWritingToEmptyString)
{
SimpleStringCollection col;
col.allocate(3);
col[3] = SimpleString("HAH");
STRCMP_EQUAL("", col[3].asCharString());
}
示例8: StringFrom
SimpleString StringFrom(double value)
{
char buffer [DEFAULT_SIZE];
sprintf(buffer, "%lf", value);
return SimpleString(buffer);
}
示例9: GetSaveLoadPath
void EldritchFramework::WritePrefsConfig() {
const SimpleString PrefsConfigFilename =
GetSaveLoadPath() + SimpleString("prefs.cfg");
const FileStream PrefsConfigStream =
FileStream(PrefsConfigFilename.CStr(), FileStream::EFM_Write);
PrefsConfigStream.PrintF(
"# This file is automatically generated.\n# You may delete it to restore "
"defaults.\n\n");
ConfigManager::BeginWriting();
ConfigManager::Write(PrefsConfigStream, "Language");
ConfigManager::Write(PrefsConfigStream, "DisplayWidth");
ConfigManager::Write(PrefsConfigStream, "DisplayHeight");
ConfigManager::Write(PrefsConfigStream, "Fullscreen");
ConfigManager::Write(PrefsConfigStream, "OpenGL");
ConfigManager::Write(PrefsConfigStream, "Brightness");
ConfigManager::Write(PrefsConfigStream, "FOV");
ConfigManager::Write(PrefsConfigStream, "VSync");
ConfigManager::Write(PrefsConfigStream, "MouseSpeed");
ConfigManager::Write(PrefsConfigStream, "ControllerSpeed");
ConfigManager::Write(PrefsConfigStream, "InvertY");
ConfigManager::Write(PrefsConfigStream, "MasterVolume");
ConfigManager::Write(PrefsConfigStream, "MusicVolume");
m_InputSystem->WriteConfigBinds(PrefsConfigStream);
}
示例10: SimpleString
// Save to working directory on Windows and Linux. On Mac, save in proper
// location.
/*virtual*/ SimpleString EldritchFramework::GetSaveLoadPath() {
#if BUILD_MAC
return ObjCJunk::GetUserDirectory();
#else
return SimpleString("./");
#endif
}
示例11: SaveCommandLineArguments
void SaveCommandLineArguments( int argc, char* argv[] )
{
for( int ArgumentIndex = 0; ArgumentIndex < argc; ++ArgumentIndex )
{
g_CommandLineArguments.PushBack( SimpleString( argv[ ArgumentIndex ] ) );
}
}
示例12: getTestResult
void UtestShell::assertCstrContains(const char* expected, const char* actual, const char* text, const char* fileName, int lineNumber)
{
getTestResult()->countCheck();
if (actual == NULLPTR && expected == NULLPTR) return;
if (actual == NULLPTR || expected == NULLPTR)
failWith(ContainsFailure(this, fileName, lineNumber, expected, actual, text));
if (!SimpleString(actual).contains(expected))
failWith(ContainsFailure(this, fileName, lineNumber, expected, actual, text));
}
示例13: getTestResult
void UtestShell::assertCstrNoCaseContains(const char* expected, const char* actual, const char* fileName, int lineNumber)
{
getTestResult()->countCheck();
if (actual == 0 && expected == 0) return;
if(actual == 0 || expected == 0)
failWith(ContainsFailure(this, fileName, lineNumber, expected, actual));
if (!SimpleString(actual).containsNoCase(expected))
failWith(ContainsFailure(this, fileName, lineNumber, expected, actual));
}
示例14: if
bool MockNamedValue::equals(const MockNamedValue& p) const
{
if (type_ != p.type_) return false;
if (type_ == "int")
return value_.intValue_ == p.value_.intValue_;
else if (type_ == "char*")
return SimpleString(value_.stringValue_) == SimpleString(p.value_.stringValue_);
else if (type_ == "void*")
return value_.pointerValue_ == p.value_.pointerValue_;
else if (type_ == "double")
return (doubles_equal(value_.doubleValue_, p.value_.doubleValue_, 0.005));
if (comparator_)
return comparator_->isEqual(value_.objectPointerValue_, p.value_.objectPointerValue_);
return false;
}
示例15: getTestResult
void UtestShell::assertCstrNoCaseEqual(const char* expected, const char* actual, const char* text, const char* fileName, int lineNumber)
{
getTestResult()->countCheck();
if (actual == 0 && expected == 0) return;
if (actual == 0 || expected == 0)
failWith(StringEqualNoCaseFailure(this, fileName, lineNumber, expected, actual, text));
if (!SimpleString(expected).equalsNoCase(actual))
failWith(StringEqualNoCaseFailure(this, fileName, lineNumber, expected, actual, text));
}