Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2004-05-20 18:39:41


John Nagle wrote:
> This looks rather complex for what it does.
>
> It might be helpful to define the user-visible
>API first. Then worry about the implementation.

The user-visible API that I am using is the basic_string API (C++98 21.3)
along with operator const CharT *() and format( const CharT *, va_args ) to
allow C-style string interoperability. There are also implementations of the
C string API (string.h) to allow fixed_string to interface with C code.

The requirements for fixed_string are:
[1] prevent buffer overflow on a fixed capacity string (CharT[ n ]);
[2] provide a basic_string interface -- this is where part of the complexity
comes in
[3] provide C-string functions (strcpy, strlen, etc.)
[4] allow functions to operate on variable-capacity strings without
resorting to template code -- this is where the rest of the complexity comes
in

My implementation meets the above requirements, although requirement [3]
could be more fully implemented (I'm working on this). Requirements 2 and 3
are interface (API) requirements, defined in the C++98 and C90 standards,
while 1 and 4 are interface requirements.

Despite the basic_string interface being complex, I do not want to drop it
(even if that would simplify the class considerably!)

However, if there is a simpler way to meet these requirements then I'd be
happy to see what it is.

Regards,
Reece

_________________________________________________________________
Use MSN Messenger to send music and pics to your friends
http://www.msn.co.uk/messenger


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