Boost logo

Boost :

From: Vinnie Falco (vinnie.falco_at_[hidden])
Date: 2020-01-21 03:43:49


Is there any interest in a URL library for Boost? This is something
that has been requested for a while now, and I've finally gotten
around to it.

Key features:

* Construct a read-only url::view from a string_view
* Construct a modifiable url::value from a string_view
  - Mutate the parts (e.g. set_scheme)

  - Set encoded or decoded strings:
    url::value u;
    u.set_username("Fr ed");
    u.set_encoded_password("pass%20word");

  - Retrieve encoded or decoded strings:
    u.username(); // returns decoded std::string
    u.encoded_password(); // returns encoded string_view

For servers, execution paths are provided to avoid all dynamic
allocation. For example to retrieve the decoded username:
    url::static_pool<4000> sp;
    std::cout << u.username( sp.allocator() );

The std::basic_string returned by username() uses the specified
allocator. A server can handle URLs without allocating any memory.

There's some punycode conversion routines but I haven't figured out if
they should be part of the library, or how they would manifest as APIs
(for international domain names).

You can perform calculations with URLs using an Allocator (default to
std::allocator<char>), or you can use a container with "static
storage" (e.g. fixed_string):

    url::static_value<4000> u; // 4000 char capacity

The library is here:

<https://github.com/vinniefalco/url>

This is still a work in progress, and I'm open to feedback that might
help me make better remaining design choices.

Thanks


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk