{"id":20602347,"url":"https://github.com/jbaldwin/libchain","last_synced_at":"2025-03-06T16:25:30.176Z","repository":{"id":45607072,"uuid":"253344446","full_name":"jbaldwin/libchain","owner":"jbaldwin","description":"Easy to use std::string enhancements.","archived":false,"fork":false,"pushed_at":"2021-12-05T18:58:30.000Z","size":224,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-17T01:50:36.878Z","etag":null,"topics":["cpp","cpp17","cpp17-library","modern-cpp","string","string-manipulation"],"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/jbaldwin.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-04-05T22:28:14.000Z","updated_at":"2023-04-12T11:07:09.000Z","dependencies_parsed_at":"2022-09-11T15:41:33.251Z","dependency_job_id":null,"html_url":"https://github.com/jbaldwin/libchain","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/jbaldwin%2Flibchain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbaldwin%2Flibchain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbaldwin%2Flibchain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbaldwin%2Flibchain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jbaldwin","download_url":"https://codeload.github.com/jbaldwin/libchain/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242243512,"owners_count":20095723,"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","cpp17","cpp17-library","modern-cpp","string","string-manipulation"],"created_at":"2024-11-16T09:13:36.215Z","updated_at":"2025-03-06T16:25:30.149Z","avatar_url":"https://github.com/jbaldwin.png","language":"C++","readme":"# libchain - C++17 std::string utility chain belt\n\n[![CI](https://github.com/jbaldwin/libchain/workflows/build/badge.svg)](https://github.com/jbaldwin/libchain/workflows/build/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/jbaldwin/libchain/badge.svg?branch=master)](https://coveralls.io/github/jbaldwin/libchain?branch=master)\n[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/jbaldwin/libchain.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/jbaldwin/libchain/context:cpp)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/89a3474520bc4ee682f348c8b4b09cf8)](https://www.codacy.com/gh/jbaldwin/libchain/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=jbaldwin/libchain\u0026amp;utm_campaign=Badge_Grade)\n[![language][badge.language]][language]\n[![license][badge.license]][license]\n\nhttps://github.com/jbaldwin/libchain\n\n## Usage\n\n### Requirements\n    C++17 compiler (g++/clang++)\n        Tested on g++-9 and clang++-9\n    CMake\n    make and/or ninja\n\n### Instructions\n\n#### Building\n    mkdir Release \u0026\u0026 cd Release\n    cmake -DCMAKE_BUILD_TYPE=Release ..\n    cmake --build .\n\n## Examples\n\n```C++\n    #include \u003ciostream\u003e\n    \n    #include \u003cchain/chain.hpp\u003e\n    \n    int main()\n    {\n        using namespace chain;\n    \n        auto print_parts = [](auto\u0026 parts) {\n            for (const auto\u0026 part : parts)\n            {\n                std::cout \u003c\u003c part \u003c\u003c \" \";\n            }\n            std::cout \u003c\u003c \"\\n\";\n        };\n    \n        // A simple csv split. split() only allocates space for the std::string_view\n        // values that it returns, it does not make any copies of the input data.\n        auto parts1 = str::split(\"1,2,3\", ',');\n        // parts1 = { \"1\", \"2\", \"3\" }\n        print_parts(parts1);\n    \n        // A split mapped into integers.\n        auto parts2 = str::split_map\u003cint64_t\u003e(\n            \"1,2,3\", ',', [](std::string_view part) { return str::to_number\u003cint64_t\u003e(part).value_or(0); });\n        // parts2 = { 1, 2, 3 }\n        print_parts(parts2);\n    \n        // A pre-allocated split, for large splits to reduce allocations.\n        std::vector\u003cstd::string_view\u003e parts3{};\n        parts3.reserve(128);\n        str::split(\"1,2,3,...,128\", ',', parts3);\n        // parts3 = { \"1\", \"2\", \"3\", ... , \"128\" }\n        print_parts(parts3);\n    \n        // A split with zero allocations.\n        str::split_for_each(\"1,2,3,4,5\", ',', [](std::string_view part) {\n            // 1, 2, 3, 4, 5\n            std::cout \u003c\u003c part \u003c\u003c \", \";\n            // Can optionally provide a lambda that returns -\u003e bool type,\n            // returning true continues splitting, returning false stops splitting.\n        });\n        std::cout \u003c\u003c \"\\n\";\n    \n        // A simple csv join.\n        std::vector\u003cint64_t\u003e parts4{1, 2, 3};\n        auto                 joined1 = str::join(parts4, ',');\n        // joined1 == \"1,2,3\"\n        std::cout \u003c\u003c joined1 \u003c\u003c \"\\n\";\n    \n        // A map join which squares its parts first.\n        std::vector\u003cint64_t\u003e parts5{1, 2, 3};\n        // \"1,4,9\"\n        std::cout \u003c\u003c str::map_join(parts5, ',', [](int64_t x) { return x * x; }) \u003c\u003c \"\\n\";\n    \n        // Simple consistent to number api, leverages std::optional instead of exceptions.\n        auto value = str::to_number\u003cuint64_t\u003e(\"420\").value_or(0);\n        // value == 420\n        std::cout \u003c\u003c value \u003c\u003c \"\\n\";\n    \n        return 0;\n    }\n````\n\n## Support\n\nFile bug reports, feature requests and questions using [GitHub Issues](https://github.com/jbaldwin/libchain/issues)\n\n## Readme updates\nTo edit this file the template is located at `.githooks/readme-template.md`, editing it directly in the root README.md will be overwritten by the `git pre-commit` hook which automatically replaces the code portions of this file with the appropriate examples.\n\n## Code formatting\nThis library has a `git pre-commit` hook which is installed when `cmake` is invoked.  Any files that are commited will automatically have `clang-format` run on them before.\n\nCopyright © 2020, Josh Baldwin\n\n[badge.language]: https://img.shields.io/badge/language-C%2B%2B17-yellow.svg\n[badge.license]: https://img.shields.io/badge/license-MIT-blue\n\n[language]: https://en.wikipedia.org/wiki/C%2B%2B17\n[license]: https://en.wikipedia.org/wiki/MIT_License\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbaldwin%2Flibchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjbaldwin%2Flibchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbaldwin%2Flibchain/lists"}