Boost logo

Boost :

From: Alberto Ganesh Barbati (AlbertoBarbati_at_[hidden])
Date: 2008-02-02 06:15:23


Marshall Clow ha scritto:
> I am in need of a library to parse/encode/decode URLs.
> A quick look through the boost tree doesn't yield any obvious candidates.

That would be a most welcome addition. It doesn't have to be anything as
complex as Boost.Filesystem. Something like Python urlparse might be
enough for most use cases.

> Before I dive into writing my own, does anyone have any
> pointers/recommendations?
>

In the meantime, you can use Boost.Regex or Boost.Xpressive. According
to http://www.faqs.org/rfcs/rfc2396.html a suitable regex is the following:

   ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?

if $n are the groups produced by the regex, the parts of the url are as
follows:

       scheme = $2
       authority = $4
       path = $5
       query = $7
       fragment = $9

There is also an example in Boost.regex using token iterators, see
http://boost.org/libs/regex/doc/examples.html (search for "url").

HTH,

Ganesh


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