{"id":21327868,"url":"https://github.com/siddiqsoft/string2map","last_synced_at":"2026-02-14T04:03:27.185Z","repository":{"id":48828031,"uuid":"309965885","full_name":"SiddiqSoft/string2map","owner":"SiddiqSoft","description":"Header only C++17 library to parse a string containing delimited key-value pairs into a map container including the feature to convert from std::string to std::wstring and vice-versa.","archived":false,"fork":false,"pushed_at":"2025-01-16T02:52:00.000Z","size":99,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-14T23:42:00.002Z","etag":null,"topics":["cpp","http-header-parser","key-value","map","parse","string","tokenize","winhttp"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SiddiqSoft.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":"2020-11-04T10:13:04.000Z","updated_at":"2025-01-16T02:49:01.000Z","dependencies_parsed_at":"2025-01-22T12:45:19.811Z","dependency_job_id":"c4244ac0-e944-40df-bdf2-6695a1036802","html_url":"https://github.com/SiddiqSoft/string2map","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiddiqSoft%2Fstring2map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiddiqSoft%2Fstring2map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiddiqSoft%2Fstring2map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiddiqSoft%2Fstring2map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SiddiqSoft","download_url":"https://codeload.github.com/SiddiqSoft/string2map/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248981258,"owners_count":21193143,"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","http-header-parser","key-value","map","parse","string","tokenize","winhttp"],"created_at":"2024-11-21T21:20:08.566Z","updated_at":"2026-02-14T04:03:27.115Z","avatar_url":"https://github.com/SiddiqSoft.png","language":"C++","readme":"# string2map and string2vector\n\n[![CodeQL](https://github.com/SiddiqSoft/string2map/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/SiddiqSoft/string2map/actions/workflows/codeql-analysis.yml)\n[![Build Status](https://dev.azure.com/siddiqsoft/siddiqsoft/_apis/build/status/SiddiqSoft.string2map?branchName=main)](https://dev.azure.com/siddiqsoft/siddiqsoft/_build/latest?definitionId=3\u0026branchName=main)\n![](https://img.shields.io/nuget/v/SiddiqSoft.string2map)\n![](https://img.shields.io/github/v/tag/SiddiqSoft/string2map)\n![](https://img.shields.io/azure-devops/tests/siddiqsoft/siddiqsoft/2)\n![](https://img.shields.io/azure-devops/coverage/siddiqsoft/siddiqsoft/2)\n\nSimple C++17 library to aid in the parsing of HTTP headers into a STL map-type container.\n\n\n## Objective\n\nConvert the input string with the specified delimiters into a map of key-value pairs with the given input:\n- std::[w]string\n- Key delimiter (example: `: `, `:`, `=`, `= `)\n- Value delimiter (end of the key-value pair element, example: CRLF)\n- Destination output type for key/value: `string` or `wstring`.\n- Destination container type: `map`, `multimap`, `unordered_map`.\n\n\n## API\n\n```cpp\nnamespace siddiqsoft::string2map\n{\n    template \u003ctypename T, typename D = T, typename R = std::map\u003cD, D\u003e\u003e\n    R parse(T\u0026 src, const T\u0026 keyDelimiter, const T\u0026 valueDelimiter, const T\u0026 terminalDelimiter= T{}) noexcept(false)\n}\n```\n\ntypename | Type      | Comment\n---------|-----------|--------------\n`T`      | `string` or `wstring`  | Type of the source string\n`D`      | `string` or `wstring`  | Type of the destination string (used in the container)\n`R`      | `map`, `unordered_map`, `multimap` | Generally type is container\u003cD,D\u003e\n\n\n```cpp\nnamespace siddiqsoft::string2vector\n{\n    template \u003ctypename T\u003e\n    std::vector\u003cT\u003e parse(const T\u0026 src, const T\u0026 keyDelimiter)\n}\n```\n\ntypename | Type      | Comment\n---------|-----------|--------------\n`T`      | `string` or `wstring`  | Type of the source string\n\n\n## Usage\n\nGet it from [nuget](https://www.nuget.org/packages/string2map/) or you can submodule it.\n\n```cpp\n#include \u003cstring\u003e\n#include \u003cmap\u003e\n\n#include \"siddiqsoft/string2map.hpp\"\n\nTEST(parse, Test_string2map)\n{\n    std::string sampleStr{ \"Host: duplicate\\r\\n\"\n                    \"Host: hostname.com\\r\\n\"\n                    \"Content-Type: text\\r\\n\"\n                    \"Content-Length: 99\\r\\n\\r\\n\" };\n\n    auto kvmap= siddiqsoft::string2map::parse\u003cstring,  // input string\n                                              wstring, // transform to wstring\n                                              map\u003cwstring,wstring\u003e // destination container\n                                             \u003e(sampleStr);\n\n    // We expect only 3 items even though there is a duplicate key in the source string.\n    // The std::map container ensures unique keys.\n    EXPECT_EQ(3, kvmap.size());\n}\n\n\nTEST(parse, Test_string2vector)\n{\n    std::string sampleStr{ \"/a/b/c/d\" };\n\n    auto kv= siddiqsoft::string2vector::parse\u003cstring\u003e(sampleStr);\n\n    EXPECT_EQ(4, kv.size());\n}\n\n```\n\n\u003csmall align=\"right\"\u003e\n\n\u0026copy; 2020 Siddiq Software LLC. All rights reserved. Refer to [LICENSE](LICENSE).\n\n\u003c/small\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiddiqsoft%2Fstring2map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiddiqsoft%2Fstring2map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiddiqsoft%2Fstring2map/lists"}