SiddiqSoft.string2map 1.2.1-main0001

This is a prerelease version of SiddiqSoft.string2map.
There is a newer version of this package available.
See the version list below for details.
dotnet add package SiddiqSoft.string2map --version 1.2.1-main0001                
NuGet\Install-Package SiddiqSoft.string2map -Version 1.2.1-main0001                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SiddiqSoft.string2map" Version="1.2.1-main0001" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SiddiqSoft.string2map --version 1.2.1-main0001                
#r "nuget: SiddiqSoft.string2map, 1.2.1-main0001"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SiddiqSoft.string2map as a Cake Addin
#addin nuget:?package=SiddiqSoft.string2map&version=1.2.1-main0001&prerelease

// Install SiddiqSoft.string2map as a Cake Tool
#tool nuget:?package=SiddiqSoft.string2map&version=1.2.1-main0001&prerelease                

string2map

CodeQL

Simple C++17 library to aid in the parsing of HTTP headers into a STL map-type container.

Objective

Convert the input string with the specified delimiters into a map of key-value pairs with the given input:

  • std::[w]string
  • Key delimiter (example: : , :, =, = )
  • Value delimiter (end of the key-value pair element, example: CRLF)
  • Destination output type for key/value: string or wstring.
  • Destination container type: map, multimap, unordered_map.

API

namespace string2map
{
	template <typename T, typename D = T, typename R = std::map<D, D>>
	R parse(T& src, const T& keyDelimiter, const T& valueDelimiter) 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>

Usage

Get it from nuget

#include <string>
#include <map>

#include "siddiqsoft/string2map.hpp"

void Test()
{
    auto sampleStr{ "Host: duplicate\r\n"
                    "Host: hostname.com\r\n"
                    "Content-Type: text\r\n"
                    "Content-Length: 99\r\n\r\n"s };

    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());
}

<small align="right">

© 2020 Siddiq Software LLC. All rights reserved. Refer to LICENSE.

</small>

Product Compatible and additional computed target framework versions.
native native is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on SiddiqSoft.string2map:

Package Downloads
SiddiqSoft.restcl

Focussed REST Client for modern C++

SiddiqSoft.CosmosClient

Azure Cosmos REST-API Client for Modern C++

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.4.2 147 12/8/2024
2.4.1 77 12/8/2024
2.4.0 160 12/7/2024
2.3.1 2,061 11/20/2021
2.3.0 22,374 9/9/2021
2.2.2 1,697 8/7/2021
2.2.1 1,717 8/3/2021
2.2.0 3,255 8/3/2021
2.1.1 3,683 8/2/2021
1.4.1 1,430 7/22/2021
1.4.0-main0001 1,448 7/22/2021
1.3.0 1,788 7/10/2021
1.2.2 1,621 7/9/2021
1.2.1-main0001 1,548 7/9/2021