|
| CInByteStream () |
| Construct an empty object. More...
|
|
| CInByteStream (const char *buf, size_t sz, bool net=kByteOrderDefault) |
| Construct from a byte buffer. More...
|
|
| CInByteStream (const unsigned char *buf, size_t sz, bool net=kByteOrderDefault) |
| Construct from a byte buffer. More...
|
|
| CInByteStream (const signed char *buf, size_t sz, bool net=kByteOrderDefault) |
| Construct from a byte buffer. More...
|
|
| CInByteStream (const std::string &buf, bool net=kByteOrderDefault) |
| Construct from a byte buffer. More...
|
|
void | setSource (const char *buf, size_t sz, bool net=kByteOrderDefault) |
| Initialize with a byte buffer. More...
|
|
void | setSource (const unsigned char *buf, size_t sz, bool net=kByteOrderDefault) |
| Initialize with a byte buffer. More...
|
|
void | setSource (const signed char *buf, size_t sz, bool net=kByteOrderDefault) |
| Initialize with a byte buffer. More...
|
|
void | setSource (const std::string &buf, bool net=kByteOrderDefault) |
| Initialize with a byte buffer. More...
|
|
__Myt & | bad (int code) |
| Set status. More...
|
|
ssize_t | seek (size_t pos) |
| Set current pointer. More...
|
|
ssize_t | skip (ssize_t off) |
| Skip some data. More...
|
|
size_t | cur () const |
| Get current pointer. More...
|
|
const char * | data () const |
| Get a pointer to left data. More...
|
|
size_t | left () const |
| Get byte size of left data. More...
|
|
std::string | toString () const |
| Get a readable description of this object. More...
|
|
|
These functions read sizeof c bytes from underlying data, and store result in c , with appropriate byte order transformation.
- Parameters
-
[out] | c | An integer to receive the result |
- Returns
- Reference to self
|
__Myt & | operator>> (char &c) |
|
__Myt & | operator>> (signed char &c) |
|
__Myt & | operator>> (unsigned char &c) |
|
__Myt & | operator>> (short &c) |
|
__Myt & | operator>> (unsigned short &c) |
|
__Myt & | operator>> (int &c) |
|
__Myt & | operator>> (unsigned int &c) |
|
__Myt & | operator>> (long &c) |
|
__Myt & | operator>> (unsigned long &c) |
|
__Myt & | operator>> (long long &c) |
|
__Myt & | operator>> (unsigned long long &c) |
|
__Myt & | operator>> (wchar_t &c) |
|
|
__Myt & | operator>> (std::string &c) |
| Unpack a string. More...
|
|
__Myt & | operator>> (std::wstring &c) |
| Unpack a wide string. More...
|
|
template<class T , size_t N> |
__Myt & | operator>> (T(&c)[N]) |
| Unpack an array. More...
|
|
|
These functions operates on different manipulators to achieve special purpose.
Please see the corresponding manipulator generators in Manip for more information. - Parameters
-
- Returns
- Reference of self
|
__Myt & | operator>> (void(*m)(__MyBase &)) |
|
template<class T > |
__Myt & | operator>> (const NS_IMPL::CManipulatorRawPtr< T > &m) |
|
template<class T > |
__Myt & | operator>> (const NS_IMPL::CManipulatorRawCont< T > &m) |
|
template<class ForwardIter > |
__Myt & | operator>> (const NS_IMPL::CManipulatorRawRange< ForwardIter > &m) |
|
template<typename LenT , class T > |
__Myt & | operator>> (const NS_IMPL::CManipulatorArrayPtr< LenT, T > &m) |
|
template<typename LenT , class T > |
__Myt & | operator>> (const NS_IMPL::CManipulatorArrayCont< LenT, T > &m) |
|
template<class T > |
__Myt & | operator>> (const NS_IMPL::CManipulatorValueByteOrder< T > &m) |
|
__Myt & | operator>> (const NS_IMPL::CManipulatorSeek &m) |
|
__Myt & | operator>> (const NS_IMPL::CManipulatorSkip &m) |
|
template<typename T > |
__Myt & | operator>> (const NS_IMPL::CManipulatorSkipPtr< T > &m) |
|
template<class T > |
__Myt & | operator>> (const NS_IMPL::CManipulatorOffsetValue< T > &m) |
|
template<class T > |
__Myt & | operator>> (const NS_IMPL::CManipulatorProtobuf< T > &m) |
|
template<typename T > |
__Myt & | operator>> (const NS_IMPL::CManipulatorVarint< T > &m) |
|
__Myt & | operator>> (const NS_IMPL::CManipulatorStubPush &m) |
|
__Myt & | operator>> (const NS_IMPL::CManipulatorStubPop &m) |
|
template<class T , class S > |
__Myt & | operator>> (const NS_IMPL::CManipulatorEnd< T, S > &m) |
|
__Myt & | operator>> (NS_IMPL::CManipulatorEnd< void, void >(*m)()) |
|
Data unpacking interfaces.
CInByteStream is super convenient for unpacking data. It receives a byte buffer containing serialized data, and tries to decode whatever you want from it.
CInByteStream manages data endianness automatically, so you don't need to call hton/ntoh
family APIs manually.It also performs sufficient boundary checks so you won't end up with memory access violations.
What makes CInByteStream really powerful is that it integrates a number of manipulators, which makes unpacking complex structures a joy of life.
Sample code:
uint32_t version;
string name;
vector<uint64_t> orders;
in >> version >> name >> Manip::array(orders);