EpcTools
An event based multi-threaded C++ development framework.
etypes.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2009-2019 Brian Waters
3 * Copyright (c) 2019 Sprint
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 
18 #ifndef __etypes_h_included
19 #define __etypes_h_included
20 
21 #include <utility>
22 #include <string>
23 
27 
28 // basic data types
29 #include <stdint.h>
30 typedef void Void;
31 typedef bool Bool;
32 typedef char Char;
33 typedef unsigned char UChar;
34 typedef UChar Byte;
35 typedef int16_t Short;
36 typedef uint16_t UShort;
37 typedef int32_t Int;
38 typedef uint32_t UInt;
39 typedef int32_t Long;
40 typedef uint32_t ULong;
41 typedef ULong Dword;
42 typedef int64_t LongLong;
43 typedef uint64_t ULongLong;
44 typedef float Float;
45 typedef double Double;
46 
47 // constants
48 typedef const Bool cBool;
49 typedef const Char cChar;
50 typedef const UChar cUChar;
51 typedef const Short cShort;
52 typedef const UShort cUShort;
53 typedef const Int cInt;
54 typedef const UInt cUInt;
55 typedef const Long cLong;
56 typedef const ULong cULong;
57 typedef const Dword cDword;
58 typedef const LongLong cLongLong;
59 typedef const ULongLong cULongLong;
60 typedef const Float cFloat;
61 typedef const Double cDouble;
62 
63 // basic pointers
64 typedef Void *pVoid;
65 typedef Bool *pBool;
66 typedef Char *pChar;
67 typedef pChar pStr;
68 typedef UChar *pUChar;
69 typedef Short *pShort;
70 typedef UShort *pUShort;
71 typedef Int *pInt;
72 typedef UInt *pUInt;
73 typedef Long *pLong;
74 typedef ULong *pULong;
75 typedef Dword *pDword;
76 typedef LongLong *pLongLong;
77 typedef ULongLong *pULongLong;
78 typedef Float *pFloat;
79 typedef Double *pDouble;
80 
81 // const pointers
82 typedef const pVoid cpVoid;
83 typedef const pBool cpBool;
84 typedef const Char *cpChar;
85 typedef const Char *cpStr;
86 typedef const UChar *cpUChar;
87 typedef const pShort cpShort;
88 typedef const pUShort cpUShort;
89 typedef const pInt cpInt;
90 typedef const pUInt cpUInt;
91 typedef const pLong cpLong;
92 typedef const pULong cpULong;
93 typedef const pDword cpDword;
94 typedef const pLongLong cpLongLong;
95 typedef const pULongLong cpULongLong;
96 typedef const pFloat cpFloat;
97 typedef const pDouble cpDouble;
98 
99 typedef union {
100  struct
101  {
102  Dword lowPart;
103  Long highPart;
104  } li;
105  LongLong quadPart;
106 } longinteger_t;
107 
108 typedef union {
109  struct
110  {
111  Dword lowPart;
112  Dword highPart;
113  } uli;
114  ULongLong quadPart;
115 } ulonginteger_t;
116 
117 #if __cplusplus == 201103
118 namespace std {
119  template<typename T, typename U=T>
120  T exchange(T& obj, U&& new_value)
121  {
122  T old_value(std::move(obj));
123  obj = std::forward<T>(new_value);
124  return old_value;
125  }
126 }
127 #endif
128 
129 inline std::string methodName(const std::string& prettyFunction)
130 {
131  size_t colons = prettyFunction.find("::");
132  size_t begin = prettyFunction.substr(0,colons).rfind(" ") + 1;
133  size_t end = prettyFunction.rfind("(") - begin;
134  return prettyFunction.substr(begin,end) + "()";
135 }
136 
137 #define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)
138 
139 inline std::string className(const std::string& prettyFunction)
140 {
141  size_t colons = prettyFunction.rfind("::");
142  if (colons == std::string::npos)
143  return "::";
144  size_t begin = prettyFunction.substr(0,colons).rfind(" ") + 1;
145  size_t end = colons - begin;
146  return prettyFunction.substr(begin,end);
147 }
148 
149 #define __CLASS_NAME__ className(__PRETTY_FUNCTION__)
150 
151 
153 
154 #endif // #define __etypes_h_included
STL namespace.