VR-Link API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlCgHelpers.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 ******************************************************************************/
5 
8 
9 #pragma once
10 
11 #include "vlString.h"
12 #include "vlStringUtil.h"
13 #include <map>
14 
15 #ifdef DtUSE_UTILITIES_NAMESPACE
16 namespace DtUSE_UTILITIES_NAMESPACE
17 {
18 #endif
19 
20 static int myCurrentLargeFileNum = 0;
21 static std::map<DtString,DtString> longNamesToShortNames;
24 {
26  struct{
29  } bits;
30 };
31 
33 {
35  struct{
38  } bits;
39 };
41 const int endianChecker = 1;
42 #define is_bigendian() ( (*(char*)&endianChecker) == 0 )
43 
45 static void swapByteArray( char * byteArray, int theSize )
46 {
47  int theEnd = 0;
48  for( int i = 0; i < ( theSize >> 1 ); ++i )
49  {
50  theEnd = ( theSize - 1 ) - i;
51  byteArray[ i ] ^= byteArray[ theEnd ];
52  byteArray[ theEnd ] ^= byteArray[ i ];
53  byteArray[ i ] ^= byteArray[ theEnd ];
54  }
55 }
56 
59 {
60  unsigned short msbyte = rhs & 0x00ff;
61  unsigned short lsbyte = ( rhs & 0xff00 ) >> 8;
62  return ( msbyte << 8 ) | lsbyte;
63 }
64 
67 {
68  unsigned short msword = endianSwap16Bit( rhs & 0x0000ffff );
69  unsigned short lsword = endianSwap16Bit(( rhs & 0xffff0000 ) >> 16 );
70  return ( msword << 16 ) | lsword;
71 }
72 
75 {
77  unsigned int mspart = endianSwap32Bit( static_cast<unsigned int>(rhs & 0xffffffff) );
78  unsigned int lspart = endianSwap32Bit(static_cast<unsigned int>(( rhs >> 32 ) & 0xffffffff) );
79  return ( DtU64 ( mspart ) << 32 ) | lspart;
80 }
81 
84 {
85  DtFloat32Layout temp;
86  temp.flt = rhs;
88  DtU16 mspart = endianSwap16Bit(temp.bits.mslong);
89  DtU16 lspart = endianSwap16Bit(temp.bits.lslong);
90  temp.bits.mslong = mspart;
91  temp.bits.lslong = lspart;
92  return temp.flt;
93 }
94 
97 {
98  DtFloat64Layout temp;
99  temp.flt = rhs;
101  DtU32 mspart = endianSwap32Bit(temp.bits.mslong);
102  DtU32 lspart = endianSwap32Bit(temp.bits.lslong);
103  temp.bits.mslong = mspart;
104  temp.bits.lslong = lspart;
105  return temp.flt;
106 }
107 
108 
110 {
111  input = DtReplaceAllSubstrings(input, '-', "_");
112  input = DtReplaceAllSubstrings(input, '.', "_");
113 
114  std::map<DtString,DtString>::iterator iter = longNamesToShortNames.find(input);
115  if(iter != longNamesToShortNames.end())
116  {
117  input = iter->second;
118  }
119  else if(input.length() > 100)
120  {
121  std::string temp = input.string();
122  temp.resize(50);
123 
125  temp += num;
126 
127  longNamesToShortNames[input] = temp.c_str();
128 
129  input = temp.c_str();
130 
132  }
133 
134  return input;
135 }
136 
137 #ifdef DtUSE_UTILITIES_NAMESPACE
138 }
139 #endif

Document ID: Generated on Wed Jan 7 13:31:29 EST 2015 from SVN revision 149162
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)