Boost logo

Boost :

Subject: [boost] Formal Review Request: Boost.String.Convert
From: Vladimir.Batov_at_[hidden]
Date: 2009-02-15 22:22:16


Well, the fishing trip did not work out. :-\ Therefore, I would like to
request a formal review for the Boost.String.Convert functionality. I've
uploaded the file called boost-string-convert.zip to the Vault
(http://www.boostpro.com/vault/index.php). It has the conversion-related
header, the test/usage executable and the documentation (MS Word, HTML).
Compiled on Linux and Visual Studio 2008. At the bottom is the
"motivation" introductory section from the docs. There is very little of
actually code, so you might just read it rather that suffering through my
document mumble.

Currently-known issues.

1) The attention was given to the behavior (to provide simple/advanced
conversion-failure check, throw/no-throw behavior, locale, formatting) and
not to the efficiency. I am sure people will come up with ways to run this
damn thing much faster. I am very much looking forward to your
contributions as I do not really feel I am any good at it.

2) I've implemented the recently suggested boost::stirng::convert()
interface but that might need some additional work to handle corner cases
correctly. I promise to look into it in due course.

I would like to thank everyone participated in the lexica_cast and
boost::string::convert-related discussions and expressing their views and
opinions and coming up with suggestions. All of them were heard,
considered and much and truly appreciated. I apologize if in the end it
does not look out as you might like to see it. I swear, your contributions
were not in vain.

Thanks,
Vladimir.

Motivation
I had a need for a convenient and uniform facility to convert values to
and from a literal textual form. Such a need is common when converting
between internal (to a program) data types and their external
representations. Typical applications would be reading of configuration
files, packing and unpacking internal data to and from, say, XML, etc.
The boost::lexical_cast looked very promising and was the preferred
solution compared to others (such as C functions, std::stringstream, etc.,
see the lexical_cast documentation for more discussion about
alternatives). Unfortunately, I needed functionality beyond what
lexical_cast was providing (configurable throw/no-throw behavior,
formatting support, locale support, etc.). After discussions on the Boost
developers list and with the lexical_cast author (Kevlin Henney) and the
maintainer (Alexander Nasonov) it was collectively decided that the
required functionality extensions were not compatible with the idea of
what lexical_cast embodied and a more dedicated family of conversion
functions with richer interfaces was needed. That decision resulted in the
development of the following header-only string-conversion library
described in this document:
boost::string::convert()
The interface is explicit about its purpose ? string-related --
string-to-type and type-to-string -- conversions. It builds on the
lexical_cast past experience, offers the already familiar conversion
functionality and more:
· throw and no-throw conversion-failure handling behavior;
· support for the default value to be returned when conversion
fails;
· formatting support based on the standard (or user-defined)
manipulators (like std::hex, std::scientific, etc.);
· locale support;
· support for various (boost::range-compliant) char and
wchar_t-based containers (std::string, std::wstring, char const*, wchar_t
const*, char array[], std::vector<char>, etc.);
· no DefaultConstructibility requirement for the Target type;
· room to grow.
 


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