Skip to main content
GameDev.net gamedev.net
🔒 Locked

can basic_string hold binary data?

Started by gimp Jun 28, 2000 at 7:30 PM 0 replies 500+ views
Original Post
gimp
gimp
I normally use unsigned char to store my binary message before handing them over to sendto(). In switching to a more STL approach I''m trying to use a queue od strings to store my byte messages. Can I use a basic string to store my binary data and protect it''s integrity (I had a nasty experience with signed data ''corrupting'' my data a while back. This is the messaging subsystem of my networked game. Messages can be of any length, in the past I''ve just used a 4k unsigned char array, which is grossly inefficient. Will message.cstr() wreak anything? Thanks gimp
Chris Brodie
deadlinegrunt
deadlinegrunt
If you want unsigned char strings then use them.
        

typedef std::basic_string< unsigned char > ustring;

ustring whatever; // blah blah blah


//If you want a dynamic array of "your choice here" then

// try something like:


typedef std::vector< unsigned int > uint;
typedef std::vector< "your UDT here" > udtwhatever;

udtwhatever something; // blah blah blah



Etc, etc. But then again, maybe I didn't understand your question, in which case you can just ignore this post.




YAP YFIO,
deadlinegrunt

Edited by - deadlinegrunt on June 28, 2000 9:26:40 PM
~deadlinegrunt

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.