M
ma740988
I'm receiving 60 bytes of data from an interface. For discussion
purposes lets consider.
unsigned char data [ 60 ] = { 0x00, 0x05, 0xFE, 0xCA };
The goal: Store the bytes into an array of unsigned short such that:
typedef std::vector < unsigned short > USHORT_VEC ;
USHORT_VEC us_vec ( 2 ) ;
us_vec [ 0 ] = 0x0005 ;
us_vec [ 1 ] = 0xFECA ;
NOTE: a 'simple' memcpy of the data results in 0x500 and 0xCAFE, for
elements 0 and 1 respectively - which is not what I want.
The question: Can I use a custom streambuf implementation - derived
off streambuf to achieve the objective?
I'll admit that the entire streams facility seems daunting (even while
skimming through Langer/Kreft) so source snippet/any help
appreciated.
Thanks
purposes lets consider.
unsigned char data [ 60 ] = { 0x00, 0x05, 0xFE, 0xCA };
The goal: Store the bytes into an array of unsigned short such that:
typedef std::vector < unsigned short > USHORT_VEC ;
USHORT_VEC us_vec ( 2 ) ;
us_vec [ 0 ] = 0x0005 ;
us_vec [ 1 ] = 0xFECA ;
NOTE: a 'simple' memcpy of the data results in 0x500 and 0xCAFE, for
elements 0 and 1 respectively - which is not what I want.
The question: Can I use a custom streambuf implementation - derived
off streambuf to achieve the objective?
I'll admit that the entire streams facility seems daunting (even while
skimming through Langer/Kreft) so source snippet/any help
appreciated.
Thanks