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


C++ SourceLocation::offset方法代码示例

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


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

示例1:

bool operator==(const SourceLocation &a, const SourceLocation &b)
{
    return a.line() == b.line()
            && a.column() == b.column()
            && a.offset() == b.offset()
            && a.fileName() == b.fileName()
            ;
}
开发者ID:edwardZhang,项目名称:qt-creator,代码行数:8,代码来源:sourcelocation.cpp

示例2: PrintTo

void PrintTo(const SourceLocation &sourceLocation, std::ostream *os)
{
    *os << sourceLocation.filePath().constData()
        << ", line: " << sourceLocation.line()
        << ", column: "<< sourceLocation.column()
        << ", offset: "<< sourceLocation.offset();
}
开发者ID:raphaelcotty,项目名称:qt-creator,代码行数:7,代码来源:sourcelocation.cpp

示例3: hasDotAt

bool CodeCompleter::hasDotAt(uint line, uint column) const
{
    const UnsavedFile &unsavedFile = translationUnit.unsavedFile();
    const SourceLocation location = translationUnit.sourceLocationAtWithoutReparsing(line, column);

    return unsavedFile.hasCharacterAt(location.offset(), '.');
}
开发者ID:xth,项目名称:ide,代码行数:7,代码来源:codecompleter.cpp

示例4: assert

unsigned
SourceManager::getCol(const LREntry &range, const SourceLocation &loc, unsigned line)
{
  if (!line) {
    if ((line = getLine(range, loc)) == 0)
      return 0;
  }

  SourceFile *file = range.getFile();

  // Cached and returned lines are + 1, but the line cache starts at 0.
  line = line - 1;
  assert(line < file->lineCache()->length());

  uint32_t pos = loc.offset() - range.id;
  uint32_t line_start = file->lineCache()->at(line);

#if !defined(NDEBUG)
  uint32_t line_end = (line < file->lineCache()->length() - 1)
                      ? file->lineCache()->at(line + 1)
                      : file->length() + 1;
  assert(pos >= line_start && pos < line_end);
#endif

  return pos - line_start + 1;
}
开发者ID:LittleKu,项目名称:sourcepawn,代码行数:26,代码来源:source-manager.cpp

示例5: PrintTo

void PrintTo(const SourceLocation &sourceLocation, std::ostream *os)
{
    auto filePath = sourceLocation.filePath();
    if (filePath.hasContent())
        *os << filePath.constData()  << ", ";

    *os << "line: " << sourceLocation.line()
        << ", column: "<< sourceLocation.column()
        << ", offset: "<< sourceLocation.offset();
}
开发者ID:KeeganRen,项目名称:qt-creator,代码行数:10,代码来源:sourcelocation.cpp

示例6: getLine

FullSourceRef
SourceManager::fullSourceRef(const LREntry &range, const SourceLocation &loc)
{
  FullSourceRef ref;
  ref.file = range.getFile();
  ref.line = getLine(range, loc);
  ref.col = getCol(range, loc, ref.line);
  ref.offset = loc.offset() - range.id;
  return ref;
}
开发者ID:LittleKu,项目名称:sourcepawn,代码行数:10,代码来源:source-manager.cpp

示例7: while

void
SourceManager::getTokenHistory(const SourceLocation &aLoc, TokenHistory *history)
{
  SourceLocation loc = aLoc;
  while (loc.isSet()) {
    size_t loc_index;
    if (!findLocation(loc, &loc_index))
      return;

    const LREntry &range = locations_[loc_index];
    if (loc.isInMacro()) {
      history->macros.append(FullMacroRef(range.getMacro(), loc.offset() - range.id));
    } else {
      history->files.append(fullSourceRef(range, loc));
    }
    loc = range.getParent();
  }
}
开发者ID:LittleKu,项目名称:sourcepawn,代码行数:18,代码来源:source-manager.cpp

示例8: completeWithArrowInsteadOfDot

ClangCodeCompleteResults CodeCompleter::completeWithArrowInsteadOfDot(uint line, uint column)
{
    ClangCodeCompleteResults results;

    const SourceLocation location = translationUnit.sourceLocationAtWithoutReparsing(line, column - 1);
    const bool replaced = translationUnit.unsavedFile().replaceAt(location.offset(),
                                                                  1,
                                                                  Utf8StringLiteral("->"));

    if (replaced) {
        results = complete(line,
                           column + 1,
                           translationUnit.cxUnsavedFiles(),
                           translationUnit.unsavedFilesCount());

        if (results.hasResults())
            neededCorrection_ = CompletionCorrection::DotToArrowCorrection;
    }

    return results;
}
开发者ID:DuinoDu,项目名称:qt-creator,代码行数:21,代码来源:codecompleter.cpp


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