当前位置: 首页>>代码示例>>C++>>正文


C++ AString::GetBuffer方法代码示例

本文整理汇总了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;
}
开发者ID:cugxiangzhenwei,项目名称:MySrcCode,代码行数:7,代码来源:StringConvert.cpp

示例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);
}
开发者ID:bks,项目名称:qz7,代码行数:28,代码来源:FSFolder.cpp

示例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;
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例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();
}
开发者ID:borneq,项目名称:bind7z,代码行数:12,代码来源:ZipIn.cpp

示例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;
  }
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:16,代码来源:IsoHandler.cpp

示例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;
}
开发者ID:4ft35t,项目名称:firmware-mod-kit,代码行数:17,代码来源:StringConvert.cpp

示例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;
}
开发者ID:cugxiangzhenwei,项目名称:MySrcCode,代码行数:18,代码来源:StringConvert.cpp

示例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;
}
开发者ID:wyrover,项目名称:7-zip32_ungarbled,代码行数:20,代码来源:ZipItem.cpp

示例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;
}
开发者ID:Ando02,项目名称:wubiuefi,代码行数:21,代码来源:Shell.cpp

示例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;
}
开发者ID:JustFFunny,项目名称:WorkSpace,代码行数:90,代码来源:ListFileUtils.cpp


注:本文中的AString::GetBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。