VR-Link API Documentation for HLA Evolved
 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 
16 #ifdef DtUSE_UTILITIES_NAMESPACE
17 namespace DtUSE_UTILITIES_NAMESPACE
18 {
19 #endif
20 
21 static int myCurrentLargeFileNum = 0;
22 static std::map<DtString,DtString> longNamesToShortNames;
25 {
27  struct{
30  } bits;
31 };
32 
34 {
36  struct{
39  } bits;
40 };
42 const int endianChecker = 1;
43 #define is_bigendian() ( (*(char*)&endianChecker) == 0 )
44 
46 static void swapByteArray( char * byteArray, int theSize )
47 {
48  int theEnd = 0;
49  for( int i = 0; i < ( theSize >> 1 ); ++i )
50  {
51  theEnd = ( theSize - 1 ) - i;
52  byteArray[ i ] ^= byteArray[ theEnd ];
53  byteArray[ theEnd ] ^= byteArray[ i ];
54  byteArray[ i ] ^= byteArray[ theEnd ];
55  }
56 }
57 
60 {
61  unsigned short msbyte = rhs & 0x00ff;
62  unsigned short lsbyte = ( rhs & 0xff00 ) >> 8;
63  return ( msbyte << 8 ) | lsbyte;
64 }
65 
68 {
69  unsigned short msword = endianSwap16Bit( rhs & 0x0000ffff );
70  unsigned short lsword = endianSwap16Bit(( rhs & 0xffff0000 ) >> 16 );
71  return ( msword << 16 ) | lsword;
72 }
73 
76 {
78  unsigned int mspart = endianSwap32Bit( static_cast<unsigned int>(rhs & 0xffffffff) );
79  unsigned int lspart = endianSwap32Bit(static_cast<unsigned int>(( rhs >> 32 ) & 0xffffffff) );
80  return ( DtU64 ( mspart ) << 32 ) | lspart;
81 }
82 
85 {
86  DtFloat32Layout temp;
87  temp.flt = rhs;
89  DtU16 mspart = endianSwap16Bit(temp.bits.mslong);
90  DtU16 lspart = endianSwap16Bit(temp.bits.lslong);
91  temp.bits.mslong = mspart;
92  temp.bits.lslong = lspart;
93  return temp.flt;
94 }
95 
98 {
99  DtFloat64Layout temp;
100  temp.flt = rhs;
102  DtU32 mspart = endianSwap32Bit(temp.bits.mslong);
103  DtU32 lspart = endianSwap32Bit(temp.bits.lslong);
104  temp.bits.mslong = mspart;
105  temp.bits.lslong = lspart;
106  return temp.flt;
107 }
108 
110 {
111  bool usingDt = false;
112  input = DtReplaceAllSubstrings(input, '/', "__");
113  input = DtReplaceAllSubstrings(input, '#', "__");
114  input = DtReplaceAllSubstrings(input, '&', "__");
115  input = DtReplaceAllSubstrings(input, '-', "__");
116  input = DtReplaceAllSubstrings(input, '.', "__");
117  input = DtReplaceAllSubstrings(input, ' ', "__");
118  input = DtReplaceAllSubstrings(input, '(', "_");
119  input = DtReplaceAllSubstrings(input, ')', "_");
120  input = DtReplaceAllSubstrings(input, '<', "_");
121  input = DtReplaceAllSubstrings(input, '>', "_");
122 
123  DtString inputUpper = input;
124  inputUpper.toUpper();
125 
126  std::map<DtString,DtString>::iterator iter = longNamesToShortNames.find(inputUpper);
127  if(iter != longNamesToShortNames.end())
128  {
129  input = iter->second;
130  }
131  else
132  {
133  DtString nonDt = input;
134  if(nonDt[0] == 'D' && nonDt[1] == 't')
135  {
136  nonDt.snipFront('t');
137  DtString nonDtUpper = nonDt;
138  nonDtUpper.toUpper();
139  std::map<DtString,DtString>::iterator iter = longNamesToShortNames.find(nonDtUpper);
140  if(iter != longNamesToShortNames.end())
141  {
142  input = "Dt" + DtFirstCharToUpper(iter->second);
143  }
144  }
145  }
146 
147  if(input.length() > 100)
148  {
149  std::string temp = input.string();
150  temp.resize(50);
151 
153  temp += num;
154 
155  longNamesToShortNames[inputUpper] = temp.c_str();
156 
157  input = temp.c_str();
158 
160  }
161 
162  return input;
163 }
164 
165 #ifdef DtUSE_UTILITIES_NAMESPACE
166 }
167 #endif

Document ID: Generated on Mon Apr 8 04:49:21 EDT 2019 from SVN revision 197403
Copyright © 2005-2016 VT MÄK. All Rights Reserved (www.mak.com)