本文整理汇总了C++中StreamString::Flush方法的典型用法代码示例。如果您正苦于以下问题:C++ StreamString::Flush方法的具体用法?C++ StreamString::Flush怎么用?C++ StreamString::Flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StreamString
的用法示例。
在下文中一共展示了StreamString::Flush方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static const char *
LanguageTypeHelpTextCallback ()
{
static char* help_text_ptr = NULL;
if (help_text_ptr)
return help_text_ptr;
StreamString sstr;
sstr << "One of the following languages:\n";
for (unsigned int l = eLanguageTypeUnknown; l < eNumLanguageTypes; ++l)
{
sstr << " " << LanguageRuntime::GetNameForLanguageType(static_cast<LanguageType>(l)) << "\n";
}
sstr.Flush();
std::string data = sstr.GetString();
help_text_ptr = new char[data.length()+1];
data.copy(help_text_ptr, data.length());
return help_text_ptr;
}
示例2: names
static const char *
FormatHelpTextCallback ()
{
static char* help_text_ptr = NULL;
if (help_text_ptr)
return help_text_ptr;
StreamString sstr;
sstr << "One of the format names (or one-character names) that can be used to show a variable's value:\n";
for (Format f = eFormatDefault; f < kNumFormats; f = Format(f+1))
{
if (f != eFormatDefault)
sstr.PutChar('\n');
char format_char = FormatManager::GetFormatAsFormatChar(f);
if (format_char)
sstr.Printf("'%c' or ", format_char);
sstr.Printf ("\"%s\"", FormatManager::GetFormatAsCString(f));
}
sstr.Flush();
std::string data = sstr.GetString();
help_text_ptr = new char[data.length()+1];
data.copy(help_text_ptr, data.length());
return help_text_ptr;
}
示例3:
static void
PadOutTo (StreamString &stream, int target)
{
stream.Flush();
int length = stream.GetString().length();
if (length + 1 < target)
stream.Printf("%*s", target - (length + 1) + 1, "");
}