Re: Converting C++ ostringStream (ostream) to ObjC's NSData
Re: Converting C++ ostringStream (ostream) to ObjC's NSData
- Subject: Re: Converting C++ ostringStream (ostream) to ObjC's NSData
- From: Gen Kiyooka <email@hidden>
- Date: Sat, 2 Jul 2005 22:37:36 -0700
On Jul 2, 2005, at 9:48 PM, Frederick C. Lee wrote:
Greetings:
How can I convert a C++ data stream (ostringstream or
stringstream) to ObjC's NSData?
I'm attempting to call a C++ routine from an ObjC routine:
---------------------------------------------
Inside ObjC calling routine:
Foo *myCPlusPlusObj;
myCPlusPlusObj=new Foo();
...
NSData *vecData = [NSData dataWithData:myCPlusPlusObj->getVec()];
...
---------------------------------------------
The called C++ routine is:
void *Foo::getVec(void) {
ostringstream dataStream;
....
return datastream;
}
Since dataStream is an auto variable on the stack, you cannot really
return a void pointer
to its data, because it will no longer exist when the caller gets
control.
The return value is a void * pointer. The conversion doesn't
work. The compiler can't convert a void * ptr to NSData.
Or, returning a iostream *, I get a runtime Signal 11 error: "
Obj_C++ has exited due to signal 11 (SIGSEGV)."
Any ideas?
Regards,
Ric.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden