{"id":18484310,"url":"https://github.com/cloud11665/str","last_synced_at":"2025-07-24T02:32:58.470Z","repository":{"id":166616209,"uuid":"642063821","full_name":"cloud11665/str","owner":"cloud11665","description":"Lightweight C++ string type with a configuable local buffer","archived":false,"fork":false,"pushed_at":"2023-05-18T22:48:52.000Z","size":62,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-22T18:05:46.894Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"ocornut/str","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloud11665.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-05-17T18:33:22.000Z","updated_at":"2023-05-18T23:19:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"aa1736d1-0ffb-4bec-9153-f0f4e257cbe4","html_url":"https://github.com/cloud11665/str","commit_stats":null,"previous_names":["cloud11665/str"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cloud11665/str","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud11665%2Fstr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud11665%2Fstr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud11665%2Fstr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud11665%2Fstr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloud11665","download_url":"https://codeload.github.com/cloud11665/str/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud11665%2Fstr/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266785483,"owners_count":23983824,"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-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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-06T12:39:20.688Z","updated_at":"2025-07-24T02:32:58.434Z","avatar_url":"https://github.com/cloud11665.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Str v0.40\n## Simple C++ string type with an optional local buffer, by Omar Cornut, cloud11665\nhttps://github.com/cloud11665/str\n\n### License:\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;This software is in the public domain. Where that dedication is not  \n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;recognized, you are granted a perpetual, irrevocable license to copy,  \n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;distribute, and modify this file as you see fit.\n\n### Usage:\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;Include this file in whatever places need to refer to it.\n\n### Note:\n- This isn't a fully featured string class.\n- It is a simple, bearable replacement to std::string that isn't heap abusive nor bloated (can actually be debugged by humans).\n- Local buffer size is currently limited to 1023 bytes (we allocate 10 bits to hold local buffer size).\n- In \"non-owned\" mode for literals/reference we don't do any tracking/counting of references.\n\nThe main idea is that you can provide an arbitrary sized local buffer if you expect string to fit most of the time, and then you avoid using costly heap.\n```cpp\n// No local buffer, always use heap, sizeof()==16\n    Str s1 = \"hey\"; // allocates\n    Str s2 = Str::ref(\"hey\"); // doesn't allocate\n// With a local buffer of 16 bytes, sizeof() == 16 + 16 bytes.\n    Str16 s = \"filename.h\"; // copy into local buffer\n    Str16 s = \"long_filename_not_very_long_but_longer_than_expected.h\";   // use heap\n// With a local buffer of 256 bytes, sizeof() == 16 + 256 bytes.\n    Str256 s = \"long_filename_not_very_long_but_longer_than_expected.h\";  // copy into local buffer\n// Common sizes are defined at the bottom of Str.h, you may define your own.\n```\n\n## Functions:\n```cpp\n    Str256 s;\n    s.set(\"hello sailor\");                   // set (copy)\n    s.setf(\"{}/{}.tmp\", folder, filename);   // set (w/format)\n    s.append(\"hello\");                       // append.\n    s.appendf(\"hello {}\", 42);               // append (w/format).\n    s.set_ref(\"Hey!\");                       // set (literal/reference, just copy pointer, no tracking)\n```\n\nConstructor helper for reference/literal:\n```cpp\n    Str ref = Str::ref(\"literal\");           // copy pointer, no allocation, no string copy\n    Str ref = Str::ref(GetDebugName());      // copy pointer. no tracking of anything whatsoever, know what you are doing!\n```\n\nAll StrN types derives from Str and instance hold the local buffer capacity. So you can pass e.g. Str256* to a function taking base type Str* and it will be functional:\n```cpp\n    void MyFunc(Str* s) { *s = \"Hello\"; }    // will use local buffer if available in Str instance\n```\n\n## Testing the code:\n    g++ -std=c++20 -g test.cpp -o test -lfmt\n    valgrind ./test","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloud11665%2Fstr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloud11665%2Fstr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloud11665%2Fstr/lists"}