{"id":18662351,"url":"https://github.com/dimits-ts/cppautomationtools","last_synced_at":"2026-04-21T16:32:23.024Z","repository":{"id":103795013,"uuid":"532049330","full_name":"dimits-ts/CppAutomationTools","owner":"dimits-ts","description":"Python scripts that generate various kinds of C++ header and source files according to YAML config files.","archived":false,"fork":false,"pushed_at":"2022-09-17T18:38:47.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-18T03:39:03.925Z","etag":null,"topics":["devops-tools","enum","script","source-code-generation","yaml"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dimits-ts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-09-02T19:09:52.000Z","updated_at":"2023-10-02T16:29:18.000Z","dependencies_parsed_at":"2024-02-28T17:01:58.321Z","dependency_job_id":null,"html_url":"https://github.com/dimits-ts/CppAutomationTools","commit_stats":null,"previous_names":["dimits-ts/cppautomationtools"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dimits-ts/CppAutomationTools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimits-ts%2FCppAutomationTools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimits-ts%2FCppAutomationTools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimits-ts%2FCppAutomationTools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimits-ts%2FCppAutomationTools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dimits-ts","download_url":"https://codeload.github.com/dimits-ts/CppAutomationTools/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimits-ts%2FCppAutomationTools/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262950293,"owners_count":23389638,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["devops-tools","enum","script","source-code-generation","yaml"],"created_at":"2024-11-07T08:11:41.744Z","updated_at":"2026-04-21T16:32:17.983Z","avatar_url":"https://github.com/dimits-ts.png","language":"Python","readme":"# CppAutomationTools\n\nPython scripts that generate C++ header and source files according to YAML config files.\n\nUsed to automate code generation in [this project](https://github.com/Anastasis575/DND-Character-Sheets).\n\n## Auto enum\nA script that produces a C++ enum class with a list of values, their names (string mappings), documentation comments and value access methods (get all values, get string of value).\n\nThe script can place the enum in a specified namespace and its implementation in a separate namespace (so as to hide implementation details).\n\n[Example](#auto-enum-example)\n\n\n\n## Auto constants\nA script that produces a C++ header containing key-value pairs. Supports simple data types such as int, float, bool and std::string. The constants can be placed either on the global or on a specified namespace.\n\n[Example](#auto-constants-example)\n\n## How to run\nTo run any of the two scripts include the `generator.py` file alongside the script you want to execute. Then execute the script like this:\n```bash\npython \u003cscript file\u003e \u003cinput file\u003e \u003coutput directory\u003e \n```\nWhere the input file must be a file following YAML syntax, and the output directory is the directory where the generated files will be placed.\n\n## Examples\n\n###   Auto enum example\n\nenums.yml:\n```yaml\nAttribute: \n  details_namespace: entity_details\n  namespace: DND\n  type: enum\n  documentation: |\n    /**\n    * @brief An enum describing the basic stats of a character.\n    * @author Dimitris Tsirmpas\n    */\n  values:\n    - Strength\n    - Dexterity\n    - Constitution\n    - Intelligence\n    - Wisdom\n    - Charisma\n```\n\nAttribute.h:\n```cpp\n#pragma once\n#include \u003cunordered_map\u003e\n\nnamespace DND {\n\t/**\n\t* @brief An enum describing the basic stats of a character.\n\t* @author Dimitris Tsirmpas\n\t*/\n\tenum class Attribute {\n\t\tStrength,\n\t\tDexterity,\n\t\tConstitution,\n\t\tIntelligence,\n\t\tWisdom,\n\t\tCharisma,\n\t};\n\t\n\t\n\tstd::string attributeToString(DND::Attribute attribute);\n\t\n\t\n\tstd::vector\u003cAttribute\u003e attributeValues();\n\t\n\tnamespace entity_details {\n\t\textern const std::unordered_map\u003cAttribute, std::string\u003e ATTRIBUTE_MAP;\n\t}\n}\n```\n\nAttribute.cpp\n```cpp\n#include \"Attribute.h\"\n#include \u003cstring\u003e\n#include \u003cutility\u003e\n#include \u003calgorithm\u003e\n\nnamespace DND {\n\t\n\tstd::string attributeToString(DND::Attribute attribute) {\n\t\treturn entity_details::ATTRIBUTE_MAP.find(attribute)-\u003esecond;\n\t}\n\t\n\tstd::vector\u003cAttribute\u003e attributeValues() {\n\t\tstd::vector\u003cDND::Attribute\u003e v;\n\t\tfor each (auto it in entity_details::ATTRIBUTE_MAP) {\n\t\t\tv.push_back(it.first);\n\t\t}\n\t\treturn v;\n\t}\n\t\n\tnamespace entity_details {\n\t\tconst std::unordered_map\u003cAttribute, std::string\u003e ATTRIBUTE_MAP = \n\t\t {\n\t\t\tstd::make_pair(Attribute::Strength, \"Strength\"),\n\t\t\tstd::make_pair(Attribute::Dexterity, \"Dexterity\"),\n\t\t\tstd::make_pair(Attribute::Constitution, \"Constitution\"),\n\t\t\tstd::make_pair(Attribute::Intelligence, \"Intelligence\"),\n\t\t\tstd::make_pair(Attribute::Wisdom, \"Wisdom\"),\n\t\t\tstd::make_pair(Attribute::Charisma, \"Charisma\"),\n\t\t};\n\t}\n}\n```\n\n\n###  Auto constants example\nrules.yml:\n```yaml\nRules:\n    type: constants\n    namespace: DND::entity_details\n    min_attribute_value : 0\n    max_attribute_value : 20\n    min_level : 1\n    max_level : 20\n    min_hp : 0\n    max_hp : 9999\n    min_ac : -5\n    max_ac : 32\n    min_speed : 1\n    max_speed : 9999\n    default_level : 1\n    default_hp : 1\n    default_ac : 0\n    default_speed : 0\n    extension: .chr \n```\n\nRules.h:\n```cpp\n#pragma once\n#include \u003cstring\u003e\n\nnamespace DND {\n\tnamespace entity_details {\n\t\tconst int MIN_ATTRIBUTE_VALUE = 0;\n\t\tconst int MAX_ATTRIBUTE_VALUE = 20;\n\t\tconst int MIN_LEVEL = 1;\n\t\tconst int MAX_LEVEL = 20;\n\t\tconst int MIN_HP = 0;\n\t\tconst int MAX_HP = 9999;\n\t\tconst int MIN_AC = -5;\n\t\tconst int MAX_AC = 32;\n\t\tconst int MIN_SPEED = 1;\n\t\tconst int MAX_SPEED = 9999;\n\t\tconst int DEFAULT_LEVEL = 1;\n\t\tconst int DEFAULT_HP = 1;\n\t\tconst int DEFAULT_AC = 0;\n\t\tconst int DEFAULT_SPEED = 0;\n\t\tinline const std::string EXTENSION = \".chr\";\n\t}\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimits-ts%2Fcppautomationtools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimits-ts%2Fcppautomationtools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimits-ts%2Fcppautomationtools/lists"}