本文整理汇总了C++中tstring::reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ tstring::reserve方法的具体用法?C++ tstring::reserve怎么用?C++ tstring::reserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tstring
的用法示例。
在下文中一共展示了tstring::reserve方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reader
static bool
ReadTextFile(const TCHAR *path, tstring &buffer)
{
/* auto-detect the character encoding, to be able to parse XCSoar
6.0 task files */
FileLineReader reader(path, ConvertLineReader::AUTO);
if (reader.error())
return false;
long size = reader.size();
if (size > 65536)
return false;
else if (size < 0)
size = 4096;
buffer.reserve(size);
const TCHAR *line;
while ((line = reader.read()) != NULL) {
if (buffer.length() > 65536)
/* too long */
return false;
buffer.append(line);
buffer.append(_T("\n"));
}
return true;
}
示例2: reader
static bool
ReadTextFile(Path path, tstring &buffer)
try {
/* auto-detect the character encoding, to be able to parse XCSoar
6.0 task files */
FileLineReader reader(path, Charset::AUTO);
long size = reader.GetSize();
if (size > 65536)
return false;
else if (size < 0)
size = 4096;
buffer.reserve(size);
const TCHAR *line;
while ((line = reader.ReadLine()) != nullptr) {
if (buffer.length() > 65536)
/* too long */
return false;
buffer.append(line);
buffer.append(_T("\n"));
}
return true;
} catch (const std::runtime_error &) {
return false;
}
示例3: XMLSafeString
void XMLSafeString(tstring& str)
{
// make an attempt at reducing re-allocs...
int len = str.size();
TCHAR * buffer = new TCHAR[len+1];
_tcscpy(buffer, str.c_str());
str.reserve(len + 20);
str = _T("");
XMLSafeString(buffer, str);
delete [] buffer;
}
示例4: FormatDecodedMETAR
void
NOAAFormatter::Format(const NOAAStore::Item &station, tstring &output)
{
output.reserve(2048);
if (!station.metar_available) {
output += _("No METAR available!");
} else {
if (station.parsed_metar_available)
FormatDecodedMETAR(station.metar, station.parsed_metar, output);
else
output += station.metar.decoded.c_str();
output += _T("\n\n");
output += station.metar.content.c_str();
}
output += _T("\n\n");
if (!station.taf_available)
output += _("No TAF available!");
else
output += station.taf.content.c_str();
}