本文整理汇总了C++中AString::GetBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ AString::GetBuffer方法的具体用法?C++ AString::GetBuffer怎么用?C++ AString::GetBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AString
的用法示例。
在下文中一共展示了AString::GetBuffer方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SystemStringToOemString
AString SystemStringToOemString(const CSysString &srcString)
{
AString result;
CharToOem(srcString, result.GetBuffer(srcString.Length() * 2));
result.ReleaseBuffer();
return result;
}
示例2: LoadComments
bool CFSFolder::LoadComments()
{
if (_commentsAreLoaded)
return true;
_comments.Clear();
_commentsAreLoaded = true;
NIO::CInFile file;
if (!file.Open(_path + kDescriptionFileName))
return false;
UInt64 length;
if (!file.GetLength(length))
return false;
if (length >= (1 << 28))
return false;
AString s;
char *p = s.GetBuffer((int)((size_t)length + 1));
UInt32 processedSize;
file.Read(p, (UInt32)length, processedSize);
p[length] = 0;
s.ReleaseBuffer();
if (processedSize != length)
return false;
file.Close();
UString unicodeString;
if (!ConvertUTF8ToUnicode(s, unicodeString))
return false;
return _comments.ReadFromString(unicodeString);
}
示例3: GetName
static AString GetName(const Byte *name)
{
const int kNameSize = 8;
AString res;
char *p = res.GetBuffer(kNameSize);
memcpy(p, name, kNameSize);
p[kNameSize] = 0;
res.ReleaseBuffer();
return res;
}
示例4: ReadFileName
void CInArchive::ReadFileName(unsigned size, AString &s)
{
if (size == 0)
{
s.Empty();
return;
}
char *p = s.GetBuffer(size);
SafeReadBytes(p, size);
p[size] = 0;
s.ReleaseBuffer();
}
示例5: AddString
static void AddString(AString &s, const char *name, const Byte *p, int size)
{
int i;
for (i = 0; i < size && p[i]; i++);
for (; i > 0 && p[i - 1] == ' '; i--);
if (i != 0)
{
AString d;
memcpy(d.GetBuffer(i), p, i);
d.ReleaseBuffer(i);
s += '\n';
s += name;
s += ": ";
s += d;
}
}
示例6: UnicodeStringToMultiByte
AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage)
{
AString resultString;
if(!srcString.IsEmpty())
{
int numRequiredBytes = srcString.Length() * 2;
int numChars = WideCharToMultiByte(codePage, 0, srcString,
srcString.Length(), resultString.GetBuffer(numRequiredBytes),
numRequiredBytes + 1, NULL, NULL);
#ifndef _WIN32_WCE
if(numChars == 0)
throw 282229;
#endif
resultString.ReleaseBuffer(numChars);
}
return resultString;
}
示例7: UnicodeStringToMultiByte
AString UnicodeStringToMultiByte(const UString &s, UINT codePage, char defaultChar, bool &defaultCharWasUsed)
{
AString dest;
defaultCharWasUsed = false;
if (!s.IsEmpty())
{
int numRequiredBytes = s.Length() * 2;
BOOL defUsed;
int numChars = WideCharToMultiByte(codePage, 0, s, s.Length(),
dest.GetBuffer(numRequiredBytes), numRequiredBytes + 1,
&defaultChar, &defUsed);
defaultCharWasUsed = (defUsed != FALSE);
if (numChars == 0)
throw 282229;
dest.ReleaseBuffer(numChars);
}
return dest;
}
示例8: ExtractInfoZipUnicodePath
bool CExtraSubBlock::ExtractInfoZipUnicodePath(AString &name, AString &res) const
{
res.Empty();
if (ID != NFileHeader::NExtraID::kInfoZipUnicodePath ||
(UInt32)Data.Size() < 5 ||
*(const Byte *)Data < 1 ||
GetUi32((const Byte *)Data + 1) != CrcCalc(name, name.Len()))
return false;
int size = (int)Data.Size() - sizeof(short) * 2 - sizeof(Byte);
if (size > 0)
{
char *p = res.GetBuffer(size + 1);
memcpy(p, (const Byte *)Data + sizeof(short) * 2 + sizeof(Byte), size);
p[size] = '\0';
res.ReleaseBuffer();
}
return true;
}
示例9: QueryFileName
UString CDrop::QueryFileName(UINT fileIndex)
{
UString fileName;
#ifndef _UNICODE
if (!g_IsNT)
{
AString fileNameA;
UINT bufferSize = QueryFile(fileIndex, (LPTSTR)NULL, 0);
QueryFile(fileIndex, fileNameA.GetBuffer(bufferSize + 2), bufferSize + 1);
fileNameA.ReleaseBuffer();
fileName = GetUnicodeString(fileNameA);
}
else
#endif
{
UINT bufferSize = QueryFile(fileIndex, (LPWSTR)NULL, 0);
QueryFile(fileIndex, fileName.GetBuffer(bufferSize + 2), bufferSize + 1);
fileName.ReleaseBuffer();
}
return fileName;
}
示例10: ReadNamesFromListFile
bool ReadNamesFromListFile(CFSTR fileName, UStringVector &strings, UINT codePage)
{
NWindows::NFile::NIO::CInFile file;
if (!file.Open(fileName,true)) /* follow the symbolic link */
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.GetBuffer(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;
}
u.ReleaseBuffer(num);
}
else
{
AString s;
char *p = s.GetBuffer((unsigned)fileSize);
UInt32 processed;
if (!file.Read(p, (UInt32)fileSize, processed))
return false;
if (processed != fileSize)
return false;
file.Close();
p[processed] = 0;
s.ReleaseBuffer();
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;
}