RWriteStream << TPtrC

Login to reply to this topic.
Wed, 2006-01-04 03:51
Joined: 2004-09-06
Forum posts: 235
In the following code....

RWriteStream stream(&buffer);
stream(&buffer);
stream << aMessage;

if aMessage is of type TPtrC and contains only one character say 'a', after execution of 3rd statement the 'stream' contains 2 character '4' and 'a'. I assume the first character is the discriptor data..

How do I copy aMessage to stream without any other metadata being copied.

Thanks,
Vink

Wed, 2006-01-04 21:40
Joined: 2005-08-11
Forum posts: 33
Re: RWriteStream << TPtrC
Hi Vink,

I haven't looked into the implementation of streams on Symbian very far, but I do have some questions for you:

When you use RReadStream, does the string appear to be correct? 
What is contained in the stream before the call to operator<<? 
Is the second line 'stream(&buffer);' a typo?

If you cast the TPtrC to a TDesC, does that give you the behaviour you want?  I doubt that it would, but I had to ask.

Rob
Thu, 2006-01-05 00:54
Joined: 2004-07-10
Forum posts: 364
Re: RWriteStream << TPtrC
That metadata is important - it will contain the length of the string that follows it, if that isn't there then how do you know how much to read in when internalizing it? i.e. if you are externalizing strings you also have to externalize a length.


Thu, 2006-01-05 03:34
Joined: 2004-09-06
Forum posts: 235
Re: RWriteStream << TPtrC
Quote from: prob
Hi Vink,

I haven't looked into the implementation of streams on Symbian very far, but I do have some questions for you:

When you use RReadStream, does the string appear to be correct? 
What is contained in the stream before the call to operator<<? 
Is the second line 'stream(&buffer);' a typo?

If you cast the TPtrC to a TDesC, does that give you the behaviour you want?  I doubt that it would, but I had to ask.

Rob
RReadStream() does retrieve the same data as I had inputted.
But problem comes when I am sending this data to some sever component implemented in Java.

yep the second line 'stream(&buffer);' was a typo.
Nope TDesC doesn't work.
Wed, 2008-04-23 09:31
Joined: 2007-04-30
Forum posts: 1
Re: RWriteStream << TPtrC

How do I copy aMessage to stream without any other metadata being copied.

Use RWriteStream::WriteL() instead of stream operators.

  • Login to reply to this topic.