C-mantic

C/C++ code generation for VS Code: Generate function definitions, function declarations, getters, setters, comparison operators, and more.

View the Project on GitHub godot42x/vscode-cmantic

Generate Getters and Setters

Selecting the name of a member variable will suggest the following code-actions 💡.

The Generate Getter and Setter, Generate Getter, and Generate Setter commands will generate accessor functions for a member variable. C-mantic will look for common private member naming schemes in order to generate appropriate function names: If a member variable name begins and/or ends with underscore(s), or if it begins with m_ or s_, these characters will be removed to create the member function names. The Case Style setting controls whether names are generated in snake_case, camelCase, or PascalCase.

Generate Accessors

Additionally, for non-primitive, non-pointer data types, setters will be generated with a const-reference (const &) parameter type. If you would like C-mantic to resolve typedef’s, type-alias’s, and enum’s, enable Cpp: Resolve Types in the settings (This is disabled by default as it may impact the performance of generating setters).

The Accessor: Getter Definition Location and Accessor: Setter Definition Location settings control where the definitions of these member functions are placed (either inline, below class body, or in matching source file).


Besides, you can change the setting of C_mantic.cpp.accessor.getterNamingStyle to determine wether to generate the function name with start with get.

And the C_mantic.cpp.accessor.boolGetterIsPrefix will override the operation above if variable type is boolean.