{"id":15047620,"url":"https://github.com/at-sso/stringtools","last_synced_at":"2026-02-11T03:30:54.847Z","repository":{"id":244732062,"uuid":"811742338","full_name":"at-sso/StringTools","owner":"at-sso","description":"String manipulation tools for C++ 17.","archived":false,"fork":false,"pushed_at":"2024-08-02T09:00:01.000Z","size":651,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-09T18:03:31.237Z","etag":null,"topics":["cpp","cpp17","namespace","string-formatter","string-manipulation","visual-studio"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/at-sso.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":"2024-06-07T07:58:00.000Z","updated_at":"2024-10-29T10:00:04.000Z","dependencies_parsed_at":"2024-06-17T04:26:00.243Z","dependency_job_id":"34c7163f-d681-4b29-b000-efaaa602c5f4","html_url":"https://github.com/at-sso/StringTools","commit_stats":null,"previous_names":["at-sso/stringtools"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/at-sso/StringTools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/at-sso%2FStringTools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/at-sso%2FStringTools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/at-sso%2FStringTools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/at-sso%2FStringTools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/at-sso","download_url":"https://codeload.github.com/at-sso/StringTools/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/at-sso%2FStringTools/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272340950,"owners_count":24917464,"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-08-27T02:00:09.397Z","response_time":76,"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","cpp17","namespace","string-formatter","string-manipulation","visual-studio"],"created_at":"2024-09-24T21:01:30.368Z","updated_at":"2026-02-11T03:30:54.819Z","avatar_url":"https://github.com/at-sso.png","language":"C++","readme":"# StringTools\n\nThe `strTools` namespace provides a set of tools for manipulating C-style strings. These functions are designed to simplify common string operations, such as concatenation, substring extraction, insertion, deletion, searching, and replacement. The library ensures proper memory management using `unique_ptr\u003cchar[]\u003e`.\n\n## Index\n\n- [StringTools](#stringtools)\n  - [Index](#index)\n  - [Overview](#overview)\n  - [Namespace features](#namespace-features)\n  - [Main function features](#main-function-features)\n  - [Installation](#installation)\n  - [Namespace Usage](#namespace-usage)\n    - [Length Calculation](#length-calculation)\n    - [Concatenation](#concatenation)\n    - [Substring Extraction](#substring-extraction)\n    - [Insertion](#insertion)\n    - [Deletion](#deletion)\n    - [Searching](#searching)\n    - [Replacement](#replacement)\n  - [Main function Usage](#main-function-usage)\n    - [Menu Options](#menu-options)\n    - [Example Usage](#example-usage)\n    - [Input Handling](#input-handling)\n    - [String Operations](#string-operations)\n  - [Full Documentation](#full-documentation)\n  - [License](#license)\n\n## Overview\n\nThis project provides a string manipulation library to easily handle strings. It includes functions for calculating the length of a string, concatenating strings, searching for a substring, and generating substrings. The `main.cpp` file demonstrates examples of how to use this library through a simple console menu.\n\n## Namespace features\n\n- **Length Calculation:** Calculate the length of a C-string.\n- **Concatenation:** Concatenate two C-strings into a new dynamically allocated string.\n- **Substring Extraction:** Extract a substring from a C-string.\n- **Insertion:** Insert one C-string into another at a specified position.\n- **Deletion:** Remove a substring from a C-string.\n- **Searching:** Find the first occurrence of a substring within a C-string.\n- **Replacement:** Replace the first occurrence of a substring with another substring.\n\n## Main function features\n\n- **Calculate the Length of a String:** Enter a string and get its length.\n- **Concatenate Strings:** Enter three strings and concatenate them.\n- **Search for a Substring:** Enter a string and a substring to find its position within the string.\n- **Generate a Substring:** Enter a string and generate a random substring from it.\n- **Exit:** Exit the program.\n\n## Installation\n\nTo use the `strTools` \u0026 `strUtil` library, include the `strtools.hh` header in your C++ project:\n\n```cpp\n#include \"src/.hxx\"\n```\n\nor:\n\n```cpp\n#include \"src/strlogger.hh\"\n#include \"src/strtools.hh\"\n#include \"src/strutil.hh\"\n#include \"src/strutilhelper.hh\"\n```\n\nEnsure that your project is set up to find the header file in its include path.\n\nYou can also try running the test program using:\n\n```bash\ng++ -std=c++17 -I src main.cpp -o main.exe \u0026\u0026 ./main.exe\n```\n\n## Namespace Usage\n\n### Length Calculation\n\nCalculate the length of a C-string.\n\n```cpp\nconst char* myString = \"Hello, World!\";\nuint64_t length = strTools::len(myString);  // length will be 13\n```\n\n### Concatenation\n\nConcatenate two C-strings into a new unique_ptr\u003cchar[]\u003e.\n\n```cpp\nconst char* str1 = \"Hello, \";\nconst char* str2 = \"World!\";\nauto result = strTools::concatStr(str1, str2);\n// result will contain \"Hello, World!\"\n```\n\n### Substring Extraction\n\nExtract a substring from a C-string.\n\n```cpp\nconst char* myString = \"Hello, World!\";\nauto sub = strTools::subStr(myString, 7, 5);\n// sub will contain \"World\"\n```\n\n### Insertion\n\nInsert one C-string into another at a specified position.\n\n```cpp\nconst char* str1 = \"Hello, World!\";\nconst char* str2 = \"Beautiful \";\nauto result = strTools::insertStr(str1, str2, 8);\n// result will contain \"Hello, Beautiful World!\"\n```\n\n### Deletion\n\nRemove a substring from a C-string.\n\n```cpp\nconst char* myString = \"Hello, World!\";\nauto result = strTools::delSubStr(myString, 7, 6);\n// result will contain \"Hello, !\"\n```\n\n### Searching\n\nFind the first occurrence of a substring within a C-string.\n\n```cpp\nconst char* myString = \"Hello, World!\";\nint64_t index = strTools::findSubStr(myString, \"World\");\n// index will be 7\n```\n\n### Replacement\n\nReplace the first occurrence of a substring with another substring.\n\n```cpp\nconst char* myString = \"Hello, World!\";\nconst char* sub1 = \"World\";\nconst char* sub2 = \"Universe\";\nauto result = strTools::replaceStr(myString, sub1, sub2);\n// result will contain \"Hello, Universe!\"\n```\n\n## Main function Usage\n\nNOTE: The `main` function requires C++20. If you are using C++17, this section will not compile.\n\n### Menu Options\n\n1. **Calculate the Length of a String:**\n\n   - Prompts the user to enter a string.\n   - Calculates the length using `strTools::len`.\n\n2. **Concatenate Three Strings:**\n\n   - Prompts the user to enter three strings.\n   - Concatenates them using `strTools::concatStr`.\n   - Displays the concatenated result.\n\n3. **Search for a Substring:**\n\n   - Prompts the user to enter a string and a substring.\n   - Searches for the substring using `strTools::findSubStr`.\n   - Extracts the substring using `strTools::subStr`.\n   - Displays the result or an error message if the substring is not found.\n\n4. **Generate a Substring from a String:**\n\n   - Prompts the user to enter a string.\n   - Generates random start and end indices.\n   - Extracts a substring using `strTools::subStr`.\n   - Displays the extracted substring.\n\n5. **Exit:**\n   - Exits the program.\n\n### Example Usage\n\n1. Run the program.\n2. Select an option by entering a number (0-4).\n3. Follow the prompts to perform the desired operation.\n4. View the result or error message.\n5. Repeat until you choose to exit (option 0).\n\n### Input Handling\n\nThe program uses the `helpers` namespace to manage invalid inputs, out-of-bounds values, and user input for different operations:\n\n- **Invalid Input:** If the input is invalid (non-numeric), an error message is shown.\n- **Out-of-Bounds Input:** If the input is not within the range [0, 4], an error message is shown.\n- **User Input Handling:** Manages input from the user, including handling exit commands and input overflow.\n\n### String Operations\n\nThe `strtools` namespace provides the following functions for string manipulation:\n\n- **Length Calculation (`strTools::len`):** Calculates the length of a string.\n- **Concatenation (`strTools::concatStr`):** Concatenates multiple strings.\n- **Substring Search (`strTools::findSubStr`):** Finds the position of a substring within a string.\n- **Substring Extraction (`strTools::subStr`):** Extracts a substring from a string based on start and end indices.\n\n## Full Documentation\n\nFor more detailed documentation on the code, including function descriptions and usage, refer to the Doxygen documentation available [here](https://github.com/at-sso/StringTools/blob/master/docs/StringTools.pdf).\n\n## License\n\nThe `strTools` library is licensed under the GNU General Public License v3.0. For more details, see [license](./license).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fat-sso%2Fstringtools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fat-sso%2Fstringtools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fat-sso%2Fstringtools/lists"}