|
Boost : |
From: John Nagle (nagle_at_[hidden])
Date: 2004-05-23 13:52:47
I've done a major rewrite on this. See
boost_fixed_string.hpp - fixed strings
boost_fixed_string_cstring.hpp - sprintf, etc.
boost_fixed_string_test.cpp - a test program
This does much the same thing as Dunn's fixed_string, but
with a somewhat simpler structure.
The main template class is "fixed_string<TYPE,LEN>", which
is generic and does all the work.
This is derived from the abstract class "fixed_string_base<TYPE>",
which is used when you need a reference or pointer to a fixed
string of unknown length. It doesn't do anything but redirect
virtual functions.
Then we define, very simply,
"char_string<LEN>" "char_string_base"
"wchar_string<LEN>" "wchar_string_base"
These are just instantiations of fixed_string, but they also
define functions that need type-based handling. So far, this
is only "vsnprintf".
There are no conditionals, other than the usual workaround for an
MSVC problem.
fixed_string has a length. Length is lazy-evaluated; some
operations make the length -1, which forces a recount of the
string when next the length is needed.
The C-type operations and subscripting are all checked for
length. Iterators are supported, but, consistent with std::string
semantics, they are unsafe.
Comments?
John Nagle
Animats
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk