James Newtons Massmind wrote: >The programmer I hired to help with this is sick and make take some time to >reply so I'll write the list with this question in hopes of finding an >answer faster. > >I'm writing Win32 code in C/C++ (MS Visual C++ 2005 Express Edition) and >part of this code manipulates data that is handed to it in a memory buffer. >I may have to insert things and thereby increase the size of the data beyond >the size of the source buffer. So I need to allocate a buffer of my own, >copy from the source and insert my bits, the return the result in place of >the source. No problems so far. > >The issue is what class to use for my buffer. Here are the requirements: >1. It should be as efficient and fast as possible. E.g. I don't need file IO >so there is no reason to use a iostream class. > >2. The data is binary. By that I mean the byte values will range from 0 to >255. Some of the data I will put into the buffer is binary, but other data >will be text and some data will be binary values (int, short, etc...) that I >will need to convert to decimal characters and append. E.g. if it was an >std::basic_stringstream I would use: > > std::basic_stringstream buffer; > int I = 123; > buffer << "I is:" << I; > >So the issue is this combination of needs: copying in parts of a binary char >array, text, or decimal values of variables. > >What class does all that? And more importantly, where is there any >documentation that would help a poor newbie like me figure out what they do >and don't? > >I've been advised to use vector but that doesn't support the << and the copy >as far as I can see. > >I've also been advised not to use streams as they don't play well with >binary? > >Any advice appreciated. > >--- >James Newton: PICList webmaster/Admin >mailto:jamesnewton@piclist.com 1-619-652-0593 phone >http://www.piclist.com/member/JMN-EFP-786 >PIC/PICList FAQ: http://www.piclist.com > > > > Take a look at the ArrayList class. It can do the things you need. It can grow dynamcially, it takes any object types and it can be efficient in speed and memory. Check out the documentation to see how it's used and see some samples. That will let you know for sure if it meets your needs. -Chris -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist