Boost.URL is a portable C++ library which provides containers and algorithms which model a "URL," more formally described using the Uniform Resource Identifier (URI) specification (henceforth referred to as rfc3986). A URL is a compact sequence of characters that identifies an abstract or physical resource. For example, this is a valid URL:
https://www.example.com/path/to/file.txt?userid=1001&pages=3&results=full#page1This library understands the grammars related to URLs and provides functionality to validate, parse, examine, and modify urls, and apply normalization or resolution algorithms
While the library is general purpose, special care has been taken to ensure that the implementation and data representation are friendly to network programs which need to handle URLs efficiently and securely, including the case where the inputs come from untrusted sources. Interfaces are provided for using error codes instead of exceptions as needed, and most algorithms have the means to opt-out of dynamic memory allocation. Another feature of the library is that all modifications leave the URL in a valid state. Code which uses this library is easy to read, flexible, and performant.
Boost.URL offers these features:
The library requires a compiler supporting at least C++11.
Aliases for standard types, such as
error_code or
string_view,
use their Boost equivalents.
A serializer for JSON.
Defined in header <boost/json/serializer.hpp>
class serializer
| Name | Description |
|---|---|
done
|
Returns true if the serialization is complete. |
read
|
Read the next buffer of serialized JSON. |
reset
|
Reset the serializer for a new string. |
This class traverses an instance of a library type and emits serialized
JSON text by filling in one or more caller-provided buffers. To use, declare
a variable and call
reset with a pointer to the variable you want
to serialize. Then call
read over and over until
done returns true.
This demonstrates how the serializer may be used to print a JSON value to an output stream.
void print( std::ostream& os, value const & jv)
{
serializer sr;
sr.reset( &jv );
while ( ! sr.done() )
{
char buf[ 4000 ];
os << sr.read( buf );
}
}
| Name | Description |
|---|---|
| alnum_chars | Contains the uppercase and lowercase letters, and digits. |
| alpha_chars | Contains the uppercase and lowercase letters. |
| digit_chars | Contains the decimal digit characters. |
The same instance may not be accessed concurrently.
Convenience header <boost/json.hpp>