| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|
|||||||
| C++ (Non Visual C++ Issues) Ask or answer C and C++ questions not related to Visual C++. This includes Console programming, Linux programming, or general ANSI C++. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
binary input and output stream
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 ;
}
Last edited by mop65715; November 20th, 2009 at 08:55 PM. |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|