URI stands for Uniform Resource Identifier and it is a string of characters used to identify a name or resource on the Internet. CPP URI is a library for parsing and constructing URIs in C++.
Example 1: Parsing a URI
#include #include
int main() { uri::uri url("https://example.com/path/to/resource/?id=1234#fragment");
In this example, we are parsing a URI using the cpp URI library and printing its components such as scheme, host, path, query and fragment.
Example 2: Constructing a URI
#include #include
int main() { uri::uri url; url.scheme("https"); url.host("example.com"); url.path("/path/to/resource/"); url.query("id=1234"); url.fragment("fragment");
std::cout << url.string() << std::endl;
return 0; }
In this example, we are constructing a URI using the cpp URI library and printing its string representation. We are setting the scheme, host, path, query and fragment components for the URI.
The cpp URI library is also known as Boost URI and it is a part of the Boost C++ Libraries.
C++ (Cpp) uri - 6 examples found. These are the top rated real world C++ (Cpp) examples of uri extracted from open source projects. You can rate examples to help us improve the quality of examples.