I have many classes with varying implementations of their private member boost::tuple<> structures ie. <std::string, int> or <short, short, float>.
I now need to parse that tuple into a private const char* message (since I want to send it via tcp), but not without changing the endianess on those data types that need their endianess changed.
This i what I have so far:
struct parseTuple{
template<typename T>
void operator()(T& t) const{
std::cout << ntohl(t) << "\n";
}
};
void Base::createMessageFromTuple(){
boost::fusion::for_each(this->structure, parseTuple());
}
There are a few things I think I need to know before I can proceed:
How to keep track of the tuple members so i can allocate space for the
messageaccording to their datatypes (static member, maybe?)How to differentiate in the template between the datatypes that fit the
ntohlrequirements and those that need different treatment i.e.std::string- Is this even the correct approach?