本文整理汇总了C++中AString::ReleaseBuf_CalcLen方法的典型用法代码示例。如果您正苦于以下问题:C++ AString::ReleaseBuf_CalcLen方法的具体用法?C++ AString::ReleaseBuf_CalcLen怎么用?C++ AString::ReleaseBuf_CalcLen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AString
的用法示例。
在下文中一共展示了AString::ReleaseBuf_CalcLen方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadComments
bool CFSFolder::LoadComments()
{
_comments.Clear();
_commentsAreLoaded = true;
NIO::CInFile file;
if (!file.Open(_path + kDescriptionFileName))
return false;
UInt64 len;
if (!file.GetLength(len))
return false;
if (len >= (1 << 28))
return false;
AString s;
char *p = s.GetBuf((unsigned)(size_t)len);
UInt32 processedSize;
file.Read(p, (UInt32)len, processedSize);
s.ReleaseBuf_CalcLen((unsigned)(size_t)len);
if (processedSize != len)
return false;
file.Close();
UString unicodeString;
if (!ConvertUTF8ToUnicode(s, unicodeString))
return false;
return _comments.ReadFromString(unicodeString);
}
示例2: ReadString
void CInArchive::ReadString(unsigned size, AString &s)
{
s.Empty();
if (size != 0)
{
ReadBytes((Byte *)s.GetBuf(size), size);
s.ReleaseBuf_CalcLen(size);
}
}
示例3: ReadNamesFromListFile
bool ReadNamesFromListFile(CFSTR fileName, UStringVector &strings, UINT codePage)
{
NWindows::NFile::NIO::CInFile file;
if (!file.Open(fileName))
return false;
UInt64 fileSize;
if (!file.GetLength(fileSize))
return false;
if (fileSize >= ((UInt32)1 << 31) - 32)
return false;
UString u;
if (codePage == MY__CP_UTF16 || codePage == MY__CP_UTF16BE)
{
if ((fileSize & 1) != 0)
return false;
CByteArr buf((size_t)fileSize);
UInt32 processed;
if (!file.Read(buf, (UInt32)fileSize, processed))
return false;
if (processed != fileSize)
return false;
file.Close();
unsigned num = (unsigned)fileSize / 2;
wchar_t *p = u.GetBuf(num);
if (codePage == MY__CP_UTF16)
for (unsigned i = 0; i < num; i++)
{
wchar_t c = GetUi16(buf + i * 2);
if (c == 0)
return false;
p[i] = c;
}
else
for (unsigned i = 0; i < num; i++)
{
wchar_t c = (wchar_t)GetBe16(buf + i * 2);
if (c == 0)
return false;
p[i] = c;
}
p[num] = 0;
u.ReleaseBuf_SetLen(num);
}
else
{
AString s;
char *p = s.GetBuf((unsigned)fileSize);
UInt32 processed;
if (!file.Read(p, (UInt32)fileSize, processed))
return false;
if (processed != fileSize)
return false;
file.Close();
s.ReleaseBuf_CalcLen((unsigned)processed);
if (s.Len() != processed)
return false;
// #ifdef CP_UTF8
if (codePage == CP_UTF8)
{
if (!ConvertUTF8ToUnicode(s, u))
return false;
}
else
// #endif
MultiByteToUnicodeString2(u, s, codePage);
}
const wchar_t kGoodBOM = 0xFEFF;
const wchar_t kBadBOM = 0xFFFE;
UString s;
unsigned i = 0;
for (; i < u.Len() && u[i] == kGoodBOM; i++);
for (; i < u.Len(); i++)
{
wchar_t c = u[i];
if (c == kGoodBOM || c == kBadBOM)
return false;
if (c == L'\n' || c == 0xD)
{
AddName(strings, s);
s.Empty();
}
else
s += c;
}
AddName(strings, s);
return true;
}