{"id":24505721,"url":"https://github.com/caseymcc/std_wrappers","last_synced_at":"2025-03-15T08:42:15.061Z","repository":{"id":150339756,"uuid":"105167965","full_name":"caseymcc/std_wrappers","owner":"caseymcc","description":"Wrappers for exporting std templates from libs/dlls","archived":false,"fork":false,"pushed_at":"2017-12-04T15:23:31.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-21T23:33:26.524Z","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/caseymcc.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":"2017-09-28T15:49:14.000Z","updated_at":"2017-09-28T16:09:07.000Z","dependencies_parsed_at":"2023-04-06T09:55:17.191Z","dependency_job_id":null,"html_url":"https://github.com/caseymcc/std_wrappers","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/caseymcc%2Fstd_wrappers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caseymcc%2Fstd_wrappers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caseymcc%2Fstd_wrappers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caseymcc%2Fstd_wrappers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caseymcc","download_url":"https://codeload.github.com/caseymcc/std_wrappers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243707298,"owners_count":20334614,"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":"2025-01-21T23:31:21.964Z","updated_at":"2025-03-15T08:42:15.040Z","avatar_url":"https://github.com/caseymcc.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"This repo provides wrappers for standard library templates so that they can be exported from libs and dlls. So far the following are included.\n\n* shared_ptr\n* string\n* vector\n* list\n* map\n\nThe templates are expected to be included in the library (lib or dll) by including both a header and source file for the template (preferable in a namspace to reduce conflicts). You need to include the actuall stand library class as well as handle import/exporting of the new classes. There are also provided macros to help with the import/export along with the class instantiation. This all can be seen in the example provided with the source.\n\nexample_std.h\n```c\n#ifndef _example_std_h_\n#define _example_std_h_\n\n#include \"example_std_export.h\"\n\n#include \u003cstring\u003e\n#include \u003cvector\u003e\n#include \u003cmemory\u003e\n#include \u003cmap\u003e\n\n#ifdef EXAMPLE_STD_EXPORTS\n#define EXAMPLE_STD_EXTERN\n#define STD_WRAPPER_EXPORT\n#else\n#define EXAMPLE_STD_EXTERN extern\n#endif\n\n#include \"std_wrappers/macro.h\"\n\nnamespace example_std\n{\n\n#include \"std_wrappers/string.h\"\n#include \"std_wrappers/vector.h\"\n\nSTD_WRAP_STRING(EXAMPLE_STD_EXTERN, EXAMPLE_STD_EXPORT);\nSTD_WRAP_VECTOR(EXAMPLE_STD_EXTERN, EXAMPLE_STD_EXPORT, size_t);\n\nstruct EXAMPLE_STD_EXPORT TestStruct\n{\n    int number;\n    string value;\n};\n\n#include \"std_wrappers/shared_ptr.h\"\n\nSTD_WRAP_SHARED_PTR(EXAMPLE_STD_EXTERN, EXAMPLE_STD_EXPORT, TestStruct);\n\n#include \"std_wrappers/map.h\"\n\nSTD_WRAP_MAP(EXAMPLE_STD_EXTERN, EXAMPLE_STD_EXPORT, string, int);\n\n}//namespace example_std\n\n#endif//_example_std_h_\n```\n\nexample_std.cpp\n```c\n#include \"example_std.h\"\n\nnamespace example_std\n{\n\n#include \"std_wrappers\\shared_ptr.cpp\"\n#include \"std_wrappers\\string.cpp\"\n#include \"std_wrappers\\vector.cpp\"\n#include \"std_wrappers\\map.cpp\"\n\n}//namespace example_std\n```\n\nSetting up the wrappers this way allows the stand library implementation to be compiled into the library without going through the effort of creating a similar c interface. The wrapped classes can be used like thier base counter parts with some limitations. The should be accesible to an std library algorithm that works off iterators. \n\n```c\nexample_std::vector\u003csize_t\u003e vec;\n\nauto iter=std::find(vec.begin(), vec.end(), 2);\n```\n\nThey can be readily converted to their std counter parts using copy constructors\n\n```c\nexample_std::vector\u003csize_t\u003e vec;\n\nstd::vector\u003csize_t\u003e values(vec.begin(), vec.end());\n```\n\nOn the library side if you declare STD_WRAPPER_EXPORT this will allow the wrappers to use all of the the functionality of the std versions as well as to allow the wrappers to copy or move directly from the std version.\n\n```c\nvector\u003csize_t\u003e testVectorReturnFromBase()\n{\n    std::vector\u003csize_t\u003e values;\n\n    values.push_back(10);\n    values.push_back(20);\n \n    return vector\u003csize_t\u003e(values);\n}\n```\n\nThe wrappers themselves will inclure extra function calls on every call that is made to the lower std template but it allows for easy exchange on the libraries interface at the cost of this overhead.\n\nThis is a rough draft, feel free to add any support or give feedback.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaseymcc%2Fstd_wrappers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaseymcc%2Fstd_wrappers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaseymcc%2Fstd_wrappers/lists"}