#ifndef _COMMON_INCLUDED_
#define _COMMON_INCLUDED_
#include <algorithm>
#include <cassert>
#ifdef _MSC_VER
#include <cfloat>
#else
#include <cmath>
#endif
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <list>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#if defined(__ANDROID__)
#include <sstream>
namespace std {
template<typename T>
std::string to_string(const T& val) {
std::ostringstream os;
os << val;
return os.str();
}
}
#endif
#if defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API
#include <basetsd.h>
#ifndef snprintf
#define snprintf …
#endif
#define safe_vsprintf …
#elif defined (solaris)
#define safe_vsprintf …
#include <sys/int_types.h>
#define UINT_PTR …
#else
#define safe_vsprintf(buf,max,format,args) …
#include <stdint.h>
#define UINT_PTR …
#endif
#if defined(_MSC_VER)
#define strdup …
#endif
#ifdef _MSC_VER
#pragma warning(disable : 4786)
#pragma warning(disable : 4514)
#pragma warning(disable : 4201)
#endif
#include "PoolAlloc.h"
#define POOL_ALLOCATOR_NEW_DELETE(A) …
namespace glslang {
TStringAllocator;
TString;
}
namespace std {
template<> struct hash<glslang::TString> { … };
}
namespace glslang {
inline TString* NewPoolTString(const char* s)
{ … }
template<class T> inline T* NewPoolObject(T*)
{ … }
template<class T> inline T* NewPoolObject(T, int instances)
{ … }
inline bool StartsWith(TString const &str, const char *prefix)
{ … }
template <class T> class TVector : public std::vector<T, pool_allocator<T> > { … };
template <class T> class TList : public std::list<T, pool_allocator<T> > { … };
template <class K, class D, class CMP = std::less<K> >
class TMap : public std::map<K, D, CMP, pool_allocator<std::pair<K const, D> > > { … };
template <class K, class D, class HASH = std::hash<K>, class PRED = std::equal_to<K> >
class TUnorderedMap : public std::unordered_map<K, D, HASH, PRED, pool_allocator<std::pair<K const, D> > > { … };
template <class K, class CMP = std::less<K> >
class TSet : public std::set<K, CMP, pool_allocator<K> > { … };
TPersistString;
template <class T> T Min(const T a, const T b) { … }
template <class T> T Max(const T a, const T b) { … }
#if defined(_MSC_VER) || (defined(MINGW_HAS_SECURE_API) && MINGW_HAS_SECURE_API)
inline const TString String(const int i, const int base = 10)
{
char text[16];
_itoa_s(i, text, sizeof(text), base);
return text;
}
#else
inline const TString String(const int i, const int = 10)
{ … }
#endif
struct TSourceLoc { … };
class TPragmaTable : public TMap<TString, TString> { … };
const int MaxTokenLength = …;
template <class T> bool IsPow2(T powerOf2)
{ … }
template <class T> void RoundToPow2(T& number, int powerOf2)
{ … }
template <class T> bool IsMultipleOfPow2(T number, int powerOf2)
{ … }
template <class T> int IntLog2(T n)
{ … }
}
#endif