VR-Link API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlEncodingHelpers.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 ******************************************************************************/
7 
8 #pragma once
9 
10 #include <stdint.h>
11 
12 #ifdef DtUSE_UTILITIES_NAMESPACE
13 namespace DtUSE_UTILITIES_NAMESPACE
14 {
15 #endif
16 
18 const int endianChecker = 1;
19 #define is_bigendian() ( (*(char*)&endianChecker) == 0 )
20 
22 static void swapByteArray( char * byteArray, int theSize )
23 {
24  int theEnd = 0;
25  for( int i = 0; i < ( theSize >> 1 ); ++i )
26  {
27  theEnd = ( theSize - 1 ) - i;
28  byteArray[ i ] ^= byteArray[ theEnd ];
29  byteArray[ theEnd ] ^= byteArray[ i ];
30  byteArray[ i ] ^= byteArray[ theEnd ];
31  }
32 }
33 
36 {
37  unsigned short msbyte = rhs & 0x00ff;
38  unsigned short lsbyte = ( rhs & 0xff00 ) >> 8;
39  return ( msbyte << 8 ) | lsbyte;
40 }
41 
44 {
45  unsigned short msword = endianSwap16Bit( rhs & 0x0000ffff );
46  unsigned short lsword = endianSwap16Bit(( rhs & 0xffff0000 ) >> 16 );
47  return ( msword << 16 ) | lsword;
48 }
49 
52 {
54  unsigned int mspart = endianSwap32Bit( static_cast<unsigned int>(rhs & 0xffffffff) );
55  unsigned int lspart = endianSwap32Bit(static_cast<unsigned int>(( rhs >> 32 ) & 0xffffffff) );
56  return ( DtU64 ( mspart ) << 32 ) | lspart;
57 }
58 
59 #ifdef DtUSE_UTILITIES_NAMESPACE
60 }
61 #endif

Document ID: Generated on Mon Feb 6 18:36:34 EST 2017 from SVN revision 173107
Copyright © 2005-2016 VT MÄK. All Rights Reserved (www.mak.com)