How to use the cpplint._ClassInfo function in cpplint

To help you get started, we’ve selected a few cpplint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TheOstrichIO / cpplint / cpplint.py View on Github external
'alternatives, such as pointers or simple constants.')

  # Track class entry and exit, and attempt to find cases within the
  # class declaration that don't meet the C++ style
  # guidelines. Tracking is very dependent on the code matching Google
  # style guidelines, but it seems to perform well enough in testing
  # to be a worthwhile addition to the checks.
  classinfo_stack = class_state.classinfo_stack
  # Look for a class declaration. The regexp accounts for decorated classes
  # such as in:
  # class LOCKABLE API Object {
  # };
  class_decl_match = Match(
      r'\s*(template\s*<[\w\s<>,:]*>\s*)?(class|struct)\s+([A-Z_]+\s+)*(\w+(::\w+)*)', line)
  if class_decl_match:
    classinfo_stack.append(_ClassInfo(class_decl_match.group(4), linenum))

  # Everything else in this function uses the top of the stack if it's
  # not empty.
  if not classinfo_stack:
    return

  classinfo = classinfo_stack[-1]

  # If the opening brace hasn't been seen look for it and also
  # parent class declarations.
  if not classinfo.seen_open_brace:
    # If the line has a ';' in it, assume it's a forward declaration or
    # a single-line class declaration, which we won't process.
    if line.find(';') != -1:
      classinfo_stack.pop()
      return