I'm trying to put together a class or (suite of classes) that'll support reads and writes in binary form into an input and output stream respectively. The class will also support automatic conversion from big-endian (network byte order) to little-endian and vice-versa. The question: I need design guidance on how I could setup the class such that I'll have support for both file I/O (read/writes to a file) and/or a vector - of say unsigned char. For instance.
Code:typedef std::vector < unsigned char > uchar_vec ; int main() { unsigned short a ( 0 ); unsigned short b ( 0 ); uchar_vec my_vec ( 4 ) ; contents_from_my_vec_to_shorts >> short_a >> short_b ; contents_from_shorts_to_myvec << short_a << short_b ; }


Reply With Quote