Registry / devops / cppheaderparser

cppheaderparser

JSON →
library2.7.4pypypi✓ verified 85d ago

A parser for C++ header files that extracts class, struct, function, and typedef definitions into a structured dictionary. Version 2.7.4. Release cadence is irregular, with last release in 2021.

pip install cppheaderparser
INSTALL
IMPORT
SIG · CPPHEADERPARSER
C
cppheaderparser
devopspythonv2.7.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CppHeaderParser
from CppHeaderParser import CppHeaderParser
import CppHeaderParser
CppHeaderParser is a class, not a module. Common mistake is to import the module and try to use it directly.

Parse a C++ header from a string or file and access parsed elements.

from CppHeaderParser import CppHeaderParser cppCode = ''' class MyClass { public: int myMethod(); }; ''' parser = CppHeaderParser(cppCode) # or pass a filepath: CppHeaderParser('path/to/header.h') print(parser.return_code) print(parser.classes) print(parser.functions) print(parser.typedefs)
Debug
Known issues
gotchaCppHeaderParser is case-sensitive. The class name must be exactly capitalized as CppHeaderParser (capital C, P, H, P).
fix
Use 'from CppHeaderParser import CppHeaderParser' exactly as shown.
affects: all
gotchaThe parser may not handle all C++11/14/17 features perfectly. Complicated templates, constexpr, or attributes may cause parse errors.
fix
Preprocess the header with a C++ preprocessor (e.g., gcc -E) to expand macros and remove unused conditional branches before parsing.
affects: all
Errors
Common errors & fixes
AttributeError: module 'CppHeaderParser' has no attribute 'CppHeader'
Importing the module instead of the class, or using wrong class name.
fix
Use: from CppHeaderParser import CppHeaderParser
CppHeaderParser.ParseError: 'Parenthesis'
Encountered a syntax element the parser cannot understand, often due to complex templates or missing semicolons.
fix
Verify the header is valid C++. If needed, run through a preprocessor first.
Upgrade
Version history
2.7.4latest on PyPI · released Nov 22, 2016
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
cppheaderparser — pip install cppheaderparser · libregistry