{"id":15047749,"url":"https://github.com/ubpa/udrefl","last_synced_at":"2025-04-06T07:14:28.171Z","repository":{"id":39366042,"uuid":"280821262","full_name":"Ubpa/UDRefl","owner":"Ubpa","description":"Ubpa Dynamic Reflection","archived":false,"fork":false,"pushed_at":"2022-03-05T13:46:24.000Z","size":955,"stargazers_count":375,"open_issues_count":2,"forks_count":64,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-06T07:14:24.191Z","etag":null,"topics":["cpp","cpp20","reflection"],"latest_commit_sha":null,"homepage":"","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/Ubpa.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}},"created_at":"2020-07-19T08:11:21.000Z","updated_at":"2025-03-26T08:51:46.000Z","dependencies_parsed_at":"2022-08-01T08:19:44.168Z","dependency_job_id":null,"html_url":"https://github.com/Ubpa/UDRefl","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ubpa%2FUDRefl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ubpa%2FUDRefl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ubpa%2FUDRefl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ubpa%2FUDRefl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ubpa","download_url":"https://codeload.github.com/Ubpa/UDRefl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445681,"owners_count":20939961,"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":["cpp","cpp20","reflection"],"created_at":"2024-09-24T21:04:10.150Z","updated_at":"2025-04-06T07:14:28.154Z","avatar_url":"https://github.com/Ubpa.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"```\n\n __    __   _______  .______       _______  _______  __      \n|  |  |  | |       \\ |   _  \\     |   ____||   ____||  |     \n|  |  |  | |  .--.  ||  |_)  |    |  |__   |  |__   |  |     \n|  |  |  | |  |  |  ||      /     |   __|  |   __|  |  |     \n|  `--'  | |  '--'  ||  |\\  \\----.|  |____ |  |     |  `----.\n \\______/  |_______/ | _| `._____||_______||__|     |_______|\n                                                             \n\n```\n\n[![repo-size](https://img.shields.io/github/languages/code-size/Ubpa/UDRefl?style=flat)](https://github.com/Ubpa/UDRefl/archive/master.zip) [![tag](https://img.shields.io/github/v/tag/Ubpa/UDRefl)](https://github.com/Ubpa/UDRefl/tags) [![license](https://img.shields.io/github/license/Ubpa/UDRefl)](LICENSE) \n\n⭐ Star us on GitHub — it helps!\n\n# UDRefl\n\n\u003e **U**bpa **D**ynamic **R**eflection\n\nExtremely **fast** and **powerful** C++20 dynamic reflection library\n\n## Documentaion [-\u003e](doc/) \n\n- [to-do](doc/todo.md) \n- [change log](doc/change_log.md) \n- manual (TODO)\n- overview\n  - [中文](doc/overview_zh_CN.md) \n- introduction\n  - [English](doc/introduction_en_US.md) \n  - [中文](doc/introduction_zh_CN.md) \n\n## How to Use\n\n\u003e the example code is [here](src/test/00_readme/main.cpp), other examples is [here](https://github.com/Ubpa/UDRefl#other-example) \n\nSuppose you need to reflect `struct Vec` \n\n```c++\nstruct Vec {\n  float x;\n  float y;\n  float norm() const {\n    return std::sqrt(x * x + y * y);\n  }\n};\n```\n\n### Manual registration\n\n```c++\nMngr.RegisterType\u003cVec\u003e();\nMngr.AddField\u003c\u0026Vec::x\u003e(\"x\");\nMngr.AddField\u003c\u0026Vec::y\u003e(\"y\");\nMngr.AddMethod\u003c\u0026Vec::norm\u003e(\"norm\");\n```\n\n### Iterate over members\n\n```c++\nfor (auto\u0026\u0026 [name, info] : FieldRange_of\u003cVec\u003e)\n  std::cout \u003c\u003c name.GetView() \u003c\u003c std::endl;\n\nfor (auto\u0026\u0026 [name, info] : MethodRange_of\u003cVec\u003e)\n  std::cout \u003c\u003c name.GetView() \u003c\u003c std::endl;\n```\n\n### Constructing types\n\n```c++\nSharedObject v = Mngr.MakeShared(Type_of\u003cVec\u003e);\nstd::cout \u003c\u003c v.GetType().GetName() \u003c\u003c std::endl; // prints \"Vec\"\n```\n\n### Set/get variables\n\n```c++\nv.Var(\"x\") = 3;\nv.Var(\"y\") = 4;\nstd::cout \u003c\u003c \"x: \" \u003c\u003c v.Var(\"x\") \u003c\u003c std::endl;\n```\n\n### Invoke Methods\n\n```c++\nstd::cout \u003c\u003c \"norm: \" \u003c\u003c v.Invoke(\"norm\") \u003c\u003c std::endl;\n```\n\n### Iterate over variables\n\n```c++\nfor (auto\u0026\u0026 [name, var] : v.GetVars())\n  std::cout \u003c\u003c name.GetView() \u003c\u003c \": \" \u003c\u003c var \u003c\u003c std::endl;\n```\n\n### other example\n\n- [const \u0026 static](src/test/02_const_static/main.cpp) \n- [method](src/test/03_method/main.cpp) \n- [enum](src/test/04_enum/main.cpp) \n- [overload](src/test/05_overload/main.cpp) \n- [inheritance](src/test/06_inheritance/main.cpp) \n- [virtual inheritance](src/test/07_virtual/main.cpp) \n- [attr](src/test/08_attr/main.cpp) \n- [lifetime (ctor, dtor)](src/test/09_lifecycle/main.cpp) \n- [dynamic field](src/test/10_dynamic/main.cpp) \n- [invoke](src/test/11_invoke/main.cpp) \n- [meta function](src/test/12_Meta/main.cpp) \n- [reference](src/test/13_ref/main.cpp) \n- [serialize](src/test/15_serializer/main.cpp) \n- [container](src/test/16_container/main.cpp) \n- [compatible](src/test/17_compatible/main.cpp) \n- [tuple](src/test/18_tuple/main.cpp) \n- [pointer](src/test/19_pointer/main.cpp) \n- [array](src/test/20_array/main.cpp) \n- [string](src/test/21_string/main.cpp) \n- [variant](src/test/22_variant/main.cpp) \n- [optional](src/test/23_optional/main.cpp) \n- [bootstrap](src/test/ext/00_bootstrap/main.cpp) \n- [[data-driven] `RegisterType`](src/test/24_dd_type/main.cpp) \n\n## Features\n\n- global fields, methods or enums\n- classes with **single**-, **multiple**- and **virtual**-inheritance\n- constructors (arbitrary argument count) and destructors\n- methods (**virtual**, **abstract**, **overloaded**, arbitrary argument count) : you can pass arguments by a buffer (on stack or heap)\n- ability to invoke methods of classes from any arbitrary class level\n- argument type auto **convertion** when invoking method\n- no header pollution: the reflection information is created in the cpp file to minimize compile time when modifying the data\n- working with custom types without the need of having the declaration of the type available at compile time (useful for plugins)\n- possibility to add additional **attribute** to all reflection objects\n- reference\n- pointer, array\n- standard container, iterator\n- **meta** function\n  - operations: `operator +`, `operator-`, ...\n  - container: `begin`, `end`, `empty`, `size`, ...\n- bootstrap\n- **no** macro usage\n- **no** rtti required\n- **no** exceptions (this feature come with cost and is also regularly disabled on consoles)\n- **no** external compiler or tool needed, only standard ISO C++20\n\n## Compiler compatibility\n\n- Clang/LLVM \u003e= 10.0\n- GCC \u003e= 10.0\n- MSVC \u003e= 1926\n\n\u003e Tested platforms:\n\u003e\n\u003e - Windows 10: VS2019 16.8.5\n\u003e\n\u003e - Ubuntu 20: GCC 10.2, Clang 11.0\n\u003e\n\u003e - MacOS 11.0 : GCC 10.2\n\u003e\n\u003e   \u003e AppleClang 12 and Clang 11 is not supported\n\n## Licensing\n\nYou can copy and paste the license summary from below.\n\n```\nMIT License\n\nCopyright (c) 2020 Ubpa\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fubpa%2Fudrefl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fubpa%2Fudrefl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fubpa%2Fudrefl/lists"}