{"id":21252702,"url":"https://github.com/atomicptr/toolbelt","last_synced_at":"2026-07-13T07:31:59.773Z","repository":{"id":143275966,"uuid":"71699494","full_name":"atomicptr/toolbelt","owner":"atomicptr","description":"Collection of useful header-only util functions, written in C++14.","archived":false,"fork":false,"pushed_at":"2016-11-26T17:31:41.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-06-28T20:31:22.937Z","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/atomicptr.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":"2016-10-23T11:48:57.000Z","updated_at":"2016-10-23T11:49:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"d06b352b-1143-4472-a11c-413c15180991","html_url":"https://github.com/atomicptr/toolbelt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/atomicptr/toolbelt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Ftoolbelt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Ftoolbelt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Ftoolbelt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Ftoolbelt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atomicptr","download_url":"https://codeload.github.com/atomicptr/toolbelt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Ftoolbelt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35414732,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-13T02:00:06.543Z","response_time":119,"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":[],"created_at":"2024-11-21T03:48:29.813Z","updated_at":"2026-07-13T07:31:59.753Z","avatar_url":"https://github.com/atomicptr.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# toolbelt [![Build Status](https://travis-ci.org/atomicptr/toolbelt.svg?branch=master)](https://travis-ci.org/atomicptr/toolbelt)\n\nCollection of useful header-only util functions, written in C++14.\n\n## Usage\n\nJust pick whatever header files you need and drop them  into your project.\n\n## Content\n\n### crc32.hpp\n\nCompile time CRC32.\n\n```cpp\nauto crc = toolbelt::crc32(\"Hello, World\");\n```\n\n### format_time.hpp\n\nFormat std::chrono time strings.\n\n```cpp\nauto now = std::chrono::system_clock::now();\ntoolbelt::format_time(now, \"Today is %A\"); // Today is Friday\n```\n\n### logger.hpp\n\nSimple extensible logger with log levels.\n\nDependencies: **format_time.hpp**\n\n```cpp\ntoolbelt::logger logger;\n\nstd::string name = \"World\";\n\nlogger.log(\"Hello, \", name);\n// [13:37:42][INFO] Hello, World\n\nlogger(toolbelt::log_level::warning).log(\"Oh something went wrong!\");\n// [02:03:04][WARNING] Oh something went wrong!\n```\n\nIf you want to use your custom types, just overload ``std::ostream\u0026 operator\u003c\u003c(std::ostream\u0026, YOUR_TYPE\u0026)``\n\n```cpp\nstruct vec2 {\n    int x;\n    int y;\n};\n\nstd::ostream\u0026 operator\u003c\u003c(std::ostream\u0026 os, const vec2\u0026 v) {\n    os \u003c\u003c \"vec2 x: \" \u003c\u003c v.x \u003c\u003c \", y: \" \u003c\u003c v.y;\n    return os;\n}\n\nvec2 position = get_position();\n\nlogger.log(\"my position is: \", position);\n```\n\n### make_smart.hpp\n\nCreate a ``std::unique_ptr`` from C Constructor/Destructor pairs.\n\n```cpp\n// General usage\nstruct Type { ... };\nType* construct(...);\nvoid destruct(Type*);\n\nauto ptr = toolbelt::make_smart\u003cType\u003e(construct, destruct, arg1, ...);\n\n// Example using SDL2\n...make_smart\u003cSDL_Window\u003e(SDL_CreateWindow, SDL_DestroyWindow, \"Window Title!\", ...);\n```\n\n### os.hpp\n\nSome simple utils to work across different operating systems.\n\n```cpp\nif(toolbelt::current_os == toolbelt::operating_system::windows) {\n    std::cout \u003c\u003c \"I'm on Windows!\" \u003c\u003c std::endl;\n    // Do windows specific code\n}\n\nstd::cout \u003c\u003c \"My OS: \" \u003c\u003c toolbelt::os_name \u003c\u003c std::endl;\n\n// you can also access environment variables\n// NOTE: this will throw an exception if the environment variable does not exist\nstd::cout \u003c\u003c \"My not so secret key is \" \u003c\u003c toolbelt::env(\"SECRETKEY\") \u003c\u003c std::endl;\n\nauto homedir = toolbelt::home_directory();\nauto configdir = toolbelt::user_config_directory();\n\n// There are also a few preprocessor directives, like:\n\n#ifdef TOOLBELT_OS_WINDOWS\n// ...\n#elif TOOLBELT_OS_MACOS\n// ...\n#elif TOOLBELT_OS_LINUX\n// ...\n#elif TOOLBELT_OS_IOS\n// ...\n#elif TOOLBELT_OS_ANDROID\n// ...\n#endif\n```\n\n### string.hpp\n\nA few string utils.\n\n```cpp\n\nauto str = toolbelt::replace(\"Hello, Universe!\", \"Universe\", \"World\"); // Hello, World!\nauto parts = toolbelt::split(\"Good Evening\", ' '); // [\"Good\", \"Evening\"]\nauto str = toolbelt::to_lower(\"CAPSLOCK\"); // capslock\nauto str = toolbelt::to_upper(\"capslock\");  // CAPSLOCK\nauto str = toolbelt::trim(\"   I'M IN SPAAACE    \"); // there is also ltrim and rtrim!\nbool b = toolbelt::ends_with(\"Hello, World\", \"World\"); // true\n```\n\n### unit_tests.hpp\n\nFairly simple way to do unit tests.\n\n```cpp\ntoolbelt::test_suite suite;\n\nsuite.test(\"2 + 2 is 4\", []() {\n    return ExpectEquals(2 + 2, 4);\n});\n\nsuite.test(\"true and true is true\", []() {\n    return ExpectTrue(true \u0026\u0026 true);\n});\n\n// runs the tests, returns true if ALL tests passed\nauto result = suite.run_tests();\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicptr%2Ftoolbelt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomicptr%2Ftoolbelt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicptr%2Ftoolbelt/lists"}