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


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

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: replace_path_prefix

void replace_path_prefix(SmallVectorImpl<char> &Path,
                         const StringRef &OldPrefix, const StringRef &NewPrefix,
                         Style style) {
  if (OldPrefix.empty() && NewPrefix.empty())
    return;

  StringRef OrigPath(Path.begin(), Path.size());
  if (!OrigPath.startswith(OldPrefix))
    return;

  // If prefixes have the same size we can simply copy the new one over.
  if (OldPrefix.size() == NewPrefix.size()) {
    std::copy(NewPrefix.begin(), NewPrefix.end(), Path.begin());
    return;
  }

  StringRef RelPath = OrigPath.substr(OldPrefix.size());
  SmallString<256> NewPath;
  path::append(NewPath, style, NewPrefix);
  path::append(NewPath, style, RelPath);
  Path.swap(NewPath);
}
开发者ID:jacobly0,项目名称:llvm-z80,代码行数:22,代码来源:Path.cpp


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