
Security News
Knip Hits 500 Releases with v5.62.0, Improving TypeScript Config Detection and Plugin Integrations
Knip hits 500 releases with v5.62.0, refining TypeScript config detection and updating plugins as monthly npm downloads approach 12M.
SiddiqSoft.string2map
Advanced tools
Simple C++17 library to aid in the parsing of HTTP headers into a STL map-type container.
Convert the input string with the specified delimiters into a map of key-value pairs with the given input:
:
, :
, =
, =
)string
or wstring
.map
, multimap
, unordered_map
.namespace siddiqsoft::string2map
{
template <typename T, typename D = T, typename R = std::map<D, D>>
R parse(T& src, const T& keyDelimiter, const T& valueDelimiter, const T& terminalDelimiter= T{}) noexcept(false)
}
typename | Type | Comment |
---|---|---|
T | string or wstring | Type of the source string |
D | string or wstring | Type of the destination string (used in the container) |
R | map , unordered_map , multimap | Generally type is container<D,D> |
namespace siddiqsoft::string2vector
{
template <typename T>
std::vector<T> parse(const T& src, const T& keyDelimiter)
}
typename | Type | Comment |
---|---|---|
T | string or wstring | Type of the source string |
Get it from nuget or you can submodule it.
#include <string>
#include <map>
#include "siddiqsoft/string2map.hpp"
TEST(parse, Test_string2map)
{
std::string sampleStr{ "Host: duplicate\r\n"
"Host: hostname.com\r\n"
"Content-Type: text\r\n"
"Content-Length: 99\r\n\r\n" };
auto kvmap= siddiqsoft::string2map::parse<string, // input string
wstring, // transform to wstring
map<wstring,wstring> // destination container
>(sampleStr);
// We expect only 3 items even though there is a duplicate key in the source string.
// The std::map container ensures unique keys.
EXPECT_EQ(3, kvmap.size());
}
TEST(parse, Test_string2vector)
{
std::string sampleStr{ "/a/b/c/d" };
auto kv= siddiqsoft::string2vector::parse<string>(sampleStr);
EXPECT_EQ(4, kv.size());
}
© 2020 Siddiq Software LLC. All rights reserved. Refer to LICENSE.
FAQs
Parse of key-value pair from string
We found that siddiqsoft.string2map demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Knip hits 500 releases with v5.62.0, refining TypeScript config detection and updating plugins as monthly npm downloads approach 12M.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.