GCUtilities.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // (c) 2005 by Basler Vision Technologies
3 // Section: Vision Components
4 // Project: GenICam
5 // Author: Fritz Dierks
6 // $Header$
7 // License: This file is published under the license of the EMVA GenICam Standard Group.
8 // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
9 // If for some reason you are missing this file please contact the EMVA or visit the website
10 // (http://www.genicam.org) for a full copy.
11 //
12 // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
13 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
14 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
16 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
19 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22 // POSSIBILITY OF SUCH DAMAGE.
23 //-----------------------------------------------------------------------------
30 #ifndef GENAPI_GENAPIUTILITIES_DEF_H_
31 #define GENAPI_GENAPIUTILITIES_DEF_H_
32 
33 #if defined (_WIN32)
34 # include <windows.h>
35 #endif
36 
37 #include <GenICamVersion.h>
38 
39 #include <Base/GCTypes.h>
40 #include <Base/GCString.h>
41 #include <Base/GCStringVector.h>
42 #include <Base/GCException.h>
43 #include <Base/GCLinkage.h>
44 
45 #if defined(UNDER_RTSS)
46 #include <Base/GCRTSSUtilities.h>
47 #endif // defined(UNDER_RTSS)
48 
49 #if defined(UNDER_RTSS)
50 #define USE_TEMP_CACHE_FILE 0
51 #else
52 #define USE_TEMP_CACHE_FILE 1
53 #endif // defined(UNDER_RTSS)
54 
55 #if defined(UNDER_RTSS)
56 #define USE_TEMP_CACHE_FILE 0
57 #else
58 #define USE_TEMP_CACHE_FILE 1
59 #endif // defined(UNDER_RTSS)
60 
61 #if defined (_MSC_VER)
62 # if defined (_WIN64)
63 # define PLATFORM_NAME "Win64_x64"
64 # else
65 # define PLATFORM_NAME "Win32_i86"
66 # endif
67 #elif defined (__GNUC__)
68 # define GENICAM_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
69 # if defined (__LP64__)
70 # if defined (__linux__)
71 # define PLATFORM_NAME "Linux64_x64"
72 # elif defined (__APPLE__)
73 # define PLATFORM_NAME "Maci64_x64"
74 # else
75 # error Unknown Platform
76 # endif
77 # else
78 # if defined (__linux__)
79 # define PLATFORM_NAME "Linux32_i86"
80 # elif defined (__APPLE__)
81 # error Unsupported Platform
82 # elif defined (VXWORKS)
83 # define PLATFORM_NAME "VxWorks_PPC"
84 # else
85 # error Unknown Platform
86 # endif
87 # endif
88 #else
89 # error Unknown Platform
90 #endif
91 
92 #ifndef GC_COUNTOF
93 # define GC_COUNTOF(arr) (sizeof (arr) / sizeof (arr)[0] )
94 #endif
95 
96 namespace GENICAM_NAMESPACE
97 {
100  template<typename Td, typename Ts>
101  inline Td INTEGRAL_CAST2( Ts s )
102  {
103  const Td d = static_cast<Td>( s );
104  if ( static_cast<Ts>( d ) != s ){
105  throw RUNTIME_EXCEPTION("INTEGRAL_CAST failed");
106  }
107  return d;
108  }
109 
112  template<typename T>
113  inline T INTEGRAL_CAST( int64_t ll )
114  {
115  return INTEGRAL_CAST2<T, int64_t>( ll );
116  }
117 
119  GCBASE_API bool DoesEnvironmentVariableExist( const gcstring &VariableName );
120 
123  GCBASE_API gcstring GetValueOfEnvironmentVariable( const gcstring &VariableName );
124 
127  GCBASE_API bool GetValueOfEnvironmentVariable(const gcstring &VariableName, gcstring &VariableContent );
128 
129 #if defined(UNDER_RTSS)
130  GCBASE_API bool DoesFileExist( const gcstring &FilePath );
132 #endif // defined(UNDER_RTSS)
133 
136  GCBASE_API gcstring UrlEncode(const GENICAM_NAMESPACE::gcstring& Input);
137 
141 
144  GCBASE_API void ReplaceEnvironmentVariables(gcstring &Buffer, bool ReplaceBlankBy20 = false);
145 
146 
148 
153  GCBASE_API gcstring GetGenICamCacheFolder(void);
154 
156 
161  GCBASE_API gcstring GetGenICamLogConfig(void);
162 
164 
169  GCBASE_API gcstring GetGenICamCLProtocolFolder(void);
170 
172  GCBASE_API void SetGenICamCacheFolder(const gcstring& path);
173 
175  GCBASE_API void SetGenICamLogConfig(const gcstring& path);
176 
178  GCBASE_API void SetGenICamCLProtocolFolder(const gcstring& path);
179 
181  GCBASE_API void Tokenize(
182  const gcstring& str,
183  gcstring_vector& tokens,
184  const gcstring& delimiters = " "
185  );
186 
188  GCBASE_API void GetFiles(
189  const gcstring &FileTemplate,
190  gcstring_vector &FileNames,
191  const bool DirectoriesOnly = false );
192 
194  GCBASE_API gcstring GetModulePathFromFunction(void *pFunction);
195 }
196 
197 #define GENICAM_UNUSED(unused_var) ((void)(unused_var))
198 
199 #if !defined(GENICAM_DEPRECATED)
200 # if defined(__GNUC__) && (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 1) // is at least GCC 3.1 compiler?
201 # define GENICAM_DEPRECATED(FUNCTION) FUNCTION __attribute__ ((deprecated))
202 # elif defined(_MSC_VER) && (_MSC_VER >= 1300) // is at least VC 2003 compiler?
203 # define GENICAM_DEPRECATED(FUNCTION) __declspec(deprecated) FUNCTION
204 # else
205 # define GENICAM_DEPRECATED(FUNCTION) FUNCTION
206 # endif // compiler check
207 #endif // #if !defined(GENICAM_DEPRECATED)
208 
209 
211 //
212 // Useful to create pragma message output recognized by VisualStudio
213 //
214 // Usage:
215 // #pragma message ( __ERR__ "Invalid DLL ABI" )
216 //
218 // Message formatter
219 #define _TO_STRING( __stN ) #__stN
220 #define EXPAND_TO_STRINGISE( __stN ) _TO_STRING( __stN )
221 #define __LINE_STR__ EXPAND_TO_STRINGISE(__LINE__)
222 #define __LOCATION__ __FILE__ "(" __LINE_STR__ ")"
223 #define __OUTPUT_FORMATER__(_type) __LOCATION__ " : " _type " : "
224 
225 // Message types
226 #define __WARN__ __OUTPUT_FORMATER__("WARNING")
227 #define __ERR__ __OUTPUT_FORMATER__("ERROR")
228 #define __TODO__ __OUTPUT_FORMATER__("TBD")
229 
230 #endif // GENAPI_GENAPIUTILITIES_DEF_H_
GCBASE_API void SetGenICamLogConfig(const gcstring &path)
Stores the path of the GenICam logging properties file.
GCBASE_API gcstring GetGenICamCacheFolder(void)
Retrieve the path of the GenICam cache folder.
GCBASE_API gcstring GetGenICamCLProtocolFolder(void)
Retrieve the path of the CLProtocol folder.
GCBASE_API GENICAM_NAMESPACE::gcstring UrlDecode(const GENICAM_NAMESPACE::gcstring &Input)
Replaces xx escapes by their char equivalent.
helpers for pragma linkage
Portable string vector implementation.
GCBASE_API gcstring GetGenICamLogConfig(void)
Retrieve the path of the GenICam logging properties file.
__int64 int64_t
Definition: config-win32.h:21
#define RUNTIME_EXCEPTION
Fires a runtime exception, e.g. throw RUNTIME_EXCEPTION("buh!")
Definition: GCException.h:246
GCBASE_API void Tokenize(const gcstring &str, gcstring_vector &tokens, const gcstring &delimiters=" ")
splits str input string into a list of tokens using the delimiter
GCBASE_API void SetGenICamCLProtocolFolder(const gcstring &path)
Stores the path of the CLProtocol folder.
GCBASE_API void GetFiles(const gcstring &FileTemplate, gcstring_vector &FileNames, const bool DirectoriesOnly=false)
Gets a list of files or directories matching a given FileTemplate.
central versioning counters
GCBASE_API gcstring UrlEncode(const GENICAM_NAMESPACE::gcstring &Input)
Converts \ to / and replaces all unsafe characters by their xx equivalent.
GenICam RTSS utilities.
Td INTEGRAL_CAST2(Ts s)
This verifies at runtime if there was no loss of data if an type Ts (e.g.
Definition: GCUtilities.h:101
GCBASE_API gcstring GetValueOfEnvironmentVariable(const gcstring &VariableName)
Retrieve the value of an environment variable.
GCBASE_API void SetGenICamCacheFolder(const gcstring &path)
Stores the path of the GenICam cache folder.
GCBASE_API void ReplaceEnvironmentVariables(gcstring &Buffer, bool ReplaceBlankBy20=false)
Replaces in a string and replace &#39; &#39; with %20.
A string class which is a clone of std::string.
Definition: GCString.h:52
GCBASE_API bool DoesEnvironmentVariableExist(const gcstring &VariableName)
Returns true if an environment variable exists.
T INTEGRAL_CAST(int64_t ll)
This verifies at runtime if there was no loss of data if an int64_t was downcast to type T (e...
Definition: GCUtilities.h:113
Portable string implementation.
GCBASE_API gcstring GetModulePathFromFunction(void *pFunction)
true = only subdirectories (ex . and ..) are retrieved; false = only files are retrieved ...
Platform-dependent type definitions.


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Thu Jun 6 2019 19:10:54