11 #ifndef encodingImplHelpers_H_
12 #define encodingImplHelpers_H_
21 #define is_bigendian() ( (*(char*)&endianChecker) == 0 )
27 for(
int i = 0; i < ( theSize >> 1 ); ++i )
29 theEnd = ( theSize - 1 ) - i;
30 byteArray[ i ] ^= byteArray[ theEnd ];
31 byteArray[ theEnd ] ^= byteArray[ i ];
32 byteArray[ i ] ^= byteArray[ theEnd ];
39 unsigned short msbyte = rhs & 0x00ff;
40 unsigned short lsbyte = ( rhs & 0xff00 ) >> 8;
41 return ( msbyte << 8 ) | lsbyte;
49 return ( msword << 16 ) | lsword;
56 unsigned int mspart =
endianSwap32Bit( static_cast<unsigned int>(rhs & 0xffffffff) );
57 unsigned int lspart =
endianSwap32Bit(static_cast<unsigned int>(( rhs >> 32 ) & 0xffffffff) );
58 return (
Integer64( mspart ) << 32 ) | lspart;
92 inline void appendBytes( std::vector<Octet>& wrapper,
const char* bytes,
size_t length )
96 unsigned int currentBufferSize = wrapper.size();
97 wrapper.resize( currentBufferSize + length );
98 memcpy( &wrapper[ currentBufferSize ], bytes, length );
102 inline unsigned int paddingSizeInBytes(
unsigned int bufferLength,
unsigned int elementOctetBoundary )
104 if ( bufferLength == 0 )
return 0;
105 return bufferLength % elementOctetBoundary;
109 inline void insertBytes( std::vector<Octet>& wrapper,
size_t length )
113 unsigned int currentBufferSize = wrapper.size();
114 wrapper.resize( currentBufferSize + length );
void appendBytes(std::vector< Octet > &wrapper, const char *bytes, size_t length)
append to a octet vector
Definition: encodingImplHelpers.h:92
const int endianChecker
This checks whether the machine is Big Endian or Little Endian.
Definition: encodingImplHelpers.h:20
float endianSwap32BitFloat(float rhs)
swap 32 bit float
Definition: encodingImplHelpers.h:62
unsigned int paddingSizeInBytes(unsigned int bufferLength, unsigned int elementOctetBoundary)
Get the padding for this element.
Definition: encodingImplHelpers.h:102
unsigned short endianSwap16Bit(unsigned short rhs)
swap 16 bits
Definition: encodingImplHelpers.h:37
void swapByteArray(char *byteArray, int theSize)
Swap the byte array in memory.
Definition: encodingImplHelpers.h:24
double endianSwap64BitDouble(double rhs)
Definition: encodingImplHelpers.h:77
void insertBytes(std::vector< Octet > &wrapper, size_t length)
Insert bytes into the octet buffer.
Definition: encodingImplHelpers.h:109
Integer64 endianSwap64Bit(Integer64 rhs)
swap 64 bits
Definition: encodingImplHelpers.h:53
unsigned int endianSwap32Bit(unsigned int rhs)
swap 32 bits
Definition: encodingImplHelpers.h:45
long long Integer64
Definition: EncodingConfig.h:38