AnimatLab  2
Test
StdUtilFunctions.h
Go to the documentation of this file.
1 
7 namespace StdUtils
8 {
9 
10 //#define STD_LOG_DB_ON
11 #define STD_LOG_DB_DSN ""
12 #define STD_LOG_DB_USER ""
13 #define STD_LOG_DB_PSWD ""
14 
15 enum StdLogLevel
16 {
17  StdLogNone = 0, // no trace
18  StdLogError = 10, // only trace error
19  StdLogInfo = 20, // some extra info
20  StdLogDebug = 30, // debugging info
21  StdLogDetail = 40 // detailed debugging info
22 };
23 
24 /*
25 void STD_UTILS_PORT ThrowError(long lError, std::string strSource, std::string strError, std::string strValueName, long lVal);
26 void STD_UTILS_PORT ThrowError(long lError, std::string strSource, std::string strError, std::string strValueName, double dblVal);
27 void STD_UTILS_PORT ThrowError(long lError, std::string strSource, std::string strError, std::string strValueName, std::string strVal);
28 void STD_UTILS_PORT ThrowError(long lError, std::string strSource, std::string strError, std::string strAddToError = "");
29 void STD_UTILS_PORT RelayError(CStdErrorInfo oInfo);
30 */
31 
32 // -----------------------------------------------------------------------------
33 // MIN and MAX. The Standard C++ template versions go by so many names (at
34 // at least in the MS implementation) that you never know what's available
35 // -----------------------------------------------------------------------------
36 template<class Type>
37 inline const Type& SSMIN(const Type& arg1, const Type& arg2)
38 {
39  return arg2 < arg1 ? arg2 : arg1;
40 }
41 template<class Type>
42 inline const Type& SSMAX(const Type& arg1, const Type& arg2)
43 {
44  return arg2 > arg1 ? arg2 : arg1;
45 }
46 
47 std::string STD_UTILS_PORT Std_CreateAppID();
48 
49 void STD_UTILS_PORT Std_RelayError(CStdErrorInfo oInfo, std::string strSourceFile, long lSourceLine);
50 void STD_UTILS_PORT Std_ThrowError(long lError, std::string strError, std::string strSourceFile, long lSourceLine,
51  std::string strValueName, unsigned char iVal);
52 void STD_UTILS_PORT Std_ThrowError(long lError, std::string strError, std::string strSourceFile, long lSourceLine,
53  std::string strValueName, unsigned short iVal);
54 void STD_UTILS_PORT Std_ThrowError(long lError, std::string strError, std::string strSourceFile, long lSourceLine,
55  std::string strValueName, int iVal);
56 void STD_UTILS_PORT Std_ThrowError(long lError, std::string strError, std::string strSourceFile, long lSourceLine,
57  std::string strValueName, long lVal);
58 void STD_UTILS_PORT Std_ThrowError(long lError, std::string strError, std::string strSourceFile, long lSourceLine,
59  std::string strValueName, float fltVal);
60 void STD_UTILS_PORT Std_ThrowError(long lError, std::string strError, std::string strSourceFile, long lSourceLine,
61  std::string strValueName, double dblVal);
62 void STD_UTILS_PORT Std_ThrowError(long lError, std::string strError, std::string strSourceFile, long lSourceLine,
63  std::string strValueName, std::string strVal);
64 void STD_UTILS_PORT Std_ThrowError(long lError, std::string strError, std::string strSourceFile, long lSourceLine,
65  std::string strText);
66 
67 #ifndef RELAY_ERROR
68  #define RELAY_ERROR(oError) Std_RelayError(oError, __FILE__, __LINE__)
69 #endif
70 
71 #ifndef THROW_PARAM_ERROR
72  #define THROW_PARAM_ERROR(lError, strError, strValueName, Val) Std_ThrowError(lError, strError, __FILE__, __LINE__, strValueName, Val)
73 #endif
74 
75 #ifndef THROW_TEXT_ERROR
76  #define THROW_TEXT_ERROR(lError, strError, strText) Std_ThrowError(lError, strError, __FILE__, __LINE__, strText)
77 #endif
78 
79 #ifndef THROW_ERROR
80  #define THROW_ERROR(lError, strError) Std_ThrowError(lError, strError, __FILE__, __LINE__, "")
81 #endif
82 
83 std::string STD_UTILS_PORT Std_ToStr(std::string strVal);
84 std::string STD_UTILS_PORT Std_ToStr(const char *strVal);
85 std::string STD_UTILS_PORT Std_ToStr(unsigned char iVal);
86 std::string STD_UTILS_PORT Std_ToStr(unsigned short iVal);
87 std::string STD_UTILS_PORT Std_ToStr(int iVal);
88 std::string STD_UTILS_PORT Std_ToStr(unsigned int iVal);
89 std::string STD_UTILS_PORT Std_ToStr(long lVal);
90 std::string STD_UTILS_PORT Std_ToStr(unsigned long lVal);
91 std::string STD_UTILS_PORT Std_ToStr(float fltVal);
92 std::string STD_UTILS_PORT Std_ToStr(double dblVal);
93 std::string STD_UTILS_PORT Std_ToStr(bool bVal);
94 std::string STD_UTILS_PORT Std_ToStr(std::string strFormat, unsigned char iVal);
95 std::string STD_UTILS_PORT Std_ToStr(std::string strFormat, unsigned short iVal);
96 std::string STD_UTILS_PORT Std_ToStr(std::string strFormat, int iVal);
97 std::string STD_UTILS_PORT Std_ToStr(std::string strFormat, long lVal);
98 std::string STD_UTILS_PORT Std_ToStr(std::string strFormat, float fltVal);
99 std::string STD_UTILS_PORT Std_ToStr(std::string strFormat, double dblVal);
100 
101 bool STD_UTILS_PORT Std_ToBool(int iVal);
102 bool STD_UTILS_PORT Std_ToBool(std::string strVal);
103 std::string STD_UTILS_PORT Std_NullStr(std::string strFormat);
104 
105 #ifdef WIN32
106  std::string STD_UTILS_PORT Std_ConvertToANSI(LPCWSTR strData);
107  LPWSTR STD_UTILS_PORT Std_ConvertFromANSI(std::string strData);
108 #endif
109 
110 #define STR(v) Std_ToStr(v)
111 #define FSTR(f, v) Std_ToStr(f, v)
112 #define NULL_STR(s) Std_NullStr(s)
113 
114 #ifdef WIN32
115  #define STD_MAX max
116  #define STD_MIN min
117 #else
118  #define STD_MAX std::max
119  #define STD_MIN std::min
120 #endif
121 
122 int STD_UTILS_PORT Std_VariantTypeToConst(std::string strType);
123 std::string STD_UTILS_PORT Std_ConstToVariantType(int iType);
124 
125 int STD_UTILS_PORT Std_Split(const std::string& input, const std::string& delimiter, CStdArray<std::string> &results);
126 std::string STD_UTILS_PORT Std_Combine(CStdArray<std::string> &aryParts, std::string strDelimiter);
127 std::string STD_UTILS_PORT Std_Trim(std::string strVal);
128 std::string STD_UTILS_PORT Std_TrimLeft(std::string strVal);
129 std::string STD_UTILS_PORT Std_TrimRight(std::string strVal);
130 bool STD_UTILS_PORT Std_IsNumeric(std::string strVal);
131 bool STD_UTILS_PORT Std_IsIntegerType(std::string strVal);
132 std::string STD_UTILS_PORT Std_Left(std::string strVal, int iCount);
133 std::string STD_UTILS_PORT Std_Right(std::string strVal, int iCount);
134 std::string STD_UTILS_PORT Std_ToUpper(std::string strVal);
135 std::string STD_UTILS_PORT Std_ToLower(std::string strVal);
136 std::string STD_UTILS_PORT Std_Replace(std::string strVal, std::string strFind, std::string strReplace);
137 
138 long STD_UTILS_PORT Std_RGB(unsigned char iRed, unsigned char iGreen, unsigned char iBlue);
139 //long STD_UTILS_PORT Std_LoadRGB(CStdXml &oXml, std::string strParamName, bool bThrowError = true, long lDefault = 0);
140 //void STD_UTILS_PORT Std_LoadColor(CStdXml &oXml, std::string strParamName, float *aryColor, bool bThrowError = true);
141 //void STD_UTILS_PORT Std_LoadColor(std::string strXml, std::string strParamName, float *aryColor, bool bThrowError = true);
142 
143 int STD_UTILS_PORT Std_Sign(float fltVal);
144 int STD_UTILS_PORT Std_Sign(float fltVal, float fltDefault);
145 void STD_UTILS_PORT Std_SRand(unsigned long lSeed);
146 int STD_UTILS_PORT Std_IRand( int low, int high );
147 long STD_UTILS_PORT Std_LRand( long low, long high );
148 float STD_UTILS_PORT Std_FRand( float low, float high );
149 double STD_UTILS_PORT Std_DRand( double low, double high );
150 
151 
152 bool STD_UTILS_PORT Std_InValidRange(int iMinVal, int iMaxVal, int iVal, bool bThrowError = true, std::string strParamName = "");
153 bool STD_UTILS_PORT Std_InValidRange(long lMinVal, long lMaxVal, long lVal, bool bThrowError = true, std::string strParamName = "");
154 bool STD_UTILS_PORT Std_InValidRange(float fltMinVal, float fltMaxVal, float fltVal, bool bThrowError = true, std::string strParamName = "");
155 bool STD_UTILS_PORT Std_InValidRange(double dblMinVal, double dblMaxVal, double dblVal, bool bThrowError = true, std::string strParamName = "");
156 
157 bool STD_UTILS_PORT Std_IsBelowMax(int iMaxVal, int iVal, bool bThrowError = true, std::string strParamName = "", bool bInclusiveLimit = false);
158 bool STD_UTILS_PORT Std_IsBelowMax(long lMaxVal, long lVal, bool bThrowError = true, std::string strParamName = "", bool bInclusiveLimit = false);
159 bool STD_UTILS_PORT Std_IsBelowMax(float fltMaxVal, float fltVal, bool bThrowError = true, std::string strParamName = "", bool bInclusiveLimit = false);
160 bool STD_UTILS_PORT Std_IsBelowMax(double dblMaxVal, double dblVal, bool bThrowError = true, std::string strParamName = "", bool bInclusiveLimit = false);
161 
162 bool STD_UTILS_PORT Std_IsAboveMin(int iMinVal, int iVal, bool bThrowError = true, std::string strParamName = "", bool bInclusiveLimit = false);
163 bool STD_UTILS_PORT Std_IsAboveMin(long lMinVal, long lVal, bool bThrowError = true, std::string strParamName = "", bool bInclusiveLimit = false);
164 bool STD_UTILS_PORT Std_IsAboveMin(float fltMinVal, float fltVal, bool bThrowError = true, std::string strParamName = "", bool bInclusiveLimit = false);
165 bool STD_UTILS_PORT Std_IsAboveMin(double dblMinVal, double dblVal, bool bThrowError = true, std::string strParamName = "", bool bInclusiveLimit = false);
166 
167 std::string STD_UTILS_PORT Std_CheckString(std::string strVal);
168 bool STD_UTILS_PORT Std_IsBlank(std::string strVal);
169 
170 std::string STD_UTILS_PORT Std_RetrieveParam(int argc, const char **argv, std::string strParamName, bool bThrowError = true);
171 
172 //***************************************************************************************************************
173 // Byte Array Functions
174 
175 long STD_UTILS_PORT Std_GetBitSize(CStdArray<unsigned char> &aryRawData);
176 
177 std::string STD_UTILS_PORT Std_ByteArrayToHexString(CStdArray<unsigned char> &aryBytes);
178 void STD_UTILS_PORT Std_ByteArrayToHexString(CStdArray<unsigned char> &aryBytes, std::string &strHex);
179 void STD_UTILS_PORT Std_HexStringToByteArray(std::string strHex, CStdArray<unsigned char> &aryBytes);
180 unsigned char STD_UTILS_PORT *Std_HexStringToByteArray(std::string strHex, long &lArraySize);
181 unsigned char STD_UTILS_PORT Std_HexToByte(std::string strVal);
182 unsigned char STD_UTILS_PORT Std_HexCharToByte(char cVal);
183 
184 void STD_UTILS_PORT Std_GetBinarySection(CStdArray<unsigned char> &aryRawData, long lStartBit, long lBitLength, unsigned char &cOut);
185 void STD_UTILS_PORT Std_GetBinarySection(CStdArray<unsigned char> &aryRawData, long lStartBit, long lBitLength, unsigned short &iOut);
186 void STD_UTILS_PORT Std_GetBinarySection(CStdArray<unsigned char> &aryRawData, long lStartBit, long lBitLength, unsigned long &lOut);
187 void STD_UTILS_PORT Std_GetBinarySection(CStdArray<unsigned char> &aryRawData, long lStartBit, long lBitLength, CStdArray<unsigned char> &aryOutData);
188 unsigned char STD_UTILS_PORT Std_GetByteFromArray(CStdArray<unsigned char> &aryRawData, long lEndBit, long lBitsNeeded);
189 bool STD_UTILS_PORT Std_GetBitFromArray(CStdArray<unsigned char> &aryRawData, long lBit);
190 
191 
192 void STD_UTILS_PORT Std_SetBinarySection(CStdArray<unsigned char> &aryRawData, long lStartBit, long lBitLength, unsigned char cIn);
193 void STD_UTILS_PORT Std_SetBinarySection(CStdArray<unsigned char> &aryRawData, long lStartBit, long lBitLength, unsigned short iIn);
194 void STD_UTILS_PORT Std_SetBinarySection(CStdArray<unsigned char> &aryRawData, long lStartBit, long lBitLength, unsigned long lIn);
195 void STD_UTILS_PORT Std_SetBinarySection(CStdArray<unsigned char> &aryRawData, long lStartBit, long lBitLength, CStdArray<unsigned char> &aryInData);
196 void STD_UTILS_PORT Std_SetByteInArray(CStdArray<unsigned char> &aryRawData, unsigned char cIn, long lEndBit, long lBitsNeeded);
197 void STD_UTILS_PORT Std_SetBitInArray(CStdArray<unsigned char> &aryRawData, long lBit, bool bVal);
198 void STD_UTILS_PORT Std_SetBitRangeInArray(CStdArray<unsigned char> &aryRawData, long lStartBit, long lBitLength, bool bVal);
199 void STD_UTILS_PORT Std_FlipBitInArray(CStdArray<unsigned char> &aryRawData, long lBit);
200 void STD_UTILS_PORT Std_FlipBitRangeInArray(CStdArray<unsigned char> &aryRawData, long lStartBit, long lBitLength);
201 
202 void STD_UTILS_PORT Std_CopyBinarySection(CStdArray<unsigned char> &aryInData, long lStartInBit,
203  CStdArray<unsigned char> &aryOutData, long lStartOutBit,
204  long lBitLength);
205 
206 bool STD_UTILS_PORT Std_ReadBinaryData(CStdArray<unsigned char> &aryBinaryData, long lLastBit, long &lStartBit, long lBitLength, unsigned char &cOut);
207 bool STD_UTILS_PORT Std_ReadBinaryData(CStdArray<unsigned char> &aryBinaryData, long lLastBit, long &lStartBit, long lBitLength, unsigned short &iOut);
208 bool STD_UTILS_PORT Std_ReadBinaryData(CStdArray<unsigned char> &aryBinaryData, long lLastBit, long &lStartBit, long lBitLength, unsigned long &lOut);
209 
210 void STD_UTILS_PORT Std_WriteBinaryData(CStdArray<unsigned char> &aryBinaryData, long &lStartBit, long lBitLength, unsigned char cIn);
211 void STD_UTILS_PORT Std_WriteBinaryData(CStdArray<unsigned char> &aryBinaryData, long &lStartBit, long lBitLength, unsigned short iIn);
212 void STD_UTILS_PORT Std_WriteBinaryData(CStdArray<unsigned char> &aryBinaryData, long &lStartBit, long lBitLength, unsigned long lIn);
213 
214 unsigned char STD_UTILS_PORT Std_BinaryToGreyCode(unsigned char cVal);
215 unsigned short STD_UTILS_PORT Std_BinaryToGreyCode(unsigned short iVal);
216 unsigned long STD_UTILS_PORT Std_BinaryToGreyCode(unsigned long lVal);
217 
218 unsigned char STD_UTILS_PORT Std_GreyCodeToBinary(unsigned char cVal);
219 unsigned short STD_UTILS_PORT Std_GreyCodeToBinary(unsigned short iVal);
220 unsigned long STD_UTILS_PORT Std_GreyCodeToBinary(unsigned long lVal);
221 
222 // Byte Array Functions
223 //***************************************************************************************************************
224 
225 //***************************************************************************************************************
226 // Logging Functions
227 
228 int STD_UTILS_PORT Std_GetTraceLevel();
229 void STD_UTILS_PORT Std_SetTraceLevel(const int iVal);
230 void STD_UTILS_PORT Std_SetLogLevel(const int iLevel);
231 void STD_UTILS_PORT Std_LogMsg(const int iLevel, std::string strMessage, std::string strSourceFile = "", int iSourceLine = -1, bool bPrintHeader = true);
232 void STD_UTILS_PORT Std_TraceMsg(const int iLevel, std::string strMessage, std::string strSourceFile = "", int iSourceLine = -1, bool bLogToFile = true, bool bPrintHeader = true);
233 void STD_UTILS_PORT Std_ResetLog();
234 
235 #ifndef _WIN32_WCE
236  void STD_UTILS_PORT Std_SetLogFilePrefix(std::string strFilePrefix);
237  std::string STD_UTILS_PORT Std_GetLogFilePrefix();
238  void STD_UTILS_PORT Std_Log(const int nLevel, bool bPrintHeader, LPCTSTR strFormat, ...);
239 #endif
240 
241 #define LOG_MSG(l, m) Std_LogMsg(l, m, __FILE__, __LINE__)
242 #define LOG_ERROR(m) Std_LogMsg(StdLogError, m, __FILE__, __LINE__)
243 
244 //Turn on logging depending on the detail desired.
245 #ifdef STD_TRACING_ON
246  #ifdef STD_TRACE_DETAIL
247  #ifdef _DEBUG
248  #define TRACE_DEBUG_NS(m) Std_TraceMsg(StdLogDebug, m, "", -1, STD_TRACE_TO_FILE, false)
249  #define TRACE_DEBUG(m) Std_TraceMsg(StdLogDebug, m, __FILE__, __LINE__, STD_TRACE_TO_FILE, true)
250  #define TRACE_INFO(m) Std_TraceMsg(StdLogInfo, m, __FILE__, __LINE__, STD_TRACE_TO_FILE, true)
251  #define TRACE_INFO_NS(m) Std_TraceMsg(StdLogInfo, m, "", -1, STD_TRACE_TO_FILE, false)
252  #define TRACE_DETAIL(m) Std_TraceMsg(StdLogDetail, m, __FILE__, __LINE__, STD_TRACE_TO_FILE, true)
253  #define TRACE_DETAIL_NS(m) Std_TraceMsg(StdLogDetail, m, "", -1, STD_TRACE_TO_FILE, false)
254  #else
255  #define TRACE_DEBUG_NS(m) Std_LogMsg(StdLogDebug, m, "", -1, false)
256  #define TRACE_DEBUG(m) Std_LogMsg(StdLogDebug, m, __FILE__, __LINE__, true)
257  #define TRACE_INFO(m) Std_LogMsg(StdLogInfo, m, __FILE__, __LINE__, true)
258  #define TRACE_INFO_NS(m) Std_LogMsg(StdLogInfo, m, "", -1, false)
259  #define TRACE_DETAIL(m) Std_LogMsg(StdLogDetail, m, __FILE__, __LINE__, true)
260  #define TRACE_DETAIL_NS(m) Std_LogMsg(StdLogDetail, m, "", -1, false)
261  #endif
262  #else
263  #ifdef STD_TRACE_INFO
264  #ifdef _DEBUG
265  #define TRACE_DEBUG_NS(m) Std_TraceMsg(StdLogDebug, m, "", -1, STD_TRACE_TO_FILE, false)
266  #define TRACE_DEBUG(m) Std_TraceMsg(StdLogDebug, m, __FILE__, __LINE__, STD_TRACE_TO_FILE, true)
267  #define TRACE_INFO(m) Std_TraceMsg(StdLogInfo, m, __FILE__, __LINE__, STD_TRACE_TO_FILE, true)
268  #define TRACE_INFO_NS(m) Std_TraceMsg(StdLogInfo, m, "", -1, STD_TRACE_TO_FILE, false)
269  #define TRACE_DETAIL(m)
270  #define TRACE_DETAIL_NS(m)
271  #else
272  #define TRACE_DEBUG_NS(m) Std_LogMsg(StdLogDebug, m, "", -1, false)
273  #define TRACE_DEBUG(m) Std_LogMsg(StdLogDebug, m, __FILE__, __LINE__, true)
274  #define TRACE_INFO(m) Std_LogMsg(StdLogInfo, m, __FILE__, __LINE__, true)
275  #define TRACE_INFO_NS(m) Std_LogMsg(StdLogInfo, m, "", -1, false)
276  #define TRACE_DETAIL(m)
277  #define TRACE_DETAIL_NS(m)
278  #endif
279  #else
280  #ifdef STD_TRACE_DEBUG
281  #ifdef _DEBUG
282  #define TRACE_DEBUG_NS(m) Std_TraceMsg(StdLogDebug, m, "", -1, STD_TRACE_TO_FILE, false)
283  #define TRACE_DEBUG(m) Std_TraceMsg(StdLogDebug, m, __FILE__, __LINE__, STD_TRACE_TO_FILE, true)
284  #define TRACE_INFO(m)
285  #define TRACE_INFO_NS(m)
286  #define TRACE_DETAIL(m)
287  #define TRACE_DETAIL_NS(m)
288  #else
289  #define TRACE_DEBUG_NS(m) Std_LogMsg(StdLogDebug, m, "", -1, false)
290  #define TRACE_DEBUG(m) Std_LogMsg(StdLogDebug, m, __FILE__, __LINE__, true)
291  #define TRACE_INFO(m)
292  #define TRACE_INFO_NS(m)
293  #define TRACE_DETAIL(m)
294  #define TRACE_DETAIL_NS(m)
295  #endif
296  #else
297  #define TRACE_DEBUG_NS(m)
298  #define TRACE_DEBUG(m)
299  #define TRACE_INFO(m)
300  #define TRACE_INFO_NS(m)
301  #define TRACE_DETAIL(m)
302  #define TRACE_DETAIL_NS(m)
303  #endif
304  #endif
305  #endif
306 #else
307  #define TRACE_DEBUG_NS(m)
308  #define TRACE_DEBUG(m)
309  #define TRACE_INFO(m)
310  #define TRACE_INFO_NS(m)
311  #define TRACE_DETAIL(m)
312  #define TRACE_DETAIL_NS(m)
313 #endif
314 
315 
316 #ifdef STD_LOG_DB_ON
317  #define LOG_DB(m) Std_LogDBMsg(m, STD_LOG_DB_DSN, STD_LOG_DB_USER, STD_LOG_DB_PSWD)
318 #else
319  #define LOG_DB(m)
320 #endif
321 
322 // Logging Functions
323 //***************************************************************************************************************
324 
325 
326 //***************************************************************************************************************
327 // Timing Functions
328 
329 unsigned long STD_UTILS_PORT Std_GetTick();
330 void STD_UTILS_PORT Std_Sleep(unsigned long lMilliseconds);
331 
332 // Timing Functions
333 //***************************************************************************************************************
334 
335 
336 //***************************************************************************************************************
337 // File Functions
338 
339 bool STD_UTILS_PORT Std_IsFullPath(std::string strPath);
340 void STD_UTILS_PORT Std_SplitPathAndFile(std::string &strFullPath, std::string &strPath, std::string &strFile);
341 bool STD_UTILS_PORT Std_DirectoryExists(std::string strPath);
342 bool STD_UTILS_PORT Std_FileExists(std::string strFullPath);
343 std::string STD_UTILS_PORT Std_ExecutablePath();
344 
345 void STD_UTILS_PORT Std_SetFileTime(std::string strFilename);
346 
347 // File Functions
348 //***************************************************************************************************************
349 
350 //***************************************************************************************************************
351 // Vector Functions
352 
353 typedef float StdVector4[4];
354 typedef float StdVector3[3];
355 
356 #define V3_DIST(a, b) sqrt( pow(a[0]-b[0], 2) + pow(a[1]-b[1], 2) + pow(a[2]-b[2], 2) )
357 #define V4_DIST(a, b) sqrt( pow(a[0]-b[0], 2) + pow(a[1]-b[1], 2) + pow(a[2]-b[2], 2) + pow(a[3]-b[3], 2) )
358 
359 #define V3_MAG(a) sqrt( pow(a[0], 2) + pow(a[1], 2) + pow(a[2], 2) )
360 #define V4_MAG(a) sqrt( pow(a[0], 2) + pow(a[1], 2) + pow(a[2], 2) + pow(a[3], 2) )
361 
362 // Vector Functions
363 //***************************************************************************************************************
364 
365 } //StdUtils
int Std_VariantTypeToConst(std::string strType)
Standard variant type to constant.
void Std_CopyBinarySection(CStdArray< unsigned char > &aryInData, long lStartInBit, CStdArray< unsigned char > &aryOutData, long lStartOutBit, long lBitLength)
Copies a section of a byte array to a new position within the array.
unsigned char Std_BinaryToGreyCode(unsigned char cVal)
Converts a binary value to grey code.
std::string Std_CreateAppID()
Gets the standard create application identifier.
void Std_FlipBitRangeInArray(CStdArray< unsigned char > &aryRawData, long lStartBit, long lBitLength)
Flips all the bits within a section of a byte array.
void Std_SetLogLevel(const int iLevel)
Sets the log level.
std::string Std_Left(std::string strVal, int iCount)
Gets the left portion of a substring.
bool Std_IsNumeric(std::string strVal)
Tests if this string is a number.
void Std_SplitPathAndFile(std::string &strFullPath, std::string &strPath, std::string &strFile)
Splits the path from the actual filename.
void Std_SetBinarySection(CStdArray< unsigned char > &aryRawData, long lStartBit, long lBitLength, unsigned char cIn)
Replaces a section of a byte array with a new byte array.
int Std_Split(const std::string &input, const std::string &delimiter, CStdArray< std::string > &results)
Splits a string into an array of subparts based on a delimiter.
unsigned char Std_HexCharToByte(char cVal)
Converts a hexidecimal number to a byte.
int Std_Sign(float fltVal)
Determines the sign of a number.
bool Std_InValidRange(int iMinVal, int iMaxVal, int iVal, bool bThrowError, std::string strParamName)
Tests whether a number is within a valid range.
std::string Std_ConstToVariantType(int iType)
Standard constant to variant type.
std::string Std_Combine(CStdArray< std::string > &aryParts, std::string strDelimiter)
Combines an array of strings into a single string.
std::string Std_ByteArrayToHexString(CStdArray< unsigned char > &aryBytes)
Converts a byte array to hexadecimal string.
long Std_GetBitSize(CStdArray< unsigned char > &aryRawData)
Gets the number of bits in a byte array.
bool Std_IsAboveMin(int iMinVal, int iVal, bool bThrowError, std::string strParamName, bool bInclusiveLimit)
Tests if a number is above a minimum value.
std::string Std_Trim(std::string strVal)
Trims a string.
bool Std_DirectoryExists(std::string strPath)
Queries if a given directory exists.
void Std_WriteBinaryData(CStdArray< unsigned char > &aryBinaryData, long &lStartBit, long lBitLength, unsigned char cIn)
Writes data to a byte array.
void Std_HexStringToByteArray(std::string strHex, CStdArray< unsigned char > &aryBytes)
Converts a hex string to a byte array.
void Std_SetByteInArray(CStdArray< unsigned char > &aryRawData, unsigned char cIn, long lEndBit, long lBitsNeeded)
Sets a byte within an array.
int Std_IRand(int low, int high)
Generates a random number between two values.
unsigned char Std_GreyCodeToBinary(unsigned char cVal)
Converts a grey code to a binary value.
unsigned long Std_GetTick()
Gets the time tick.
int Std_GetTraceLevel()
Gets the trace level.
std::string Std_GetLogFilePrefix()
Gets the log file prefix.
void Std_ThrowError(long lError, std::string strError, std::string strSourceFile, long lSourceLine, std::string strValueName, unsigned char iVal)
Standard throw error.
unsigned char Std_GetByteFromArray(CStdArray< unsigned char > &aryRawData, long lEndBit, long lBitsNeeded)
Gets a single byte from a byte array.
Namespace for the standard utility objects.
Definition: MarkupSTL.cpp:19
unsigned char Std_HexToByte(std::string strVal)
Converts a hexidecimal number to a byte.
bool Std_ToBool(int iVal)
Converts a value toa bool.
bool Std_IsBelowMax(int iMaxVal, int iVal, bool bThrowError, std::string strParamName, bool bInclusiveLimit)
Tests if a number is below a maximum value.
void Std_SetBitInArray(CStdArray< unsigned char > &aryRawData, long lBit, bool bVal)
Sets a bit within an array.
bool Std_ReadBinaryData(CStdArray< unsigned char > &aryBinaryData, long lLastBit, long &lStartBit, long lBitLength, unsigned char &cOut)
Reads binary data from a byte array.
void Std_TraceMsg(const int iLevel, std::string strMessage, std::string strSourceFile, int iSourceLine, bool bLogToFile, bool bPrintHeader)
Traces a message to the debugger window.
void Std_SRand(unsigned long lSeed)
Sets the seed for generating a random number.
void Std_LogMsg(const int iLevel, std::string strMessage, std::string strSourceFile, int iSourceLine, bool bPrintHeader)
Logs a message,.
double Std_DRand(double low, double high)
Generates a random number between two values.
std::string Std_ToLower(std::string strVal)
Converts a string to lower case.
std::string Std_ExecutablePath()
Finds the name and path of the current executable.
float Std_FRand(float low, float high)
Generates a random number between two values.
bool Std_IsIntegerType(std::string strVal)
Tests if this string is an integer.
void Std_SetBitRangeInArray(CStdArray< unsigned char > &aryRawData, long lStartBit, long lBitLength, bool bVal)
Sets an entire section within a byte array with a bit value.
std::string Std_ToStr(std::string strVal)
Converts a value to a string.
bool Std_IsBlank(std::string strVal)
Trims a string and tests if a string is blank.
bool Std_GetBitFromArray(CStdArray< unsigned char > &aryRawData, long lBit)
Gets a single bit from a byte array.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
void Std_SetTraceLevel(const int iVal)
Sets teh trace level.
bool Std_IsFullPath(std::string strPath)
determines if this is a full path name.
long Std_RGB(unsigned char iRed, unsigned char iGreen, unsigned char iBlue)
Generates a long representation of a color.
void Std_GetBinarySection(CStdArray< unsigned char > &aryRawData, long lStartBit, long lBitLength, unsigned char &cOut)
Gets a section of bits from a byte array.
bool Std_FileExists(std::string strFullPath)
Finds if a given file exists.
std::string Std_TrimRight(std::string strVal)
Standard trim right.
void Std_FlipBitInArray(CStdArray< unsigned char > &aryRawData, long lBit)
Flips a bit within a byte array.
std::string Std_TrimLeft(std::string strVal)
Standard trim left.
void Std_RelayError(CStdErrorInfo oInfo, std::string strSourceFile, long lSourceLine)
Standard relay error.
std::string Std_ToUpper(std::string strVal)
Converts a string to upper case.
void Std_SetLogFilePrefix(std::string strFilePrefix)
Sets the log file prefix.
long Std_LRand(long low, long high)
Generates a random number between two values.
std::string Std_Replace(std::string strVal, std::string strFind, std::string strReplace)
Replaces a substring with another string.
std::string Std_Right(std::string strVal, int iCount)
Gets the right portion of a substring.
std::string Std_NullStr(std::string strFormat)
If string is blank it uses NULL instead.