{"id":13730438,"url":"https://github.com/nikoladimitroff/Vzor","last_synced_at":"2025-05-08T03:30:30.031Z","repository":{"id":74509784,"uuid":"198717327","full_name":"nikoladimitroff/Vzor","owner":"nikoladimitroff","description":"Vzor is a reflection library for C++, with interface in Python and C++, macroless, intrusiveless, working on top modern C++ attributes","archived":false,"fork":false,"pushed_at":"2019-10-08T16:12:41.000Z","size":130,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-14T21:38:01.360Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nikoladimitroff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2019-07-24T22:23:11.000Z","updated_at":"2024-08-16T08:38:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"94ef3e42-b9f1-49a4-8bfc-a9e6423c01d9","html_url":"https://github.com/nikoladimitroff/Vzor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikoladimitroff%2FVzor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikoladimitroff%2FVzor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikoladimitroff%2FVzor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikoladimitroff%2FVzor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikoladimitroff","download_url":"https://codeload.github.com/nikoladimitroff/Vzor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252992674,"owners_count":21837166,"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":[],"created_at":"2024-08-03T02:01:14.890Z","updated_at":"2025-05-08T03:30:30.022Z","avatar_url":"https://github.com/nikoladimitroff.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# Vzor\n\nVzor is a reflection library for C++. Unlike other existing reflection systems, this one focuses on preserving your code's readability, without adding macros and other intermediate languages. You use standard C++ attributes to mark types from reflection and you use standard C++ to query type info at runtime.\n\nVzor firstly runs a python program which extracts valuable information from your code and then generates a database-like file containing all of the information necessary, accessible from your C++.\n\nThe library is a work in progress - unstable and unusable. I am happy to hear your feedback, so do scroll below for an overview and let me know what you think (open an issue or contact me directly over email).\n\n## Requirements\n\n* C++11 compatible compiler\n* Python 3.4\n\n## Usage\n\nPut `[[reflect::type]]` on types you want to reflect and `[[reflect::data]]` on data members:\n\n```cpp\nstruct [[reflect::type]] Vector3\n{\n\t[[reflect::data]]\n\tfloat X;\n\t[[reflect::data]]\n\tfloat Y;\n\t[[reflect::data]]\n\tfloat Z;\n};\n```\n\nThen query information about your type:\n\n```cpp\nconst Vzor::ReflectedType\u0026 vectorTypeInfo = Vzor::TypeOf\u003cVector3\u003e();\nprintf(\"The name of type is %s.\\n\", vectorTypeInfo.Name);\nfor (int i = 0; i \u003c 3; i++)\n{\n    printf(\"Its next member is named %s and of type %s\",\n        vectorTypeInfo.DataMembers[i].Name,\n        Vzor::TypeOf(vectorTypeInfo.DataMembers[i].TypeId).Name);\n}\n```\n\nYou can also query query information about your type (as long as your type derives from `Vzor::EnableReflectionFromThis`):\n\n```cpp\nclass [[reflect::type]] TransformData : public Vzor::EnableReflectionFromThis\u003cTransformData\u003e\n{\n\t[[reflect::data]]\n\tQuaternion Rotation;\n\t[[reflect::data]]\n\tVector3 Translation;\n\t[[reflect::data]]\n\tfloat Scale;\n};\n...\n\nTransformData data;\nconst ReflectedType\u0026 typeFromInstance = Vzor::TypeOf(data);\nprintf(\"My obj is of type: %s\", typeFromInstance.Name);\n```\n\n## Integration\n\n* Download this repo. You'd need the *generator* and the *include* dirs.\n* Include the *include/vzor/vzor.h* header in your files as you see fit.\n* Run `python generator/vzor.py` passing the folders you'd like reflected. Any *\\*.h* / *\\*.hpp* files\nwill be reflected.\n* This will create one extra header file for each reflected header (*vzorgenerated/X.h* for every X.h in the original\ndir. It will also generated a single *VzorDatabase.cpp* file.\n* Add `#include \"vzorgenerated/Foo.h\"` as the last line of *Foo.h* in every reflected header, e.g.\n```cpp\n// If this is vector3.h, define your class\nstruct [[reflect::type]] Vector3\n{\n\t[[reflect::data]]\n\tfloat X;\n\t[[reflect::data]]\n\tfloat Y;\n\t[[reflect::data]]\n\tfloat Z;\n};\n// And then include the generated file\n#include \"vzorgenerated/Vector3.h\"\n```\n* Add *vzorgenerated/VzorDatabase.cpp* to your own project. This file contains the bulk of the information\nand requires you to compile it alongside your assembly.\n\n## What it can do currently\n\n* Reflect a folder of C++ header files passed to the generator python script\n* Generate descriptions of your types from headers\n* Provides a simple API to query properties of any reflected types.\n\nExplore the public API to learn more, which right now consits of these:\n- `Vzor::ReflectedType` - stores data for some type\n- `Vzor::ReflectedVariable` - stores data for some variable (usually a data member of a type)\n- `Vzor::TypeOf` - an overloaded freestanding function which let's you statically query the type of a class\n- `Vzor::EnableReflectionFromThis` - the class you should be inheriting from if you want your objects to know their own types\n\nSee the tests project for examples.\n\n## Missing features\n\n1. Reflecting nested classes\n1. No support for types in different namespaces with the same names.\n1. No docs\n1. No support for const in pointers (e.g. `Foo const *`)\n1. Performance / stress / sanity tests\n1. Support for accessing actual property / function values (atm you can see a description of the properties, but can't access their value)\n1. Support for functions\n1. Support for enums\n1. Better error reporting\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikoladimitroff%2FVzor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikoladimitroff%2FVzor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikoladimitroff%2FVzor/lists"}