|
Prev: C++ language: Cloneable classes
Next: How to convert a pointer to member function type to a const member one
From: Christopher on 5 May 2008 03:35 On Apr 26, 9:43 am, "Angus" <nos...(a)gmail.com> wrote: > Hello > > I want to create streams of data that will include fundamental data types > but not classes or pointers. Eg I might want create a stream with a > header(2 bytes), a length of message (2 bytes), and then use the basic > structure size,data where size is the number of bytes and data is the binary > data. You are contradicting yourself. You want a stream that doesn't send classes, but then describe a data structure you want to stream. The fact that you want a header implies you want to send a message, not a stream. You do not stream messages. You send messages _or_ you stream data. > An example piece of data could be a timestamp which is a double value. So > size would be sizeof(double) followed by the data which would be the double > value. Sounds like a message to me. Unless you have a continuous stream of timestamps, in which case you stream doubles. But what would be the point of streaming timestamps? > I can do all this at a low level but was wondering if I should really be > using the stream classes to do this? If so can anyone give me any pointers > as to how to get started. I don't think you should. It sounds like you are wanting to send messages. > As I have binary data is stringstream inappropriate? If so which stream > class to use? A stringstream is an iostream designed for text. It is probably inappropriate for use. You can always derive your own custom stream from one of the iostream classes, but again, I don't think you are looking for streams here. It sounds like you want to send messages, ... I assume messages of the network variety, probably UDP. -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |