C
Christopher Benson-Manica
Sorry for the lame title, but it's hard to condense what I'm about to
say... Here's my situation (my first real C++ situation, yay!).
Currently we have a MyTCPThread (don't let the name scare you, this
isn't OT) that has a socket member object that has methods Send() and
GetLine() for sending and receiving data. I want to subclass
MyTCPThread so I can use << and >> as wrappers for Send() and
GetLine() (Send() is my primary concern at the moment, FWIW). I could
probably come up with some hackneyed scheme to do this on my own, but
I'd really like some advice on how to do it well.
My initial newbie thoughts suggest something like
class
MyStreamBasedTCPThread : public MyTCPThread
{
protected:
std:stringstream outbuf;
};
but the big problem I see with this is how to make << apply to outbuf
(which will get sent) and still keep all the cool overloaded <<
operators that ostringstreams already have. I'm really feeling lost
looking for a good way to do this. I'd be extremely grateful for any
guidance!
say... Here's my situation (my first real C++ situation, yay!).
Currently we have a MyTCPThread (don't let the name scare you, this
isn't OT) that has a socket member object that has methods Send() and
GetLine() for sending and receiving data. I want to subclass
MyTCPThread so I can use << and >> as wrappers for Send() and
GetLine() (Send() is my primary concern at the moment, FWIW). I could
probably come up with some hackneyed scheme to do this on my own, but
I'd really like some advice on how to do it well.
My initial newbie thoughts suggest something like
class
MyStreamBasedTCPThread : public MyTCPThread
{
protected:
std:stringstream outbuf;
};
but the big problem I see with this is how to make << apply to outbuf
(which will get sent) and still keep all the cool overloaded <<
operators that ostringstreams already have. I'm really feeling lost
looking for a good way to do this. I'd be extremely grateful for any
guidance!