### NamespaceAlias Example Source: https://cxxheaderparser.readthedocs.io/en/latest/types.html Shows the syntax for defining a namespace alias. ```text namespace ANS = my::ns; ~~~ ~~~~~~ ``` -------------------------------- ### NamespaceDecl Example Source: https://cxxheaderparser.readthedocs.io/en/latest/types.html Illustrates the declaration of a nested namespace. ```text namespace foo::bar {} ~~~~~~~~ ``` -------------------------------- ### Basic Custom Parsing Setup Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Instantiate a custom visitor, then create and use CxxParser to process content. The visitor collects data as parsing progresses. ```python visitor = MyVisitor() parser = CxxParser(filename, content, visitor) parser.parse() # do something with the data collected by the visitor ``` -------------------------------- ### Visitor Callback: on_deduction_guide Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Called when a C++ deduction guide is encountered. ```python on_deduction_guide(_state_ , _guide_) ``` -------------------------------- ### on_namespace_start Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Callback function invoked at the start of a namespace block. It receives the current state of the namespace block. ```APIDOC ## on_namespace_start(state) ### Description Callback function invoked at the start of a namespace block. ### Parameters - **state** (NamespaceBlockState) - The state of the namespace block. ### Return Type Optional[bool] ``` -------------------------------- ### on_deduction_guide Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Callback function invoked when a deduction guide is encountered. It receives the current state and the deduction guide object. ```APIDOC ## on_deduction_guide(state, guide) ### Description Callback function invoked when a deduction guide is encountered during parsing. ### Parameters - **state** (Union[ExternBlockState, NamespaceBlockState]) - The current parsing state. - **guide** (DeductionGuide) - The deduction guide object. ### Return Type None ``` -------------------------------- ### Using Namespace Example Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html This callback is triggered when a 'using namespace' directive is encountered, bringing all names from a namespace into the current scope. ```cpp using namespace std; ``` -------------------------------- ### Method Ref-Qualifier Example Source: https://cxxheaderparser.readthedocs.io/en/latest/types.html Demonstrates the 'ref_qualifier' attribute for methods, specifically for rvalue references (&&). ```cpp void foo() &&; ~~ ``` -------------------------------- ### Using Alias Examples Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html This callback handles 'using' declarations that create aliases for types. It covers both simple type aliases and template aliases. ```cpp using foo = int; template using VectorT = std::vector; ``` -------------------------------- ### Using Declaration Example Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html This callback is invoked for 'using' declarations that bring names from other namespaces into the current scope. ```cpp using NS::ClassName; ``` -------------------------------- ### NameSpecifier Example Source: https://cxxheaderparser.readthedocs.io/en/latest/types.html Illustrates a qualified name with multiple segments. ```text Foo::Bar ~~~ ``` -------------------------------- ### on_extern_block_start Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Callback function invoked at the start of an extern block. It receives the current state of the extern block. ```APIDOC ## on_extern_block_start(state) ### Description Callback function invoked at the start of an extern block. ### Parameters - **state** (ExternBlockState) - The state of the extern block. ### Return Type Optional[bool] ``` -------------------------------- ### Create Pcpp Preprocessor Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Creates a preprocessor using pcpp, a pure Python library. This option is portable and ignores missing #include files, making it suitable when performance is not critical. Ensure pcpp is installed separately. ```python pp = make_pcpp_preprocessor() options = ParserOptions(preprocessor=pp) parse_file(content, options=options) ``` -------------------------------- ### DeductionGuide Source: https://cxxheaderparser.readthedocs.io/en/latest/types.html Represents a deduction guide in C++. ```APIDOC ## DeductionGuide ### Description Represents a deduction guide. ### Parameters - **result_type** (`Type`) - **name** (`PQName`) - **parameters** (`List`[`Parameter`]) - **doxygen** (`Optional`[`str`]) ``` -------------------------------- ### C++ Deduction Guides Source: https://cxxheaderparser.readthedocs.io/en/latest/types.html Use DeductionGuide to represent C++ deduction guides, which are used for template argument deduction. It includes the result type, name, parameters, and optional doxygen comments. ```python class cxxheaderparser.types.DeductionGuide(_result_type_ , _name_ , _parameters_ , _doxygen =None_): """ ``` template MyClass(T) -> MyClass(int); ``` Parameters: * **result_type** (`Union`[`Array`, `Pointer`, `Type`]) * **name** (`PQName`) * **parameters** (`List`[`Parameter`]) * **doxygen** (`Optional`[`str`]) result_type: Array | Pointer | Typeᅡᅠ The type that this is an array of name: PQNameᅡᅠ possibly qualified type name for the base parameters: List[Parameter]ᅡᅠ Any attributes attached to this base specifier doxygen: str | None = Noneᅡᅠ Virtual inheritance ``` -------------------------------- ### Typedef Declaration Example Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html This callback is triggered for each typedef encountered. It handles simple typedefs and pointer typedefs. ```cpp typedef int T, *PT; ``` -------------------------------- ### make_pcpp_preprocessor Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Creates a preprocessor function that uses pcpp (which must be installed separately) to preprocess the input text. If missing #include files are encountered, this preprocessor will ignore the error. This preprocessor is pure python so it's very portable, and is a good choice if performance isn't critical. ```APIDOC ## make_pcpp_preprocessor ### Description Creates a preprocessor function that uses pcpp (which must be installed separately) to preprocess the input text. If missing #include files are encountered, this preprocessor will ignore the error. This preprocessor is pure python so it's very portable, and is a good choice if performance isn't critical. ### Parameters #### Keyword-Only Parameters * **defines** (List[str]) - list of #define macros specified as "key value" * **include_paths** (List[str]) - list of directories to search for included files * **retain_all_content** (bool) - If False, only the parsed file content will be retained * **encoding** (Optional[str]) - If specified any include files are opened with this encoding * **passthru_includes** (Optional[Pattern]) - If specified any #include directives that match the compiled regex pattern will be part of the output. * **depfile** (Optional[Path]) - If specified, will generate a preprocessor depfile that contains a list of include files that were parsed. Must also specify deptarget. Not compatible with retain_all_content * **deptarget** (Optional[List[str]]) - List of targets to put in the depfile ### Return type Callable[[str, Optional[str]], str] ### Example ```python pp = make_pcpp_preprocessor() options = ParserOptions(preprocessor=pp) parse_file(content, options=options) ``` ``` -------------------------------- ### on_parse_start Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Called when the parsing process begins, serving as an entry point for initialization. ```APIDOC ## on_parse_start ### Description Called when parsing begins ### Parameters * **state** (`NamespaceBlockState`) ### Return type `None` ``` -------------------------------- ### NullVisitor.on_class_start Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Called at the beginning of a class block. This is a no-operation method in the NullVisitor. ```APIDOC ## NullVisitor.on_class_start ### Parameters * **state** (`ClassBlockState`) ### Return type `None` ``` -------------------------------- ### on_parse_start Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Callback function invoked at the very beginning of the parsing process. It receives the initial state. ```APIDOC ## on_parse_start(state) ### Description Callback function invoked at the start of the parsing process. ### Parameters - **state** (NamespaceBlockState) - The initial parsing state. ### Return Type None ``` -------------------------------- ### on_namespace_start Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Called when a namespace directive is encountered. Returning False will prevent visiting items within this namespace. ```APIDOC ## on_namespace_start ### Description Called when a `namespace` directive is encountered If this function returns False, the visitor will not be called for any items inside this namespace (including on_namespace_end) ### Parameters * **state** (`NamespaceBlockState`) ### Return type `Optional`[`bool`] ``` -------------------------------- ### Create GCC Preprocessor Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Use this function to create a preprocessor that utilizes g++. It's accurate but will error on unresolved #include directives. Configure defines, include paths, and GCC arguments as needed. ```python pp = make_gcc_preprocessor() options = ParserOptions(preprocessor=pp) parse_file(content, options=options) ``` -------------------------------- ### make_gcc_preprocessor() Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Creates a preprocessor configured for GCC. ```APIDOC ## make_gcc_preprocessor() ### Description Creates and returns a preprocessor instance configured with settings suitable for GCC. ### Method Not specified (likely a function call) ### Endpoint N/A (Python function) ### Parameters None explicitly documented. ### Request Example N/A ### Response A preprocessor object configured for GCC. ``` -------------------------------- ### Visitor Callback: on_class_start Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Called when a class, struct, or union definition begins. Returning False will prevent further callbacks for items within this class. ```python on_class_start(_state_) ``` -------------------------------- ### make_msvc_preprocessor() Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Creates a preprocessor configured for MSVC. ```APIDOC ## make_msvc_preprocessor() ### Description Creates and returns a preprocessor instance configured with settings suitable for Microsoft Visual C++ (MSVC). ### Method Not specified (likely a function call) ### Endpoint N/A (Python function) ### Parameters None explicitly documented. ### Request Example N/A ### Response A preprocessor object configured for MSVC. ``` -------------------------------- ### UsingNamespace Source: https://cxxheaderparser.readthedocs.io/en/latest/simple.html Represents a using namespace directive. ```APIDOC ## Class: UsingNamespace ### Description Represents a using namespace directive. ### Fields * **ns** (NamespaceScope) - The namespace being brought into scope. ``` -------------------------------- ### Create MSVC Preprocessor Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html This function creates a preprocessor using cl.exe from Microsoft Visual Studio. Ensure cl.exe is accessible, potentially by opening a developer command prompt or specifying its path. Errors occur if #include files are not found. ```python pp = make_msvc_preprocessor() options = ParserOptions(preprocessor=pp) parse_file(content, options=options) ``` -------------------------------- ### SimpleCxxVisitor Methods Source: https://cxxheaderparser.readthedocs.io/en/latest/genindex.html The SimpleCxxVisitor class provides methods to handle various C++ constructs during parsing. These methods are callbacks that can be overridden to process specific elements like classes, functions, namespaces, and more. ```APIDOC ## SimpleCxxVisitor Methods ### Description These methods are part of the `cxxheaderparser.simple.SimpleCxxVisitor` class. They are designed to be called during the parsing of C++ header files to notify the visitor about different code elements. Each method can be overridden to implement custom logic for handling these elements. ### Methods - **on_class_end()** * Description: Called when the end of a class definition is encountered. - **on_class_field()** * Description: Called when a field within a class is encountered. - **on_class_friend()** * Description: Called when a friend declaration within a class is encountered. - **on_class_method()** * Description: Called when a method declaration within a class is encountered. - **on_class_start()** * Description: Called when the start of a class definition is encountered. - **on_concept()** * Description: Called when a concept definition is encountered. - **on_deduction_guide()** * Description: Called when a deduction guide for a class template is encountered. - **on_enum()** * Description: Called when an enum definition is encountered. - **on_extern_block_end()** * Description: Called when the end of an extern block is encountered. - **on_extern_block_start()** * Description: Called when the start of an extern block is encountered. - **on_forward_decl()** * Description: Called when a forward declaration is encountered. - **on_function()** * Description: Called when a function definition or declaration is encountered. - **on_include()** * Description: Called when an include directive is encountered. - **on_method_impl()** * Description: Called when a method implementation is encountered. - **on_namespace_alias()** * Description: Called when a namespace alias is encountered. - **on_namespace_end()** * Description: Called when the end of a namespace is encountered. - **on_namespace_start()** * Description: Called when the start of a namespace is encountered. - **on_parse_start()** * Description: Called at the beginning of the parsing process. - **on_pragma()** * Description: Called when a pragma directive is encountered. - **on_template_inst()** * Description: Called when a template instantiation is encountered. - **on_typedef()** * Description: Called when a typedef declaration is encountered. - **on_using_alias()** * Description: Called when a using alias declaration is encountered. - **on_using_declaration()** * Description: Called when a using declaration is encountered. - **on_using_namespace()** * Description: Called when a using namespace directive is encountered. - **on_variable()** * Description: Called when a variable declaration is encountered. ### Attributes - **operator** (cxxheaderparser.types.Function attribute) * Description: Indicates that a function is an operator overload. - **override** (cxxheaderparser.types.Method attribute) * Description: Indicates that a method is an override of a base class method. ``` -------------------------------- ### SimpleCxxVisitor Source: https://cxxheaderparser.readthedocs.io/en/latest/simple.html A visitor class for traversing parsed C++ code structures. ```APIDOC ## Class: SimpleCxxVisitor ### Description A visitor class for traversing parsed C++ code structures. This class provides methods that are called during the parsing process for various C++ constructs. ### Fields * **data** (ParsedData) - The data structure holding the parsed information. ### Methods * **on_class_end()** * **on_class_field()** * **on_class_friend()** * **on_class_method()** * **on_class_start()** * **on_concept()** * **on_deduction_guide()** * **on_enum()** * **on_extern_block_end()** * **on_extern_block_start()** * **on_forward_decl()** * **on_function()** * **on_include()** * **on_method_impl()** * **on_namespace_alias()** * **on_namespace_end()** * **on_namespace_start()** * **on_parse_start()** * **on_pragma()** * **on_template_inst()** * **on_typedef()** * **on_using_alias()** * **on_using_declaration()** * **on_using_namespace()** * **on_variable()** ``` -------------------------------- ### make_pcpp_preprocessor() Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Creates a preprocessor using the pcpp library. ```APIDOC ## make_pcpp_preprocessor() ### Description Creates and returns a preprocessor instance utilizing the `pcpp` library for processing. ### Method Not specified (likely a function call) ### Endpoint N/A (Python function) ### Parameters None explicitly documented. ### Request Example N/A ### Response A preprocessor object configured using the `pcpp` library. ``` -------------------------------- ### Visitor Callback: on_extern_block_start Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Called when an `extern` block begins. Returning False will prevent callbacks for items within this block. ```python on_extern_block_start(_state_) ``` -------------------------------- ### CxxVisitor methods Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Base methods for visiting parsed C++ elements. Users typically subclass CxxVisitor and override these methods to implement custom parsing logic. ```APIDOC ## CxxVisitor visitor methods ### Description These methods are callbacks invoked by the parser when specific C++ constructs are encountered. Users should subclass `CxxVisitor` and override these methods to define custom behavior. ### Methods - `on_class_end()` - `on_class_field()` - `on_class_friend()` - `on_class_method()` - `on_class_start()` - `on_concept()` - `on_deduction_guide()` - `on_enum()` - `on_extern_block_end()` - `on_extern_block_start()` - `on_forward_decl()` - `on_function()` - `on_include()` - `on_method_impl()` - `on_namespace_alias()` - `on_namespace_end()` - `on_namespace_start()` - `on_parse_start()` - `on_pragma()` - `on_template_inst()` - `on_typedef()` - `on_using_alias()` - `on_using_declaration()` - `on_using_namespace()` - `on_variable()` ### Endpoint N/A (Python methods) ### Parameters Parameters vary depending on the specific `on_` method. Refer to the library's detailed documentation for each method's signature. ### Request Example N/A ### Response These methods typically do not return values; their purpose is to execute side effects or collect data within the visitor. ``` -------------------------------- ### make_gcc_preprocessor Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Creates a preprocessor function that uses g++ to preprocess the input text. This is a high-performance and accurate precompiler, but it will throw an error if an #include directive cannot be resolved or if other oddities exist in the input. ```APIDOC ## make_gcc_preprocessor ### Description Creates a preprocessor function that uses g++ to preprocess the input text. GCC is a high-performance and accurate precompiler, but if an #include directive can't be resolved or other oddity exists in your input it will throw an error. ### Parameters #### Keyword-Only Parameters * **defines** (List[str]) - list of #define macros specified as "key value" * **include_paths** (List[str]) - list of directories to search for included files * **retain_all_content** (bool) - If False, only the parsed file content will be retained * **encoding** (Optional[str]) - If specified any include files are opened with this encoding * **gcc_args** (List[str]) - This is the path to G++ and any extra args you might want * **print_cmd** (bool) - Prints the gcc command as its executed * **depfile** (Optional[Path]) - If specified, will generate a preprocessor depfile that contains a list of include files that were parsed. Must also specify deptarget. * **deptarget** (Optional[List[str]]) - List of targets to put in the depfile ### Return type Callable[[str, Optional[str]], str] ### Example ```python pp = make_gcc_preprocessor() options = ParserOptions(preprocessor=pp) parse_file(content, options=options) ``` ``` -------------------------------- ### Visitor Callback: on_include Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Called once for each `#include` directive found in the parsed content. ```python on_include(_state_ , _filename_) ``` -------------------------------- ### SimpleCxxVisitor Source: https://cxxheaderparser.readthedocs.io/en/latest/simple.html A visitor that stores C++ elements in a data structure. It's recommended to use parse_file() or parse_string() instead of using this directly. ```APIDOC ## SimpleCxxVisitor ### Description A simple visitor that stores all of the C++ elements passed to it in an "easy" to use data structure. You probably don’t want to use this directly, use `parse_file()` or `parse_string()` instead. ### Data - **data**: ParsedData ### Methods - **on_class_end**(_state_) - Parameters: - **state** (`ClassBlockState`[`ClassScope`, `Union`[`ClassScope`, `NamespaceScope`]]) - Return type: `None` - **on_class_field**(_state_ , _f_) - Parameters: - **state** (`ClassBlockState`[`ClassScope`, `Union`[`ClassScope`, `NamespaceScope`]]) - **f** (`Field`) - Return type: `None` - **on_class_friend**(_state_ , _friend_) - Parameters: - **state** (`ClassBlockState`[`ClassScope`, `Union`[`ClassScope`, `NamespaceScope`]]) - **friend** (`FriendDecl`) - Return type: `None` - **on_class_method**(_state_ , _method_) - Parameters: - **state** (`ClassBlockState`[`ClassScope`, `Union`[`ClassScope`, `NamespaceScope`]]) - **method** (`Method`) - Return type: `None` - **on_class_start**(_state_) - Parameters: - **state** (`ClassBlockState`[`ClassScope`, `Union`[`ClassScope`, `NamespaceScope`]]) - Return type: `Optional`[`bool`] - **on_concept**(_state_ , _concept_) - Parameters: - **state** (`Union`[`ExternBlockState`[`NamespaceScope`, `NamespaceScope`], `NamespaceBlockState`[`NamespaceScope`, `NamespaceScope`]]) - **concept** (`Concept`) - Return type: `None` - **on_deduction_guide**(_state_ , _guide_) - Parameters: - **state** (`Union`[`ExternBlockState`[`NamespaceScope`, `NamespaceScope`], `NamespaceBlockState`[`NamespaceScope`, `NamespaceScope`]]) - **guide** (`DeductionGuide`) - Return type: `None` - **on_enum**(_state_ , _enum_) - Parameters: - **state** (`Union`[`ClassBlockState`[`ClassScope`, `Union`[`ClassScope`, `NamespaceScope`]], `ExternBlockState`[`NamespaceScope`, `NamespaceScope`], `NamespaceBlockState`[`NamespaceScope`, `NamespaceScope`]]) - **enum** (`EnumDecl`) - Return type: `None` - **on_extern_block_end**(_state_) - Parameters: - **state** (`ExternBlockState`[`NamespaceScope`, `NamespaceScope`]) - Return type: `None` - **on_extern_block_start**(_state_) - Parameters: - **state** (`ExternBlockState`[`NamespaceScope`, `NamespaceScope`]) - Return type: `Optional`[`bool`] - **on_forward_decl**(_state_ , _fdecl_) - Parameters: - **state** (`Union`[`ClassBlockState`[`ClassScope`, `Union`[`ClassScope`, `NamespaceScope`]], `ExternBlockState`[`NamespaceScope`, `NamespaceScope`], `NamespaceBlockState`[`NamespaceScope`, `NamespaceScope`]]) - **fdecl** (`ForwardDecl`) - Return type: `None` - **on_function**(_state_ , _fn_) - Parameters: - **state** (`Union`[`ExternBlockState`[`NamespaceScope`, `NamespaceScope`], `NamespaceBlockState`[`NamespaceScope`, `NamespaceScope`]]) - **fn** (`Function`) - Return type: `None` - **on_include**(_state_ , _filename_) - Parameters: - **state** (`Union`[`ClassBlockState`[`ClassScope`, `Union`[`ClassScope`, `NamespaceScope`]], `ExternBlockState`[`NamespaceScope`, `NamespaceScope`], `NamespaceBlockState`[`NamespaceScope`, `NamespaceScope`]]) - **filename** (`str`) - Return type: `None` - **on_method_impl**(_state_ , _method_) - Parameters: - **state** (`Union`[`ExternBlockState`[`NamespaceScope`, `NamespaceScope`], `NamespaceBlockState`[`NamespaceScope`, `NamespaceScope`]]) - **method** (`Method`) - Return type: `None` - **on_namespace_alias**(_state_ , _alias_) - Parameters: - **state** (`Union`[`ExternBlockState`[`NamespaceScope`, `NamespaceScope`], `NamespaceBlockState`[`NamespaceScope`, `NamespaceScope`]]) - **alias** (`NamespaceAlias`) - Return type: `None` - **on_namespace_end**(_state_) - Parameters: - **state** (`NamespaceBlockState`[`NamespaceScope`, `NamespaceScope`]) - Return type: `None` - **on_namespace_start**(_state_) - Parameters: - **state** (`NamespaceBlockState`[`NamespaceScope`, `NamespaceScope`]) - Return type: `Optional`[`bool`] - **on_parse_start**(_state_) - Parameters: - **state** (`NamespaceBlockState`[`NamespaceScope`, `NamespaceScope`]) - Return type: `None` - **on_pragma**(_state_ , _content_) - Parameters: - **state** (`Union`[`ClassBlockState`[`ClassScope`, `Union`[`ClassScope`, `NamespaceScope`]], `ExternBlockState`[`NamespaceScope`, `NamespaceScope`], `NamespaceBlockState`[`NamespaceScope`, `NamespaceScope`]]) - **content** (`Value`) - Return type: `None` - **on_template_inst**(_state_ , _inst_) - Parameters: - **state** (`Union`[`ClassBlockState`[`ClassScope`, `Union`[`ClassScope`, `NamespaceScope`]], `ExternBlockState`[`NamespaceScope`, `NamespaceScope`], `NamespaceBlockState`[`NamespaceScope`, `NamespaceScope`]]) - **inst** (`TemplateInst`) - Return type: `None` - **on_typedef**(_state_ , _typedef_) - Parameters: - **state** (`Union`[`ClassBlockState`[`ClassScope`, `Union`[`ClassScope`, `NamespaceScope`]], `ExternBlockState`[`NamespaceScope`, `NamespaceScope`], `NamespaceBlockState`[`NamespaceScope`, `NamespaceScope`]]) - **typedef** (`Typedef`) - Return type: `None` ``` -------------------------------- ### Include Source: https://cxxheaderparser.readthedocs.io/en/latest/simple.html Represents an include directive. ```APIDOC ## Class: Include ### Description Represents an include directive. ### Fields * **filename** (string) - The name of the included file. ``` -------------------------------- ### make_msvc_preprocessor Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Creates a preprocessor function that uses cl.exe from Microsoft Visual Studio to preprocess the input text. cl.exe is not typically on the path, so you may need to open the correct developer tools shell or pass in the correct path to cl.exe in the msvc_args parameter. cl.exe will throw an error if a file referenced by an #include directive is not found. ```APIDOC ## make_msvc_preprocessor ### Description Creates a preprocessor function that uses cl.exe from Microsoft Visual Studio to preprocess the input text. cl.exe is not typically on the path, so you may need to open the correct developer tools shell or pass in the correct path to cl.exe in the msvc_args parameter. cl.exe will throw an error if a file referenced by an #include directive is not found. ### Parameters #### Keyword-Only Parameters * **defines** (List[str]) - list of #define macros specified as "key value" * **include_paths** (List[str]) - list of directories to search for included files * **retain_all_content** (bool) - If False, only the parsed file content will be retained * **encoding** (Optional[str]) - If specified any include files are opened with this encoding * **msvc_args** (List[str]) - This is the path to cl.exe and any extra args you might want * **print_cmd** (bool) - Prints the command as its executed ### Return type Callable[[str, Optional[str]], str] ### Example ```python pp = make_msvc_preprocessor() options = ParserOptions(preprocessor=pp) parse_file(content, options=options) ``` ``` -------------------------------- ### on_using_namespace Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Called for 'using namespace' directives, such as 'using namespace std;'. ```APIDOC ## on_using_namespace ### Description ```cpp using namespace std; ``` ### Parameters * **state** (`Union`[`ExternBlockState`[`TypeVar`(`T`), `TypeVar`(`PT`)], `NamespaceBlockState`[`TypeVar`(`T`), `TypeVar`(`PT`)]) * **namespace** (`List`[`str`]) ### Return type `None` ``` -------------------------------- ### on_include Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Callback function invoked when an include directive is found. It takes the current state and the filename. ```APIDOC ## on_include(state, filename) ### Description Callback function invoked when an include directive is encountered during parsing. ### Parameters - **state** (Union[NamespaceBlockState, ExternBlockState, ClassBlockState]) - The current parsing state. - **filename** (str) - The name of the included file. ### Return Type None ``` -------------------------------- ### Implement Custom C++ Header Parsing Source: https://cxxheaderparser.readthedocs.io/en/latest/_sources/custom.rst.txt Use this snippet to perform custom parsing of C++ header files. Define a visitor class implementing the CxxVisitor protocol and pass it to the CxxParser along with the filename and content. The parser will then call the visitor's callbacks as it processes the code. ```python visitor = MyVisitor() parser = CxxParser(filename, content, visitor) parser.parse() # do something with the data collected by the visitor ``` -------------------------------- ### ParserOptions Source: https://cxxheaderparser.readthedocs.io/en/latest/simple.html Configuration options for the C++ header parser. ```APIDOC ## Class: ParserOptions ### Description Configuration options for the C++ header parser. ### Fields * **convert_void_to_zero_params** (bool) - Optional - Whether to convert void parameters to zero parameters. * **preprocessor** (PreprocessorFunction) - Optional - A custom preprocessor function. * **verbose** (bool) - Optional - Enables verbose output during parsing. ``` -------------------------------- ### on_template_inst Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Callback function invoked when a template instantiation is found. It takes the current state and the template instantiation object. ```APIDOC ## on_template_inst(state, inst) ### Description Callback function invoked when a template instantiation is encountered during parsing. ### Parameters - **state** (Union[NamespaceBlockState, ExternBlockState, ClassBlockState]) - The current parsing state. - **inst** (TemplateInst) - The template instantiation object. ### Return Type None ``` -------------------------------- ### Generate Unit Test with cxxheaderparser Source: https://cxxheaderparser.readthedocs.io/en/latest/_sources/tools.rst.txt Generate a unit test for cxxheaderparser by providing the C++ header filename and a test name. The output can be copied to test files. ```sh python -m cxxheaderparser.gentest FILENAME.h TESTNAME ``` -------------------------------- ### Dump Header Data with cxxheaderparser Source: https://cxxheaderparser.readthedocs.io/en/latest/_sources/tools.rst.txt Use the dump tool to output data from a C++ header file to stdout. Supports different output formats like pprint, JSON, and dataclasses repr. ```sh # pprint format python -m cxxheaderparser myheader.h ``` ```sh # JSON format python -m cxxheaderparser --mode=json myheader.h ``` ```sh # dataclasses repr format python -m cxxheaderparser --mode=repr myheader.h ``` ```sh # dataclasses repr format (formatted with black) python -m cxxheaderparser --mode=brepr myheader.h ``` -------------------------------- ### on_template_inst Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Called when an explicit template instantiation is encountered in the code. ```APIDOC ## on_template_inst ### Description Called when an explicit template instantiation is encountered ### Parameters * **state** (`Union`[`NamespaceBlockState`[`TypeVar`(`T`), `TypeVar`(`PT`)], `ExternBlockState`[`TypeVar`(`T`), `TypeVar`(`PT`)], `ClassBlockState`[`TypeVar`(`T`), `TypeVar`(`PT`)]) * **inst** (`TemplateInst`) ### Return type `None` ``` -------------------------------- ### on_using_namespace Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Callback function invoked when a using namespace directive is found. It takes the current state and the namespace name(s). ```APIDOC ## on_using_namespace(state, namespace) ### Description Callback function invoked when a using namespace directive is encountered during parsing. ### Parameters - **state** (Union[ExternBlockState, NamespaceBlockState]) - The current parsing state. - **namespace** (List[str]) - The name(s) of the namespace(s) to use. ### Return Type None ``` -------------------------------- ### UsingAlias Source: https://cxxheaderparser.readthedocs.io/en/latest/types.html Represents a 'using' alias declaration. ```APIDOC ## UsingAlias ### Description Represents a 'using' alias declaration. ### Parameters * **alias** (`str`) * **type** (`Union[Array, Pointer, MoveReference, Reference, Type]`) * **template** (`Optional[TemplateDecl]`) * **access** (`Optional[str]`) * **doxygen** (`Optional[str]`) ### Attributes * **access** (`str | None`) * If within a class, the access level for this decl * **alias** (`str`) * **doxygen** (`str | None`) * Documentation if present * **template** (`TemplateDecl | None`) * **type** (`Array | Pointer | MoveReference | Reference | Type`) ``` -------------------------------- ### on_using_declaration Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Called for 'using' declarations that bring names into scope, like 'using NS::ClassName;'. ```APIDOC ## on_using_declaration ### Description ```cpp using NS::ClassName; ``` ### Parameters * **state** (`Union`[`NamespaceBlockState`[`TypeVar`(`T`), `TypeVar`(`PT`)], `ExternBlockState`[`TypeVar`(`T`), `TypeVar`(`PT`)], `ClassBlockState`[`TypeVar`(`T`), `TypeVar`(`PT`)]) * **using** (`UsingDecl`) ### Return type `None` ``` -------------------------------- ### Visitor Callback: on_concept Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Called when a C++ concept definition is encountered. ```python on_concept(_state_ , _concept_) ``` -------------------------------- ### CxxParser Class Initialization Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html The CxxParser is a single-use object for parsing C++ header content. It requires a filename, content, and a visitor instance. ```python class cxxheaderparser.parser.CxxParser(_filename_ , _content_ , _visitor_ , _options =None_, _encoding =None_) ``` -------------------------------- ### on_method_impl Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Callback function invoked when a method implementation is found. It takes the current state and the method object. ```APIDOC ## on_method_impl(state, method) ### Description Callback function invoked when a method implementation is encountered during parsing. ### Parameters - **state** (Union[ExternBlockState, NamespaceBlockState]) - The current parsing state. - **method** (Method) - The method object. ### Return Type None ``` -------------------------------- ### ParserOptions Source: https://cxxheaderparser.readthedocs.io/en/latest/simple.html Configuration object to control the behavior of the C++ header parser. ```APIDOC ## ParserOptions ### Description Options that control parsing behaviors. ### Parameters #### Path Parameters - **verbose** (bool) - If true, prints out verbose parsing information. Defaults to False. - **convert_void_to_zero_params** (bool) - If true, converts a single void parameter to zero parameters. Defaults to True. - **preprocessor** (Optional[PreprocessorFunction]) - A function that will preprocess the header before parsing. Defaults to None. ``` -------------------------------- ### on_using_declaration Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Callback function invoked when a using declaration is found. It takes the current state and the using declaration object. ```APIDOC ## on_using_declaration(state, using) ### Description Callback function invoked when a using declaration is encountered during parsing. ### Parameters - **state** (Union[NamespaceBlockState, ExternBlockState, ClassBlockState]) - The current parsing state. - **using** (UsingDecl) - The using declaration object. ### Return Type None ``` -------------------------------- ### cxxheaderparser.types.TemplateInst Source: https://cxxheaderparser.readthedocs.io/en/latest/types.html Represents an explicit template instantiation in C++. ```APIDOC ## cxxheaderparser.types.TemplateInst ### Description Explicit template instantiation. ### Parameters * **typename** (PQName) - Required * **extern** (bool) - Required * **doxygen** (Optional[str]) - Optional ### Attributes * **doxygen**: str | None = None * **extern**: bool * **typename**: PQName ``` -------------------------------- ### on_pragma Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Called once for each #pragma directive encountered during parsing. ```APIDOC ## on_pragma ### Description Called once for each `#pragma` directive encountered ### Parameters * **state** (`Union`[`NamespaceBlockState`[`TypeVar`(`T`), `TypeVar`(`PT`)], `ExternBlockState`[`TypeVar`(`T`), `TypeVar`(`PT`)], `ClassBlockState`[`TypeVar`(`T`), `TypeVar`(`PT`)]) * **content** (`Value`) ### Return type `None` ``` -------------------------------- ### UsingDecl Source: https://cxxheaderparser.readthedocs.io/en/latest/types.html Represents a 'using' declaration, typically for namespaces or class members. ```APIDOC ## UsingDecl ### Description Represents a 'using' declaration, typically for namespaces or class members. ### Parameters * **typename** (`PQName`) * **access** (`Optional[str]`) * **doxygen** (`Optional[str]`) ### Attributes * **access** (`str | None`) * If within a class, the access level for this decl * **doxygen** (`str | None`) * Documentation if present * **typename** (`PQName`) ``` -------------------------------- ### parse_file() Source: https://cxxheaderparser.readthedocs.io/en/latest/simple.html Parses a C++ header file and returns the parsed data. ```APIDOC ## parse_file() ### Description Parses a C++ header file. ### Parameters * **filename** (string) - Required - The path to the header file to parse. * **options** (ParserOptions) - Optional - Configuration options for the parser. ### Returns * **ParsedData** - An object containing the parsed data from the file. ``` -------------------------------- ### on_using_alias Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Called for 'using' declarations that create type aliases, such as 'using foo = int;' or template aliases. ```APIDOC ## on_using_alias ### Description ```cpp using foo = int; template using VectorT = std::vector; ``` ### Parameters * **state** (`Union`[`NamespaceBlockState`[`TypeVar`(`T`), `TypeVar`(`PT`)], `ExternBlockState`[`TypeVar`(`T`), `TypeVar`(`PT`)], `ClassBlockState`[`TypeVar`(`T`), `TypeVar`(`PT`)]) * **using** (`UsingAlias`) ### Return type `None` ``` -------------------------------- ### CxxVisitor Interface Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Defines the interface for visitors used by the CxxParser to emit events during parsing. ```APIDOC ## class cxxheaderparser.visitor.CxxVisitor(_* args_, _** kwargs_) ### Description Defines the interface used by the parser to emit events. ``` ```APIDOC ## on_class_end(_state_) ### Description Called when the end of a class/struct/union is encountered. ### Parameters - **state** (ClassBlockState) - The state of the class block. ### Return type None ``` ```APIDOC ## on_class_field(_state_ , _f_) ### Description Called when a field of a class is encountered. ### Parameters - **state** (ClassBlockState) - The state of the class block. - **f** (Field) - The field encountered. ### Return type None ``` ```APIDOC ## on_class_friend(_state_ , _friend_) ### Description Called when a friend declaration is encountered. ### Parameters - **state** (ClassBlockState) - The state of the class block. - **friend** (FriendDecl) - The friend declaration encountered. ### Return type None ``` ```APIDOC ## on_class_method(_state_ , _method_) ### Description Called when a method of a class is encountered inside of a class. ### Parameters - **state** (ClassBlockState) - The state of the class block. - **method** (Method) - The method encountered. ### Return type None ``` ```APIDOC ## on_class_start(_state_) ### Description Called when a class/struct/union is encountered. If this function returns False, the visitor will not be called for any items inside this class (including on_class_end). ### Parameters - **state** (ClassBlockState) - The state of the class block. ### Return type Optional[bool] ``` ```APIDOC ## on_concept(_state_ , _concept_) ### Description Called when a concept is encountered. ### Parameters - **state** (Union[ExternBlockState[TypeVar('T'), TypeVar('PT')]], NamespaceBlockState[TypeVar('T'), TypeVar('PT')]]) - The state of the current block. - **concept** (Concept) - The concept encountered. ### Return type None ``` ```APIDOC ## on_deduction_guide(_state_ , _guide_) ### Description Called when a deduction guide is encountered. ### Parameters - **state** (Union[ExternBlockState[TypeVar('T'), TypeVar('PT')]], NamespaceBlockState[TypeVar('T'), TypeVar('PT')]]) - The state of the current block. - **guide** (DeductionGuide) - The deduction guide encountered. ### Return type None ``` ```APIDOC ## on_enum(_state_ , _enum_) ### Description Called after an enum is encountered. ### Parameters - **state** (Union[NamespaceBlockState[TypeVar('T'), TypeVar('PT')]], ExternBlockState[TypeVar('T'), TypeVar('PT')]], ClassBlockState[TypeVar('T'), TypeVar('PT')]]) - The state of the current block. - **enum** (EnumDecl) - The enum declaration encountered. ### Return type None ``` ```APIDOC ## on_extern_block_end(_state_) ### Description Called when an extern block ends. ### Parameters - **state** (ExternBlockState) - The state of the extern block. ### Return type None ``` ```APIDOC ## on_extern_block_start(_state_) ### Description Called when an extern block starts. If this function returns False, the visitor will not be called for any items inside this block (including on_extern_block_end). ### Parameters - **state** (ExternBlockState) - The state of the extern block. ### Return type Optional[bool] ``` ```APIDOC ## on_forward_decl(_state_ , _fdecl_) ### Description Called when a forward declaration is encountered. ### Parameters - **state** (Union[NamespaceBlockState[TypeVar('T'), TypeVar('PT')]], ExternBlockState[TypeVar('T'), TypeVar('PT')]], ClassBlockState[TypeVar('T'), TypeVar('PT')]]) - The state of the current block. - **fdecl** (ForwardDecl) - The forward declaration encountered. ### Return type None ``` ```APIDOC ## on_function(_state_ , _fn_) ### Description Called when a function is encountered that isn’t part of a class. ### Parameters - **state** (Union[ExternBlockState[TypeVar('T'), TypeVar('PT')]], NamespaceBlockState[TypeVar('T'), TypeVar('PT')]]) - The state of the current block. - **fn** (Function) - The function encountered. ### Return type None ``` ```APIDOC ## on_include(_state_ , _filename_) ### Description Called once for each `#include` directive encountered. ### Parameters - **state** - The state of the current block. - **filename** (str) - The name of the included file. ### Return type None ``` -------------------------------- ### Function Declaration Parameters Source: https://cxxheaderparser.readthedocs.io/en/latest/types.html Details the parameters and attributes associated with a function declaration in C++. ```APIDOC ## Function Declaration Parameters This section describes the various components and attributes that define a C++ function declaration as parsed by the library. ### Parameters - **return_type** (`Union[Array, Pointer, MoveReference, Reference, Type, None]`): The return type of the function. - **name** (`PQName`): The qualified name of the function. - **parameters** (`List[Parameter]`): A list of parameters the function accepts. - **vararg** (`bool`): True if the function uses variable arguments (`...`). - **doxygen** (`Optional[str]`): Doxygen documentation string, if present. - **attributes** (`List[Attribute]`): Any attributes associated with the function declaration. - **constexpr** (`bool`): True if the function is `constexpr`. - **extern** (`Union[bool, str]`): Specifies the linkage of the function (e.g., `extern "C"`). - **static** (`bool`): True if the function is `static`. - **inline** (`bool`): True if the function is `inline`. - **deleted** (`bool`): True if the function is explicitly deleted. - **has_body** (`bool`): True if the function has a defined body. - **has_trailing_return** (`bool`): True if the function uses a trailing return type syntax. - **template** (`Union[None, TemplateDecl, List[TemplateDecl]]`): Template parameters if the function is a template. - **throw** (`Optional[Value]`): The value of any `throw` specification. - **noexcept** (`Optional[Value]`): The value of any `noexcept` specification. - **msvc_convention** (`Optional[str]`): MSVC-specific calling convention, if specified. - **operator** (`Optional[str]`): The type of operator if this is an operator function. - **raw_requires** (`Optional[Value]`): The raw string of a `requires` clause, if present. ``` -------------------------------- ### AttributeStyle Source: https://cxxheaderparser.readthedocs.io/en/latest/types.html Enumerates the different styles of attributes found in C++ code. ```APIDOC ## AttributeStyle ### Description Indicates what style of attribute was found. ### Members - **CXX**: `[[deprecated]]` - **GCC**: `__attribute__((deprecated))` - **MSVC**: `__declspec(deprecated)` ``` -------------------------------- ### cxxheaderparser.parserstate.NamespaceBlockState Source: https://cxxheaderparser.readthedocs.io/en/latest/custom.html Represents the state for parsing a namespace block, including the namespace declaration. ```APIDOC class cxxheaderparser.parserstate.NamespaceBlockState(_parent_ , _location_ , _namespace_) Parameters: * **parent** (`Union`[`ExternBlockState`[`TypeVar`(`T`), `TypeVar`(`PT`)], `NamespaceBlockState`[`TypeVar`(`T`), `TypeVar`(`PT`)], `None`]) * **location** (`Location`) * **namespace** (`NamespaceDecl`) namespace: NamespaceDecl The incremental namespace for this block parent: ExternBlockState[T, PT] | NamespaceBlockState[T, PT] parent state ```