Re: Need Container for Large Binary String
From: Ivan Vecerina (INVALID_use_webform_instead_at_vecerina.com)
Date: 11/14/04
- Previous message: Carl Barron: "Re: Need Container for Large Binary String"
- In reply to: floobles: "Need Container for Large Binary String"
- Next in thread: Maxim Yegorushkin: "Re: Need Container for Large Binary String"
- Messages sorted by: [ date ] [ thread ]
Date: 13 Nov 2004 23:32:27 -0500
"floobles" <floobles@gmail.com> wrote in message
news:d9632d0f.0411120912.7c9cdd5a@posting.google.com...
> I need to manipulate large binary strings. I would like to use some
> typical array functions (such as find first occurrence,
> insert/replace, etc.)
>
> I would *like* to use either one of the MFC containers (CArray &
> family) or STL (vector or STL strings).
>
> The STL string class would be ideal, except that all its functions
> expect a '\0' as the end of the string, but my binary string will have
> lots of '/0'...
Some functions use null-terminated C strings, but all have an equivalent
that allows you to embedd '\0'. I would suggest that you take a look
through this ongoing thread in this NG:
how to construct a string with embedded NULLs
> Next ideal would be the STL vector, but it doesn't seem like there is
> an efficient way in initializing the vector with my binary data (i.e.
> the constructors don't take a char* and length as parameters .\_/. )
> Is it possible to do a memcpy-type initialization? But this would
> rely on the implementation (and not the interface) of the vector...
A vector can be initialized using a memory range:
std::vector v( myString, myString + myStringLength );
hth,
Ivan
-- http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
- Previous message: Carl Barron: "Re: Need Container for Large Binary String"
- In reply to: floobles: "Need Container for Large Binary String"
- Next in thread: Maxim Yegorushkin: "Re: Need Container for Large Binary String"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|