SiddiqSoft.SplitUri
1.6.4
See the version list below for details.
dotnet add package SiddiqSoft.SplitUri --version 1.6.4
NuGet\Install-Package SiddiqSoft.SplitUri -Version 1.6.4
<PackageReference Include="SiddiqSoft.SplitUri" Version="1.6.4" />
paket add SiddiqSoft.SplitUri --version 1.6.4
#r "nuget: SiddiqSoft.SplitUri, 1.6.4"
// Install SiddiqSoft.SplitUri as a Cake Addin #addin nuget:?package=SiddiqSoft.SplitUri&version=1.6.4 // Install SiddiqSoft.SplitUri as a Cake Tool #tool nuget:?package=SiddiqSoft.SplitUri&version=1.6.4
SplitUri : Parse Uri Utility
Objective
Parse the Uri for HTTP resources with support for format
and nlohmann.json
.
While there are many, many libraries available, the goal of this implementation is to make usage easy along with a modern design.
Features
- Literals support so you can use
auto u= "https://www.siddiqsoft.com/"_Uri;
- Formatters for
std::format
as well as serializers fornlohmann.json
library. - Support for
std::string
andstd::wstring
- The build and tests are for Visual Studio 2019 under x64.
Usage
- Use the nuget SiddiqSoft.SplitUri
- Copy paste..whatever works.
Examples
#include "siddiqsoft/SplitUri.hpp"
..
..
using namespace siddiqsoft::literals;
// Use the literal operator helper.
auto uri= "https://www.google.com/search?q=siddiqsoft"_Uri;
// Outputs https://www.google.com/search?q=siddiqsoft
std::cout << std::format("{}", uri) << std::endl;
A more through example
using namespace siddiqsoft::literals;
auto u = "https://www.google.com/search?flag&q=siddiqsoft#v1"_Uri;
std::cerr << u.authority.host << std::endl;
std::cerr << u.authority.port << std::endl;
std::cerr << u.urlPart << std::endl;
std::cerr << u.queryPart << std::endl;
std::cerr << u.fragment << std::endl;
std::cerr << nlohmann::json(u.path).dump() << std::endl;
std::cerr << nlohmann::json(u.query).dump() << std::endl;
std::cerr << std::format("{}", u.scheme) << "...." << nlohmann::json(u.scheme).dump() << std::endl;
std::cerr << std::format("{}", u.authority) << std::endl;
std::cerr << std::format("{}", u) << std::endl;
And the corresponding output
www.google.com
443
/search?flag&q=siddiqsoft#v1
flag&q=siddiqsoft
v1
["search"]
{"flag":"", "q":"siddiqsoft"}
https...."https"
www.google.com:443
https://www.google.com/search?flag&q=siddiqsoft#v1
<hr/>
From Wikipedia we have the following structure of Uri.
userinfo host port
┌──┴───┐ ┌──────┴──────┐ ┌┴┐
https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top
└─┬─┘ └───────────┬──────────────┘└───────┬───────┘ └───────────┬─────────────┘ └┬┘
scheme authority path query fragment
API
Current implementation only supports the
http
andhttps
scheme.
Uri | ||
---|---|---|
scheme |
UriScheme | Enumeration of the Uri schemes. We currently only support http scheme. |
authority |
Auth | template argument defaulting to AuthorityHttp |
path |
vector<> | Array of strings each containing the path element |
query |
map<> | Map of query elements |
queryPart |
string | Section of the uri past the ? and upto the fragment delimiter |
url |
string | Short-cut of the path, query and fragment section |
urlPart |
string | Section of the uri past the host until end of string |
fragment |
string | Section of the uri containing the fragment |
SplitUri()
template <class CharT = char, class Auth = AuthorityHttp<CharT>>
requires std::same_as<char, CharT> || std::same_as<wchar_t, CharT>
Uri<CharT, Auth> static SplitUri(const std::basic_string<CharT>& aEndpoint);
<hr/>
Roadmap
- Support the other URI schemes.
<p align="right"> © 2021 Siddiq Software LLC. All rights reserved. </p>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
native | native is compatible. |
-
- nlohmann.json (>= 3.9.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on SiddiqSoft.SplitUri:
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.0.0 | 146 | 10/26/2024 |
1.9.0-rc0002 | 69 | 10/26/2024 |
1.8.5 | 78 | 10/26/2024 |
1.8.4 | 534 | 6/1/2022 |
1.8.3 | 633 | 11/20/2021 |
1.8.2 | 420 | 9/8/2021 |
1.8.1 | 321 | 9/8/2021 |
1.8.0 | 20,986 | 9/8/2021 |
1.7.0 | 9,007 | 8/29/2021 |
1.6.5 | 301 | 8/28/2021 |
1.6.4 | 494 | 8/18/2021 |
1.6.3 | 339 | 8/18/2021 |
1.6.2 | 359 | 8/16/2021 |
1.6.1 | 506 | 8/16/2021 |
1.5.1 | 322 | 8/13/2021 |
1.5.0 | 1,086 | 8/13/2021 |
1.4.1 | 322 | 8/9/2021 |
1.4.0 | 757 | 8/9/2021 |
1.3.0 | 310 | 8/6/2021 |
1.2.0 | 367 | 8/5/2021 |
1.1.0 | 372 | 8/5/2021 |
1.0.1 | 2,000 | 8/3/2021 |