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


C++ SmallVectorImpl::data方法代码示例

本文整理汇总了C++中SmallVectorImpl::data方法的典型用法代码示例。如果您正苦于以下问题:C++ SmallVectorImpl::data方法的具体用法?C++ SmallVectorImpl::data怎么用?C++ SmallVectorImpl::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SmallVectorImpl的用法示例。


在下文中一共展示了SmallVectorImpl::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: appendSentenceCase

StringRef camel_case::appendSentenceCase(SmallVectorImpl<char> &buffer,
                                         StringRef string) {
  // Trivial case: empty string.
  if (string.empty())
    return StringRef(buffer.data(), buffer.size());

  // Uppercase the first letter, append the rest.
  buffer.push_back(clang::toUppercase(string[0]));
  buffer.append(string.begin() + 1, string.end());
  return StringRef(buffer.data(), buffer.size());
}
开发者ID:ghostbar,项目名称:swift-lang.deb,代码行数:11,代码来源:StringExtras.cpp

示例2: getline

StringRef raw_istream::getline(SmallVectorImpl<char>& buf, int maxLen) {
  buf.clear();
  for (int i = 0; i < maxLen; ++i) {
    char c;
    read(c);
    if (has_error()) return StringRef{buf.data(), buf.size()};
    if (c == '\r') continue;
    buf.push_back(c);
    if (c == '\n') break;
  }
  return StringRef{buf.data(), buf.size()};
}
开发者ID:AustinShalit,项目名称:allwpilib,代码行数:12,代码来源:raw_istream.cpp

示例3: compress

Error zlib::compress(StringRef InputBuffer,
                     SmallVectorImpl<char> &CompressedBuffer, int Level) {
  unsigned long CompressedSize = ::compressBound(InputBuffer.size());
  CompressedBuffer.reserve(CompressedSize);
  int Res =
      ::compress2((Bytef *)CompressedBuffer.data(), &CompressedSize,
                  (const Bytef *)InputBuffer.data(), InputBuffer.size(), Level);
  // Tell MemorySanitizer that zlib output buffer is fully initialized.
  // This avoids a false report when running LLVM with uninstrumented ZLib.
  __msan_unpoison(CompressedBuffer.data(), CompressedSize);
  CompressedBuffer.set_size(CompressedSize);
  return Res ? createError(convertZlibCodeToString(Res)) : Error::success();
}
开发者ID:alex-t,项目名称:llvm,代码行数:13,代码来源:Compression.cpp

示例4: removeDotPaths

/// Remove '.' and '..' path components from the given absolute path.
/// \return \c true if any changes were made.
// FIXME: Move this to llvm::sys::path.
bool FileManager::removeDotPaths(SmallVectorImpl<char> &Path, bool RemoveDotDot) {
  using namespace llvm::sys;

  SmallVector<StringRef, 16> ComponentStack;
  StringRef P(Path.data(), Path.size());

  // Skip the root path, then look for traversal in the components.
  StringRef Rel = path::relative_path(P);
  for (StringRef C : llvm::make_range(path::begin(Rel), path::end(Rel))) {
    if (C == ".")
      continue;
    if (RemoveDotDot) {
      if (C == "..") {
        if (!ComponentStack.empty())
          ComponentStack.pop_back();
        continue;
      }
    }
    ComponentStack.push_back(C);
  }

  SmallString<256> Buffer = path::root_path(P);
  for (StringRef C : ComponentStack)
    path::append(Buffer, C);

  bool Changed = (Path != Buffer);
  Path.swap(Buffer);
  return Changed;
}
开发者ID:FrozenGene,项目名称:clang_trunk,代码行数:32,代码来源:FileManager.cpp

示例5: qsort

// Copy Options into a vector so we can sort them as we like.
static void
sortOpts(StringMap<Option*> &OptMap,
         SmallVectorImpl< std::pair<const char *, Option*> > &Opts,
         bool ShowHidden) {
  SmallPtrSet<Option*, 128> OptionSet;  // Duplicate option detection.

  for (StringMap<Option*>::iterator I = OptMap.begin(), E = OptMap.end();
       I != E; ++I) {
    // Ignore really-hidden options.
    if (I->second->getOptionHiddenFlag() == ReallyHidden)
      continue;

    // Unless showhidden is set, ignore hidden flags.
    if (I->second->getOptionHiddenFlag() == Hidden && !ShowHidden)
      continue;

    // If we've already seen this option, don't add it to the list again.
    if (!OptionSet.insert(I->second))
      continue;

    Opts.push_back(std::pair<const char *, Option*>(I->getKey().data(),
                                                    I->second));
  }

  // Sort the options list alphabetically.
  qsort(Opts.data(), Opts.size(), sizeof(Opts[0]), OptNameCompare);
}
开发者ID:nikunjy,项目名称:parallelStuff,代码行数:28,代码来源:CommandLine.cpp

示例6: emit_result

static void emit_result(std::vector<NewArchiveMember> &Archive, SmallVectorImpl<char> &OS,
        StringRef Name, std::vector<std::string> &outputs)
{
    outputs.push_back({ OS.data(), OS.size() });
    Archive.push_back(NewArchiveMember(MemoryBufferRef(outputs.back(), Name)));
    OS.clear();
}
开发者ID:davidanthoff,项目名称:julia,代码行数:7,代码来源:jitlayers.cpp

示例7: removePathTraversal

