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  bool usingDt = false;
112  input = DtReplaceAllSubstrings(input, '-', "_");
113  input = DtReplaceAllSubstrings(input, '.', "_");
114  input = DtReplaceAllSubstrings(input, ' ', "_");
115  input = DtReplaceAllSubstrings(input, '(', "_");
116  input = DtReplaceAllSubstrings(input, ')', "_");
117 
118 
119  std::map<DtString,DtString>::iterator iter = longNamesToShortNames.find(input);
120  if(iter != longNamesToShortNames.end())
121  {
122  input = iter->second;
123  }
124  else
125  {
126  DtString nonDt = input;
127  if(nonDt[0] == 'D' && nonDt[1] == 't')
128  {
129  nonDt.snipFront('t');
130  std::map<DtString,DtString>::iterator iter = longNamesToShortNames.find(DtFirstCharToLower(nonDt));
131  if(iter != longNamesToShortNames.end())
132  {
133  input = "Dt" + DtFirstCharToUpper(iter->second);
134  }
135  }
136  }
137 
138  if(input.length() > 100)
139  {
140  std::string temp = input.string();
141  temp.resize(50);
142 
144  temp += num;
145 
146  longNamesToShortNames[input] = temp.c_str();
147 
148  input = temp.c_str();
149 
151  }
152 
153  return input;
154 }
155 
156 #ifdef DtUSE_UTILITIES_NAMESPACE
157 }
158 #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)