Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
CoreMacros.h
Go to the documentation of this file.
1 
12 #ifndef __KOME_CORE_MACROS_H__
13 #define __KOME_CORE_MACROS_H__
14 
15 
17 #ifndef NULL
18  #define NULL 0
19 #endif
20 
21 
22 //
23 // Numerical
24 //
25 
27 #define MAX( x, y ) ( ( ( x ) < ( y ) ) ? ( y ) : ( x ) )
28 
30 #define MIN( x, y ) ( ( ( x ) > ( y ) ) ? ( y ) : ( x ) )
31 
35 #define CLAMP( x, low, high ) MIN( high, MAX( x, low ) )
36 
38 #define ABS( v ) ( ( v ) < 0 ? - ( v ) : ( v ) )
39 
40 #define RANGE( x, y ) ( ( ( x ) < ( y ) ) ? ( y - x ) : ( x - y ) )
41 
42 
43 //
44 // bit
45 //
46 
48 #define CIRCULAR_LEFT_SHIFT( v, bits ) ( ( ( v ) << ( bits ) ) | ( ( v ) >> ( ( sizeof( v ) * 8 ) - ( bits ) ) ) )
49 
51 #define CIRCULAR_RIGHT_SHIFT( v, bits ) ( ( ( v ) >> ( bits ) ) | ( ( v ) << ( ( sizeof( v ) * 8 ) - ( bits ) ) ) )
52 
53 //
54 // File System
55 //
56 
57 #ifdef __unix
58 
60  #define DIR_SEPARATOR "/"
61 
63  #define DIR_SEPARATOR_CHAR '/'
64 
66  #define PATH_SEPARATOR ":"
67 
69  #define PATH_SEPARATOR_CHAR ':'
70 
72  #define NEW_LINE "\n"
73 
74 #else
75 
77  #define DIR_SEPARATOR "\\"
78 
80  #define DIR_SEPARATOR_CHAR '\\'
81 
83  #define PATH_SEPARATOR ";"
84 
86  #define PATH_SEPARATOR_CHAR ';'
87 
89  #define NEW_LINE "\r\n"
90 
91 #endif // __unix
92 
93 
94 //
95 // Others
96 //
97 
99 #define NVL( checkVal, replaceVal ) ( ( ( checkVal ) == NULL ) ? ( replaceVal ) : ( checkVal ) )
100 
101 
102 
103 #endif // __KOME_CORE_MACROS_H__