Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wrapper classes? 1

Status
Not open for further replies.

EnCocytus

Programmer
Dec 18, 2002
24
US
I am currently writing a client/server dll, and what I want to do is be able to send anything over the connection. Such as files, objects, or simple text. Is there a master class that all other data classes are derived from? The closest thing I could find was CObject, but I don't think it could handle files. Also, does MFC implement wrapper classes?

Thanx for the help

1001100 1110101 1101011 1100101
 
Such a class does not exist native to C++.

I've made a class like this before. Although you will probably have to modify it to suit your needs.

[tt]class MD
{
private:
void* data; [/tt]// the internal buffer[tt]
long length; [/tt]// and the length thereof[tt]
public:
MD();

[/tt]// each of these overloads set the length to[tt]
[/tt]// the size of its respective type, allocates that much[tt]
[/tt]// memory, and then copies v to its buffer[tt]
MD& operator=(signed long v);
MD& operator=(unsigned long v);
MD& operator=(signed short v);
MD& operator=(unsigned short v);
MD& operator=(signed char v);
MD& operator=(unsigned char v);

[/tt]// data accessors for primitive types[tt]
operator signed long() const;
operator unsigned long() const;
operator signed short() const;
operator unsigned short() const;
operator signed char() const;
operator unsigned char() const;

[/tt]// this allocates strlen(sz) bytes of memory[tt]
[/tt]// and then copies sz to the buffer[tt]
MD& operator=(const char* sz);
[/tt]// this appends '\0' and then returns pointer to buffer[tt]
operator const char*() const;
};
[/tt]
Try it, see how you like it.

[sub]I REALLY hope that helps.[/sub]
Will
 
Amazing, this looks like it might be just what I'm looking for. It will prolly take a little time to customize and implement. But I think this should be enough.

Thank you.

1001100 1110101 1101011 1100101
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top