Stream
| Thu, 2008-04-10 16:32 | |
|
I'm creating a string class(which is basically a wrapper around RBuf). my class looks like so.. class string{I'd like to implement the streaming operator so that I can create strings that format correctly no matter of what I store. For instance. Int x = 15; I'm having an issue understanding RWriteStream Can someone help me out... I think it should look something like this. string& operator<<(TAny* input){Please advise if possible. OwnerOfTheWorld |
|






Forum posts: 132
Trying to create a wrapper class around a descriptor is a whole topic to itself, but leaving that aside (apart from to say you will have a memory leak as things currently are).
If you want to store the input into the RBuf8 why not just do it yourself directly? In a similar way to what you are doing in the constructor.
If you do try to use RWriteStream/RReadStream how will it know what the type of your parameter is or how long it is? If you do it yourself how will you know what type of object you have or how long it is?
Forum posts: 4
I thought that approach at first, but w/out RTTI I can not distinguish what type the object is, i'm trying to append.
And my constructor doesn't do anything.. the equal operator takes a known datatype, but how would I generalize this?
OwnerOfTheWorld
Forum posts: 132
If you can't distinguish what type the object is then how can using RWriteStream?
I didn't mean your constructor, I meant your operator=.
I think you would just have to write overloads of operator<<.
But a main point is the viability of writing a wrapper around a descriptor, the reason one doesn't exist so far for all descriptors is the scale of it. What is the intent of creating a wrapper just for RBuf?