skillfed

CppHeaderParser

Parse C++ header files and generate a data structure representing the class

cppheaderparser v2.7.4 82.1K downloads/30d#14,185 on PyPI
Permissive license BSD Abandoned released

What it is and what it does

CppHeaderParser is a Python library that reads C++ header files and builds a dictionary-like data structure representing their contents. It extracts classes with their public, protected, and private methods and properties; namespaces and nested classes; free functions; preprocessor defines; and include directives. It also parses Doxygen-style documentation comments attached to methods and properties.

The package uses PLY (Python Lex-Yacc) to tokenize and parse C++ syntax. It is intended for code generation, documentation extraction, or automated analysis of C++ codebases from Python. However, it has been abandoned since 2016 and does not track modern C++ features. Use it only when you need to extract structure from legacy C++ headers or when no active parser meets your needs.

Use it for:

  • Extract class and method signatures from C++ headers for automated code generation or wrapper creation.
  • Parse Doxygen documentation from header files to build API documentation programmatically.
  • Analyze C++ codebases to gather metrics on class hierarchies, method counts, or namespace organization.
  • Generate Python bindings or language bindings for C++ libraries by introspecting header structure.
  • Audit or refactor C++ code by extracting public/private method and property inventories.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Parses C++ header files and extracts their structure—classes, methods, properties, namespaces, and free functions—into a Python data structure for programmatic inspection.

No, unless you have a specific legacy codebase or no active alternative. The package is abandoned (last release 2016), has high install friction, and does not support modern C++ syntax. For new projects, use an active C++ parser or AST tool. For existing code depending on it, consider migration.

Install

cppheaderparser on PyPI

pip

pip install cppheaderparser

uv

uv add cppheaderparser

poetry

poetry add cppheaderparser

Installing CppHeaderParser

Before you install

High install friction: the package is abandoned (last release 2016-11-22, no commits tracked). No runtime dependencies listed, but the description notes PLY as an external requirement. Maintenance status makes this a legacy choice; use only if no active alternative exists.

License in practice

BSD license (permissive) imposes no significant restrictions on use, modification, or distribution. Suitable for both open-source and proprietary projects.

Quickstart

import CppHeaderParser
try:
    cppHeader = CppHeaderParser.CppHeader("example.h")
    sampleClass = cppHeader.classes["SampleClass"]
    methods = sampleClass["methods"]["public"]
except CppHeaderParser.CppParseError as e:
    print(e)

PLY (Python Lex-Yacc) must be installed separately; the package requires a valid C++ header file path and does not handle all C++ syntax variations.

Verify before relying

  • Whether PLY is automatically installed as a dependency or must be installed separately.
  • Compatibility with modern C++ standards (C++11, C++17, C++20) beyond what the 2016 release supports.
  • Whether the parser handles template declarations, constexpr, and other modern C++ features.

Package facts

License BSD (permissive)
Python support not specified
Install friction high — source build required
Runtime dependencies none
Maintenance abandoned — 3,552 days since the last release
First released
Downloads 82,079/month — #14,185 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: CppHeaderParser-2.7.4.tar.gz

Keywords: c++, header, parser, ply

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: C++Programming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 3Topic :: Software DevelopmentTopic :: Software Development :: Code GeneratorsTopic :: Software Development :: CompilersTopic :: Software Development :: Disassemblers

Tags

c++ header file parserparse c++ class definitionsextract c++ metadatac++ code analysis pythonheader file introspectionc++ ast parserparse c++ declarations
c++-parsingcode-generationlegacy

More Software Development packages