/// Remove traversal (ie, . or ..) from the given absolute path.
static void removePathTraversal(SmallVectorImpl<char> &Path) {
  using namespace llvm::sys;
  SmallVector<StringRef, 16> ComponentStack;
  StringRef P(Path.data(), Path.size());

  // Skip the root path, then look for traversal in the components.
  StringRef Rel = path::relative_path(P);
  for (StringRef C : llvm::make_range(path::begin(Rel), path::end(Rel))) {
    if (C == ".")
      continue;
    if (C == "..") {
      assert(ComponentStack.size() && "Path traverses out of parent");
      ComponentStack.pop_back();
    } else
      ComponentStack.push_back(C);
  }

  // The stack is now the path without any directory traversal.
  SmallString<256> Buffer = path::root_path(P);
  for (StringRef C : ComponentStack)
    path::append(Buffer, C);

  // Put the result in Path.
  Path.swap(Buffer);
}
开发者ID:4ntoine,项目名称:clang,代码行数:26,代码来源:ModuleDependencyCollector.cpp

示例8: removeDotPaths

/// Remove '.' path components from the given absolute path.
/// \return \c true if any changes were made.
// FIXME: Move this to llvm::sys::path.
bool FileManager::removeDotPaths(SmallVectorImpl<char> &Path) {
  using namespace llvm::sys;

  SmallVector<StringRef, 16> ComponentStack;
  StringRef P(Path.data(), Path.size());

  // Skip the root path, then look for traversal in the components.
  StringRef Rel = path::relative_path(P);
  bool AnyDots = false;
  for (StringRef C : llvm::make_range(path::begin(Rel), path::end(Rel))) {
    if (C == ".") {
      AnyDots = true;
      continue;
    }
    ComponentStack.push_back(C);
  }

  if (!AnyDots)
    return false;

  SmallString<256> Buffer = path::root_path(P);
  for (StringRef C : ComponentStack)
    path::append(Buffer, C);

  Path.swap(Buffer);
  return true;
}
开发者ID:KonstantinSchubert,项目名称:root,代码行数:30,代码来源:FileManager.cpp

示例9: ProcessDeclGroup

void DeclPrinter::ProcessDeclGroup(SmallVectorImpl<Decl*>& Decls) {
  this->Indent();
  Decl::printGroup(Decls.data(), Decls.size(), Out, Policy, Indentation);
  Out << ";\n";
  Decls.clear();

}
开发者ID:Intrepid,项目名称:clang-upc,代码行数:7,代码来源:DeclPrinter.cpp

示例10: uncompress

Error zlib::uncompress(StringRef InputBuffer,
                       SmallVectorImpl<char> &UncompressedBuffer,
                       size_t UncompressedSize) {
  UncompressedBuffer.resize(UncompressedSize);
  Error E =
      uncompress(InputBuffer, UncompressedBuffer.data(), UncompressedSize);
  UncompressedBuffer.resize(UncompressedSize);
  return E;
}
开发者ID:alex-t,项目名称:llvm,代码行数:9,代码来源:Compression.cpp

示例11: native

void native(const Twine &path, SmallVectorImpl<char> &result, Style style) {
  assert((!path.isSingleStringRef() ||
          path.getSingleStringRef().data() != result.data()) &&
         "path and result are not allowed to overlap!");
  // Clear result.
  result.clear();
  path.toVector(result);
  native(result, style);
}
开发者ID:jacobly0,项目名称:llvm-z80,代码行数:9,代码来源:Path.cpp

示例12: makeAbsolutePath

bool FileManager::makeAbsolutePath(SmallVectorImpl<char> &Path) const {
  bool Changed = FixupRelativePath(Path);

  if (!llvm::sys::path::is_absolute(StringRef(Path.data(), Path.size()))) {
    llvm::sys::fs::make_absolute(Path);
    Changed = true;
  }

  return Changed;
}
开发者ID:Aj0Ay,项目名称:clang,代码行数:10,代码来源:FileManager.cpp

示例13: FixupRelativePath

void FileManager::FixupRelativePath(SmallVectorImpl<char> &path) const {
  StringRef pathRef(path.data(), path.size());

  if (FileSystemOpts.WorkingDir.empty() 
      || llvm::sys::path::is_absolute(pathRef))
    return;

  SmallString<128> NewPath(FileSystemOpts.WorkingDir);
  llvm::sys::path::append(NewPath, pathRef);
  path = NewPath;
}
开发者ID:phausler,项目名称:clang,代码行数:11,代码来源:FileManager.cpp

示例14: remove_dots

bool remove_dots(SmallVectorImpl<char> &path, bool remove_dot_dot,
                 Style style) {
  StringRef p(path.data(), path.size());

  SmallString<256> result = remove_dots(p, remove_dot_dot, style);
  if (result == path)
    return false;

  path.swap(result);
  return true;
}
开发者ID:jacobly0,项目名称:llvm-z80,代码行数:11,代码来源:Path.cpp

示例15: toSentencecase

StringRef camel_case::toSentencecase(StringRef string, 
                                     SmallVectorImpl<char> &scratch) {
  if (string.empty())
    return string;

  // Can't be uppercased.
  if (!clang::isLowercase(string[0]))
    return string;

  // Uppercase the first letter, append the rest.
  scratch.clear();
  scratch.push_back(clang::toUppercase(string[0]));
  scratch.append(string.begin() + 1, string.end());
  return StringRef(scratch.data(), scratch.size());  
}
开发者ID:ghostbar,项目名称:swift-lang.deb,代码行数:15,代码来源:StringExtras.cpp


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