take data out of a stream

  • Thread starter frank dot nielsen at rocketmail dot com
  • Start date
F

frank dot nielsen at rocketmail dot com

Hi there

I have a std:istrstream full of data and i want to take this data out to a void* . I have to send the data back through jni (java) so i can't use any streams to extract data...

Something like:

std::istrstream os;

.. stuff data is os...

void* dataptr = os.getptr(); ???? HOW TO DO ????
int datalen = is.pcount();

// send back thought jni....
byteArray outdata = env->NewByteArray( datalen );
env->SetByteArrayRegion( outdata, 0, datalen, (jbyte *)(char*)dataptr );


Thanks in advance
 
F

Frank Nielsen

frank said:
Hi there

I have a std:istrstream full of data and i want to take this data out to
a void* . I have to send the data back through jni (java) so i can't use
any streams to extract data...

Something like:

std::istrstream os;

.. stuff data is os...

void* dataptr = os.getptr(); ???? HOW TO DO ????
int datalen = is.pcount();

// send back thought jni....
byteArray outdata = env->NewByteArray( datalen );
env->SetByteArrayRegion( outdata, 0, datalen, (jbyte *)(char*)dataptr );

Thanks in advance
Found the answer myself, and ofcoz it was too obvious...

void* dataptr = os.str();


But a new problem is raised. The data cannot be contained in a string-stream since it contains '\0' character, actually it is utf8 strings. So is there any binary stream classes i can use instead of istrstream????
 
D

David Harmon

On Tue, 27 Apr 2004 22:32:49 +0200 in comp.lang.c++, "Frank Nielsen"
But a new problem is raised. The data cannot be contained in a string-stream since it contains '\0' character, actually it is utf8 strings. So is there any binary stream classes i can use instead of istrstream????

What is the problem with the '\0' and the stringstream?
 
J

John Harrison

But a new problem is raised. The data cannot be contained in a
string-stream since it contains '\0' character, actually it is utf8 strings.
So is there any binary stream classes i can use instead of istrstream????

Yes istringstream, which is based on a string not on a char*, and string can
contain '\0' chars.

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,167
Messages
2,570,910
Members
47,453
Latest member
MadelinePh

Latest Threads

Top