CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Dec 2005
    Posts
    382

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured