37 #ifndef _COMMON_INCLUDED_ 38 #define _COMMON_INCLUDED_ 41 #if defined(__ANDROID__) || _MSC_VER < 1700 46 std::ostringstream os;
53 #if (defined(_MSC_VER) && _MSC_VER < 1900 ) || defined MINGW_HAS_SECURE_API 56 #define snprintf sprintf_s 58 #define safe_vsprintf(buf,max,format,args) vsnprintf_s((buf), (max), (max), (format), (args)) 59 #elif defined (solaris) 60 #define safe_vsprintf(buf,max,format,args) vsnprintf((buf), (max), (format), (args)) 61 #include <sys/int_types.h> 62 #define UINT_PTR uintptr_t 64 #define safe_vsprintf(buf,max,format,args) vsnprintf((buf), (max), (format), (args)) 66 #define UINT_PTR uintptr_t 69 #if defined(_MSC_VER) && _MSC_VER < 1800 71 inline long long int strtoll (
const char*
str,
char** endptr,
int base)
73 return _strtoi64(
str, endptr, base);
75 inline unsigned long long int strtoull (
const char*
str,
char** endptr,
int base)
77 return _strtoui64(
str, endptr, base);
79 inline long long int atoll (
const char*
str)
86 #define strdup _strdup 91 #pragma warning(disable : 4786) // Don't warn about too long identifiers 92 #pragma warning(disable : 4514) // unused inline method 93 #pragma warning(disable : 4201) // nameless union 97 #include <unordered_set> 100 #include <unordered_map> 112 #define POOL_ALLOCATOR_NEW_DELETE(A) \ 113 void* operator new(size_t s) { return (A).allocate(s); } \ 114 void* operator new(size_t, void *_Where) { return (_Where); } \ 115 void operator delete(void*) { } \ 116 void operator delete(void *, void *) { } \ 117 void* operator new[](size_t s) { return (A).allocate(s); } \ 118 void* operator new[](size_t, void *_Where) { return (_Where); } \ 119 void operator delete[](void*) { } \ 120 void operator delete[](void *, void *) { } 138 const unsigned _FNV_offset_basis = 2166136261U;
139 const unsigned _FNV_prime = 16777619U;
140 unsigned _Val = _FNV_offset_basis;
141 size_t _Count =
s.size();
142 const char* _First =
s.c_str();
143 for (
size_t _Next = 0; _Next < _Count; ++_Next)
145 _Val ^= (unsigned)_First[_Next];
175 template <
class T>
class TVector :
public std::vector<T, pool_allocator<T> > {
186 template <
class T>
class TList :
public std::list<T, pool_allocator<T> > {
189 template <
class K,
class D,
class CMP = std::less<K> >
190 class TMap :
public std::map<K, D, CMP, pool_allocator<std::pair<K const, D> > > {
193 template <
class K,
class D,
class HASH = std::hash<K>,
class PRED = std::equal_to<K> >
194 class TUnorderedMap :
public std::unordered_map<K, D, HASH, PRED, pool_allocator<std::pair<K const, D> > > {
206 template <
class T>
T Min(
const T a,
const T b) {
return a <
b ?
a :
b; }
207 template <
class T>
T Max(
const T a,
const T b) {
return a >
b ?
a :
b; }
212 #if defined _MSC_VER || defined MINGW_HAS_SECURE_API 213 inline const TString String(
const int i,
const int base = 10)
216 _itoa_s(i, text,
sizeof(text), base);
225 snprintf(text,
sizeof(text),
"%d", i);
233 void init(
int stringNum) {
init();
string = stringNum; }
259 return (powerOf2 & (powerOf2 - 1)) == 0;
273 return ! (
number & (powerOf2 - 1));
278 #endif // _COMMON_INCLUDED_
static char * number(char *str, long num, int base, int size, int precision, int type)
Definition: kprintf.c:42
GLuint const GLchar * name
Definition: glext.h:6671
GLuint GLfloat * val
Definition: glext.h:7847
std::string getStringNameOrNum(bool quoteStringName=true) const
Definition: Common.h:235
std::string to_string(const T &val)
Definition: Common.h:45
TVector(size_type i, const T &val)
Definition: Common.h:183
int line
Definition: Common.h:243
bool IsMultipleOfPow2(T number, int powerOf2)
Definition: Common.h:270
TString * NewPoolTString(const char *s)
Definition: Common.h:156
GLdouble s
Definition: glext.h:6390
Definition: PoolAlloc.h:264
GLsizei const GLchar *const * string
Definition: glext.h:6699
std::basic_string< char > TPersistString
Definition: Common.h:201
std::vector< const TString *, pool_allocator< const TString * > >::size_type size_type
Definition: Common.h:179
T * NewPoolObject(T *)
Definition: Common.h:162
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
unsigned long long strtoull(const char *__restrict nptr, char **__restrict endptr, int base)
Definition: compat_ctype.c:366
TPoolAllocator & GetThreadPoolAllocator()
Definition: PoolAlloc.cpp:47
#define NULL
Pointer to 0.
Definition: gctypes.h:65
std::size_t operator()(const glslang::TString &s) const
Definition: Common.h:136
const int MaxTokenLength
Definition: Common.h:252
const char * name
Definition: Common.h:241
#define POOL_ALLOCATOR_NEW_DELETE(A)
Definition: Common.h:112
TVector(size_type i)
Definition: Common.h:182
pool_allocator< char > TStringAllocator
Definition: Common.h:127
GLenum GLenum GLvoid GLvoid * column
Definition: glext.h:6316
void init(int stringNum)
Definition: Common.h:233
T Max(const T a, const T b)
Definition: Common.h:207
bool IsPow2(T powerOf2)
Definition: Common.h:254
std::basic_string< char, std::char_traits< char >, TStringAllocator > TString
Definition: Common.h:128
TVector(const pool_allocator< T > &a)
Definition: Common.h:181
void RoundToPow2(T &number, int powerOf2)
Definition: Common.h:264
const TString String(const int i, const int=10)
Definition: Common.h:220
int column
Definition: Common.h:244
Definition: lobject.h:303
const char *const str
Definition: portlistingparse.c:18
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6844
T Min(const T a, const T b)
Definition: Common.h:206
void * allocate(size_t numBytes)
Definition: PoolAlloc.cpp:233
void init()
Definition: Common.h:232
int string
Definition: Common.h:242