Boost logo

Boost :

Subject: Re: [boost] [ann] Urdl - a library for downloading web content
From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2009-06-17 18:54:29


Thorsten Ottosen wrote:
> May I suggest that you add a bunch of constants instead of
> using strings. You currently have
>
> // We're doing an HTTP POST ...
> is.set_option(urdl::http::request_method("POST"));
>
> // ... where the MIME type indicates plain text ...
> is.set_option(urdl::http::request_content_type("text/plain"));
>
> I don't like the hard-coding of "POST" and "text/plain". Also for
> type-safety reasons, strings are usually irritating. Maybe it would
> be possible to use enumeration values instead:
>
> // We're doing an HTTP POST ...
> is.set_option(urdl::http::request_method::post);
>
> // ... where the MIME type indicates plain text ...
> is.set_option(urdl::http::request_content_type::text_plain));

Good idea, however rather than an enum I think I will add some static
member functions for these "constants", as the set is unbounded and
users may still need to supply a custom string. E.g.:

   is.set_option(urdl::http::request_method::post());

> The Url class has operators like ==, != and <. May I suggets you hass
> hash_value( const url& ) too.

Will do.

> I'm not a fan of short names. Especially
>
> http::errc::errc_t
>
> would be clearer IMO as
>
> http::error_codes::error_code
>
> or something like that.

This is chosen for consistency with the c++0x standard library, which
has the error constants in std::errc::* (and obviously Boost.System uses
boost::system::errc). It seems reasonable to me to use "errc" as an
idiomatic name for scoping error constants in any library that uses
std::error_code and friends. What do you think?

Cheers,
Chris


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