What is the nearest equivalent in C++ to the Java ByteArrayOutputStream



 DEVELOP > c-Plus-Plus > What is the nearest equivalent in C++ to the Java ByteArrayOutputStream

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Angus"
Date: 03 Jan 2007 02:15:04 PM
Object: What is the nearest equivalent in C++ to the Java ByteArrayOutputStream
Hello
I need to port some Java code and am wondering if there is a close
equivalent to ByteArrayOutputStream.
I have been looking at the STL iostream library but not quite sure what is
best to use.
Any help would be much appreciated.
.

User: "Victor Bazarov"

Title: Re: What is the nearest equivalent in C++ to the Java ByteArrayOutputStream 03 Jan 2007 02:25:55 PM
Angus wrote:

I need to port some Java code and am wondering if there is a close
equivalent to ByteArrayOutputStream.

I have been looking at the STL iostream library but not quite sure
what is best to use.

Any help would be much appreciated.

Any standard stream has 'write' member that takes a pointer to char,
which is probably what you want... What problem are you solving?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
.
User: "Victor Bazarov"

Title: Re: What is the nearest equivalent in C++ to the Java ByteArrayOutputStream 03 Jan 2007 03:46:20 PM
Angus wrote:

"Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
news:enh3gj$65l$1@news.datemas.de...

Angus wrote:

I need to port some Java code and am wondering if there is a close
equivalent to ByteArrayOutputStream.

I have been looking at the STL iostream library but not quite sure
what is best to use.

Any help would be much appreciated.


Any standard stream has 'write' member that takes a pointer to char,
which is probably what you want... What problem are you solving?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask



I am working with binary data - so bytes of anything. I am looking at
stringstream but maybe it won't like embedded control characters etc.

Ah... No such thing as "embedded control characters" in C++, AFAIK.
'char' and 'unsigned char' are just integral types with value ranges.

Do you know if that is the case? If not what to use?

No, it's not the case. It seems you just need 'basic_stringstream' with
'unsigned char' as its first argument:
std::basic_stringstream<unsigned char> mystream;
(if unsigned char [0..255] is the requirement, Java's 'byte' is actually
unsigned) or use std::stringstream if 'char' is fine; you may need to
cast to unsigned char later.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
.



  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER