I'm working with a bunch of configuration data that needs to be sent over
from a workstation to a server. The old method was to simply memcpy
structures into a buffer and send that across, however now I'm trying to
use variable sized classes and coming into some difficulty in the copying
data to a bytestream without going too crazy. So I ask, what are your
experiences/suggestions/help with doing the following:
(Pointing me to other documetation, or new nifty libraries is fine)
#include <vector>
#include <memory>
class A {
public:
int aa;
int bb;
};
class B {
public:
std::vector<A*> aList;
void insert(A *element){
aList.push_back(element);
}
};
char Lan_Data[1000];
void workstation(){
A a1,a2;
B b;
a1.aa=10;a1.bb=20;
a2.aa=30;a2.bb=40;
b.insert(&a1);
b.insert(&a2);
//Now, copy data of 'b' (no matter how many elements)
//into a char buffer (Lan_Data) to send to a socket
// TBD:????
}
void server(){
B b;
//Take data from Lan_Data and load up the 'b' element.
// TBD:????
}
int main(){
memset(Lan_Data,0,sizeof(Lan_Data));
workstation();
server();
return 0;
}