{"id":33003022,"url":"https://github.com/netcan/config-loader","last_synced_at":"2025-12-27T12:14:30.533Z","repository":{"id":56789221,"uuid":"378921308","full_name":"netcan/config-loader","owner":"netcan","description":"Simple C++ Config Loader Framework(Serialization \u0026 Reflection)","archived":false,"fork":false,"pushed_at":"2023-07-11T10:40:46.000Z","size":133,"stargazers_count":189,"open_issues_count":3,"forks_count":33,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-05-02T16:08:37.949Z","etag":null,"topics":["cpp","deserializer","json","serializer","xml","yaml"],"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/netcan.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}},"created_at":"2021-06-21T12:22:17.000Z","updated_at":"2024-04-10T12:34:47.000Z","dependencies_parsed_at":"2024-01-03T01:19:57.481Z","dependency_job_id":"71b57a74-8502-427a-8b62-5e5ce4b9bd42","html_url":"https://github.com/netcan/config-loader","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/netcan/config-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netcan%2Fconfig-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netcan%2Fconfig-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netcan%2Fconfig-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netcan%2Fconfig-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netcan","download_url":"https://codeload.github.com/netcan/config-loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netcan%2Fconfig-loader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285028340,"owners_count":27102545,"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-11-18T02:00:05.759Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["cpp","deserializer","json","serializer","xml","yaml"],"created_at":"2025-11-13T14:00:38.908Z","updated_at":"2025-11-18T08:03:16.080Z","avatar_url":"https://github.com/netcan.png","language":"C++","readme":"# config-loader [中文版](README_CN.md)\n`config-loader` is a static reflection framework written in C++17 from **parse configuration file** to **native data structure**. It has the following characteristics:\n\n- Simple interface, users need to **define data structure** and provide corresponding **configuration file**, the framework uses meta-programming technology to generate **load** interface\n- The design conforms to the opening and closing principle, extends the data structure without modifying the framework\n- Currently supports XML, JSON and YAML format configuration files, a variety of methods can be **flexibly composed**\n- Lightweight, easy to integrate, less than ~1000 lines of code\n- Support nested data structure, STL container\n- Complete test cases\n- Support from native data structure to config file, stringify data structure\n\nFuture plans:\n\n- Provide additional C++20 version\n\n## Build \u0026 Run\nBuild\n\n```shell\n$ git clone --recursive https://github.com/netcan/config-loader.git\n$ cd config-loader\n$ mkdir build\n$ cd build\n$ cmake ..\n$ make -j\n```\n\nRun\n\n```shell\n$ cd bin/\n$ ./config_loader_test\n```\n\n## Quickly start\n\nFirstly use `DEFINE_SCHEMA` macro to define the data structure:\n\n```cpp\n// define and reflect a struct\nDEFINE_SCHEMA(Point,                          // struct Point {\n              (double) x,                     //     double x;\n              (double) y);                    //     double y;\n                                              // };\n\n// vector and string\nDEFINE_SCHEMA(SomeOfPoints,                   // struct SomeOfPoints {\n              (std::string) name,             //     std::string name;\n              (std::vector\u003cPoint\u003e) points);   //     std::vector\u003cPoint\u003e points;\n                                              // };\n```\n\nProvide configuration files, using `loadXML2Obj/loadJSON2Obj/loadYAML2Obj` interfaces:\n\n```cpp\nSomeOfPoints someOfPoints;\nauto res = loadJSON2Obj(someOfPoints, [] {\n    return R\"(\n        {\n            \"name\": \"Some of points\",\n            \"points\":[\n                { \"x\": 1.2, \"y\": 3.4 },\n                { \"x\": 5.6, \"y\": 7.8 },\n                { \"x\": 2.2, \"y\": 3.3 }\n            ]\n        }\n    )\";\n});\nREQUIRE(res == Result::SUCCESS);\nREQUIRE_THAT(someOfPoints.name, Equals(\"Some of points\"));\nREQUIRE(someOfPoints.points.size() == 3);\n```\n\nOr, through an XML configuration file.\n```cpp\nSomeOfPoints someOfPoints;\nauto res = loadXML2Obj(someOfPoints, \"configs/xml/SomeOfPoints.xml\");\nREQUIRE(res == Result::SUCCESS);\nREQUIRE_THAT(someOfPoints.name, Equals(\"Some of points\"));\nREQUIRE(someOfPoints.points.size() == 3);\n```\n\nThrough a YAML configuration file.\n```cpp\nSomeOfPoints someOfPoints;\nauto res = loadYAML2Obj(someOfPoints, [] {\nreturn R\"(\n        name: Some of points\n        points:\n          - x: 1.2\n            y: 3.4\n          - x: 5.6\n            y: 7.8\n          - x: 2.2\n            y: 3.3\n    )\";\n});\nREQUIRE(res == Result::SUCCESS);\nREQUIRE_THAT(someOfPoints.name, Equals(\"Some of points\"));\nREQUIRE(someOfPoints.points.size() == 3);\n```\n\n## Notice\nThe current framework depends on the following libraries:\n- `tinyxml2`, used for parsing xml configuration files\n- `jsoncpp`, used for parsing json configuration files\n- `yamlcpp`, used for parsing yaml configuration files\n\nIn the future, these libraries may be enabled through CMake options to avoid unnecessary dependencies in actual use: only using xml will only rely on the xml parsing library.\n\nThis framework requires configuration files to be provided in a standardized format. Taking XML as an example, the field name is required to correspond to the XML tag name, and the value corresponds to the text content of the XML; for the `map` data structure, the tag uses the attribute `name` as the key name.\n\nThe semantics of the current error code.\n```cpp\nenum class Result {\n    SUCCESS,              // parse successfully\n    ERR_EMPTY_CONTENT,    // The parsing file is empty\n    ERR_ILL_FORMED,       // Illegal parsing file\n    ERR_MISSING_FIELD,    // Missing field\n    ERR_EXTRACTING_FIELD, // Failed to parse the value\n    ERR_TYPE,             // Type error\n};\n```\n","funding_links":[],"categories":["Reflection"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetcan%2Fconfig-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetcan%2Fconfig-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetcan%2Fconfig-loader/lists"}