+/*! \fn double UnpackDouble(const char* buffer)\r
+ \brief reads a double value from byte buffer\r
+\r
+ \param[in] buffer source byte buffer\r
+ \return the (double) value read from the buffer\r
+*/\r
+API_EXPORT inline double UnpackDouble(const char* buffer) {\r
+ union { double value; unsigned char valueBuffer[sizeof(double)]; } un;\r
+ un.value = 0;\r
+ un.valueBuffer[0] = buffer[0];\r
+ un.valueBuffer[1] = buffer[1];\r
+ un.valueBuffer[2] = buffer[2];\r
+ un.valueBuffer[3] = buffer[3];\r
+ un.valueBuffer[4] = buffer[4];\r
+ un.valueBuffer[5] = buffer[5];\r
+ un.valueBuffer[6] = buffer[6];\r
+ un.valueBuffer[7] = buffer[7];\r
+ return un.value;\r
+}\r
+\r
+/*! \fn double UnpackDouble(char* buffer)\r
+ \brief reads a double value from byte buffer\r
+\r
+ This is an overloaded function.\r
+\r
+ \param[in] buffer source byte buffer\r
+ \return the (double) value read from the buffer\r
+*/\r
+API_EXPORT inline double UnpackDouble(char* buffer) {\r
+ return UnpackDouble( (const char*)buffer );\r
+}\r
+\r
+/*! \fn double UnpackFloat(const char* buffer)\r
+ \brief reads a float value from byte buffer\r
+\r
+ \param[in] buffer source byte buffer\r
+ \return the (float) value read from the buffer\r
+*/\r
+API_EXPORT inline float UnpackFloat(const char* buffer) {\r
+ union { float value; unsigned char valueBuffer[sizeof(float)]; } un;\r
+ un.value = 0;\r
+ un.valueBuffer[0] = buffer[0];\r
+ un.valueBuffer[1] = buffer[1];\r
+ un.valueBuffer[2] = buffer[2];\r
+ un.valueBuffer[3] = buffer[3];\r
+ return un.value;\r
+}\r
+\r
+/*! \fn double UnpackFloat(char* buffer)\r
+ \brief reads a float value from byte buffer\r
+\r
+ This is an overloaded function.\r
+\r
+ \param[in] buffer source byte buffer\r
+ \return the (float) value read from the buffer\r
+*/\r
+API_EXPORT inline float UnpackFloat(char* buffer) {\r
+ return UnpackFloat( (const char*)buffer );\r
+}\r
+\r
+/*! \fn signed int UnpackSignedInt(const char* buffer)\r
+ \brief reads a signed integer value from byte buffer\r
+\r
+ \param[in] buffer source byte buffer\r
+ \return the (signed int) value read from the buffer\r
+*/\r
+API_EXPORT inline signed int UnpackSignedInt(const char* buffer) {\r
+ union { signed int value; unsigned char valueBuffer[sizeof(signed int)]; } un;\r
+ un.value = 0;\r
+ un.valueBuffer[0] = buffer[0];\r
+ un.valueBuffer[1] = buffer[1];\r
+ un.valueBuffer[2] = buffer[2];\r
+ un.valueBuffer[3] = buffer[3];\r
+ return un.value;\r
+}\r
+\r
+/*! \fn signed int UnpackSignedInt(char* buffer)\r
+ \brief reads a signed integer value from byte buffer\r
+\r
+ This is an overloaded function.\r
+\r
+ \param[in] buffer source byte buffer\r
+ \return the (signed int) value read from the buffer\r
+*/\r
+API_EXPORT inline signed int UnpackSignedInt(char* buffer) {\r
+ return UnpackSignedInt( (const char*) buffer );\r
+}\r
+\r
+/*! \fn signed short UnpackSignedShort(const char* buffer)\r
+ \brief reads a signed short integer value from byte buffer\r
+\r
+ \param[in] buffer source byte buffer\r
+ \return the (signed short) value read from the buffer\r
+*/\r
+API_EXPORT inline signed short UnpackSignedShort(const char* buffer) {\r
+ union { signed short value; unsigned char valueBuffer[sizeof(signed short)]; } un;\r
+ un.value = 0;\r
+ un.valueBuffer[0] = buffer[0];\r
+ un.valueBuffer[1] = buffer[1];\r
+ return un.value;\r
+}\r
+\r
+/*! \fn signed short UnpackSignedShort(char* buffer)\r
+ \brief reads a signed short integer value from byte buffer\r
+\r
+ This is an overloaded function.\r
+\r
+ \param[in] buffer source byte buffer\r
+ \return the (signed short) value read from the buffer\r
+*/\r
+API_EXPORT inline signed short UnpackSignedShort(char* buffer) {\r
+ return UnpackSignedShort( (const char*)buffer );\r
+}\r
+\r
+/*! \fn unsigned int UnpackUnsignedInt(const char* buffer)\r
+ \brief reads an unsigned integer value from byte buffer\r
+\r
+ \param[in] buffer source byte buffer\r
+ \return the (unsigned int) value read from the buffer\r
+*/\r
+API_EXPORT inline unsigned int UnpackUnsignedInt(const char* buffer) {\r
+ union { unsigned int value; unsigned char valueBuffer[sizeof(unsigned int)]; } un;\r
+ un.value = 0;\r
+ un.valueBuffer[0] = buffer[0];\r
+ un.valueBuffer[1] = buffer[1];\r
+ un.valueBuffer[2] = buffer[2];\r
+ un.valueBuffer[3] = buffer[3];\r
+ return un.value;\r
+}\r
+\r
+/*! \fn unsigned int UnpackUnsignedInt(char* buffer)\r
+ \brief reads an unsigned integer value from byte buffer\r
+\r
+ This is an overloaded function.\r
+\r
+ \param[in] buffer source byte buffer\r
+ \return the (unsigned int) value read from the buffer\r
+*/\r
+API_EXPORT inline unsigned int UnpackUnsignedInt(char* buffer) {\r
+ return UnpackUnsignedInt( (const char*)buffer );\r
+}\r
+\r
+/*! \fn unsigned short UnpackUnsignedShort(const char* buffer)\r
+ \brief reads an unsigned short integer value from byte buffer\r
+\r
+ \param[in] buffer source byte buffer\r
+ \return the (unsigned short) value read from the buffer\r
+*/\r
+API_EXPORT inline unsigned short UnpackUnsignedShort(const char* buffer) {\r
+ union { unsigned short value; unsigned char valueBuffer[sizeof(unsigned short)]; } un;\r
+ un.value = 0;\r
+ un.valueBuffer[0] = buffer[0];\r
+ un.valueBuffer[1] = buffer[1];\r
+ return un.value;\r
+}\r
+\r
+/*! \fn unsigned short UnpackUnsignedShort(char* buffer)\r
+ \brief reads an unsigned short integer value from byte buffer\r
+\r
+ This is an overloaded function.\r
+\r
+ \param[in] buffer source byte buffer\r
+ \return the (unsigned short) value read from the buffer\r
+*/\r
+API_EXPORT inline unsigned short UnpackUnsignedShort(char* buffer) {\r
+ return UnpackUnsignedShort( (const char*)buffer );\r
+}\r
+\r
+// ----------------------------------------------------------------\r
+// 'internal' helper structs\r
+\r
+/*! \struct RaiiBuffer\r
+ \internal\r
+*/\r
+struct RaiiBuffer {\r
+ RaiiBuffer(const size_t n)\r
+ : Buffer( new char[n]() )\r
+ { }\r
+ ~RaiiBuffer(void) {\r
+ delete[] Buffer;\r
+ }\r
+ char* Buffer;\r
+};\r
+\r