Placing byte buffer into string

18 views
Skip to first unread message

SyRenity

unread,
Feb 14, 2010, 5:13:54 PM2/14/10
to Protocol Buffers
Hi.

I'm looking to switch my buffer implementation to stl string for
convenience.

What is the right way of inserting a whole byte buffer into the stl
string, and not only until the null-termination character?

Thanks.

SyRenity

unread,
Feb 14, 2010, 5:23:01 PM2/14/10
to Protocol Buffers
Actually, answering myself it seems to be as simple as:
sData.assign(buffer, size); //Where size is the full buffer size

Is this correct?

Evan Jones

unread,
Feb 14, 2010, 5:25:54 PM2/14/10
to SyRenity, Protocol Buffers

On Feb 14, 2010, at 17:23 , SyRenity wrote:
> Actually, answering myself it seems to be as simple as:
> sData.assign(buffer, size); //Where size is the full buffer size

Yes, that works. See the following for more help:

http://www.sgi.com/tech/stl/basic_string.html

Evan

--
Evan Jones
http://evanjones.ca/

SyRenity

unread,
Feb 14, 2010, 5:34:15 PM2/14/10
to Protocol Buffers
Thanks.
Reply all
Reply to author
Forward
0 new messages