{"id":26784734,"url":"https://github.com/theflash2k/classgen","last_synced_at":"2025-07-22T08:05:29.028Z","repository":{"id":135101818,"uuid":"328154866","full_name":"TheFlash2k/classgen","owner":"TheFlash2k","description":"Generate CPP classes with setters, getters and a single default constructor","archived":false,"fork":false,"pushed_at":"2022-12-04T00:45:12.000Z","size":69,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T10:32:23.376Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/TheFlash2k.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,"publiccode":null,"codemeta":null}},"created_at":"2021-01-09T12:54:17.000Z","updated_at":"2024-01-12T18:17:21.000Z","dependencies_parsed_at":"2023-06-06T04:30:26.429Z","dependency_job_id":null,"html_url":"https://github.com/TheFlash2k/classgen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TheFlash2k/classgen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheFlash2k%2Fclassgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheFlash2k%2Fclassgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheFlash2k%2Fclassgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheFlash2k%2Fclassgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheFlash2k","download_url":"https://codeload.github.com/TheFlash2k/classgen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheFlash2k%2Fclassgen/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266455107,"owners_count":23931354,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-03-29T10:29:27.731Z","updated_at":"2025-07-22T08:05:29.017Z","avatar_url":"https://github.com/TheFlash2k.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ClassGen - A Python3 based script to generate CPP files for custom classes.\n\n- What is output.cpp\n```\nOutput.cpp is the file that will be generated when you simply clone the git and run the program. It has been added so that you can see how the output will look like once stored\n```\n\n### Usage:\nChanges within the code is required:\nCheck `main()` function\n- Change the name of output file\n```python\nfileName = \"output\" # -\u003e Output should be replaced with the name of the file.\n```\n- Change the name of class\n```python\nclassName = \"check\" # -\u003e Replace check with class name\n```\n- Add Methods through dictionary (Sent as arguement to `addMethod()` method which accepts a dictionary of tuple and list as `K:V` pair)\n```python\nmethods = {\n\t(\"bool\", \"hasName\", \"private\") : [],\n\t(\"int\", \"inputAge\", \"public\") : ['int age', 'string name']\n}\ngen.addMethod(methods)\n'''\nTo add new methods, simply append a comma to the end of the current methods dictionary, and keep on adding\nnew methods.\n'''\n```\n- Add Methods through strings\nThere is another way to add attributes, that is by calling `addDirectMethod()` method with two strings, `method` and `mode`. `method` contains the return type and the name of the string as shown in `line 197` in `classgen.py`. Whilst, mode is the visibility. The calling of this function can be seen on `line 203`\n```python\nmode = \"public\"\nmethod = \"string capitalize(string data, int out)\"\n# Test Call 1\ngen.addDirectMethod(method, mode)\n# Test Call 2\ngen.addDirectMethod(data=f\"int totalAge(int age, {format(className.capitalize())} obj)\", mode=\"protected\")\n```\n- Add Attributes through dictionary (Sent as argument to `addAttrib()` method which accepts a dictionary of `string` as a `K:V` pair):\n```python\nattributes = {\n\t\"char* address\" : \"private\",\n\t\"int age\" : \"protected\",\n\t\"string name\" : \"public\",\n\t\"float cgpa\" : \"private\"\n}\ngen.addAttrib(attributes)\n'''\nThe attributes is a dictionary, the key is a string that contains the return type + variable name.\nThe value on the other hand, is the visbility mode of the specific variable in the class\n'''\n```\n- Add Attributes through strings:\nThere is another way to add attributes, that is by calling `addDirectAttrib()` method with two strings, `attribute` and `mode`. `attribute` contains the return type and the name of the string as shown in `line 199` in `classgen.py`. Whilst, mode is the visibility. The calling of this function can be seen on `line 203`\n```python\nmode = \"public\"\nattribute = \"string fatherName\"\n# Test Call 1\ngen.addDirectAttrib(attribute, mode)\n# Test Call 2\ngen.addDirectAttrib(\"int numberObjects\", \"private\")\n```\n- Add other classes to be friend of existing class:\u003cbr\u003e\nWe can declare other classes to be friend of the existing class. Like, consider a class Stack, if in `Node`, we declare this class as friend, the cpp declartion would look like:\n```cpp\nfriend class Stack; // This would be in class Node\n```\nSo, in order to make this happen in python, following method was implemented.\n```python\nfriendClassName = \"Employees\" # This will be passed to the addFriends function to make this class a friend of the existing class\ngen.addFriend(friendClassName) # Calling the friend function adder method.\n```\nThe `friendClassName` represents the name of the class that is to be added as friend. While the method call is pretty self-explanatory\n\n### Why I made this script:\nDuring my exams, I wasted alot of my time writing each setter, getter, constructor and stuff. I was free today and wanted more stuff on my github so decided to write this idk. ;-;\n\n\u003c!--\n[![carbon.png](https://i.postimg.cc/WphxysSH/carbon.png)](https://postimg.cc/RqxP65k7)\n--\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheflash2k%2Fclassgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheflash2k%2Fclassgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheflash2k%2Fclassgen/lists"}