init
This commit is contained in:
13
sdk/public/Define.h
Normal file
13
sdk/public/Define.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef ___define_H___
|
||||
#define ___define_H___
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
#include <sys/types.h>
|
||||
typedef size_t SIZE_T;
|
||||
|
||||
|
||||
|
||||
//数组维数
|
||||
#define CountArray(Array) (sizeof(Array)/sizeof(Array[0]))
|
||||
|
||||
#endif // _types_H_
|
||||
26
sdk/public/Struct.h
Normal file
26
sdk/public/Struct.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef STRUCT_HEAD_FILE
|
||||
#define STRUCT_HEAD_FILE
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//游戏列表
|
||||
#pragma pack(1)
|
||||
|
||||
|
||||
struct systemtime {
|
||||
word wYear;
|
||||
word wMonth;
|
||||
word wDayOfWeek;
|
||||
word wDay;
|
||||
word wHour;
|
||||
word wMinute;
|
||||
word wSecond;
|
||||
word wMilliseconds;
|
||||
};
|
||||
|
||||
#define PROPERTY_COUNT (sizeof(g_PropTypeList)/sizeof(g_PropTypeList[0]))//道具数目
|
||||
|
||||
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#endif
|
||||
94
sdk/public/_ast.h
Normal file
94
sdk/public/_ast.h
Normal file
@@ -0,0 +1,94 @@
|
||||
#ifndef _MDBG_H_
|
||||
#define _MDBG_H_
|
||||
|
||||
/* 定义Win32应用程序的Assert宏 */
|
||||
|
||||
|
||||
|
||||
#include "_osdef.h"
|
||||
#ifdef Assert
|
||||
#undef Assert
|
||||
#endif
|
||||
|
||||
// #ifdef WIN32
|
||||
#ifdef _DEBUG
|
||||
|
||||
#include <assert.h>
|
||||
#define Assert(exp) (exp)
|
||||
#define DbgAssert(exp)
|
||||
#else
|
||||
#define Assert(exp) (exp)
|
||||
#define DbgAssert(exp) //什么都不做
|
||||
#endif
|
||||
// #else
|
||||
// #define Assert(exp) (exp)
|
||||
// #define DbgAssert(exp) //什么都不做
|
||||
// #endif // --> #ifndef Assert
|
||||
|
||||
|
||||
/* 定义Win32应用程序的TRACE宏 */
|
||||
#ifndef WIN32
|
||||
#define TRACE(...) OutputMsg(rmTip, __VA_ARGS__)
|
||||
//#define TRACE
|
||||
#else
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include <stdarg.h>
|
||||
#include <tchar.h>
|
||||
#define TRACE _mdbgOutputDbgStr
|
||||
static void _mdbgOutputDbgStr(LPCTSTR szFormat, ...)
|
||||
{
|
||||
static TCHAR szStaticBuf[4096];
|
||||
|
||||
va_list args;
|
||||
va_start( args, szFormat );
|
||||
_vstprintf( szStaticBuf, szFormat, args );
|
||||
va_end (args );
|
||||
|
||||
OutputDebugString( szStaticBuf );
|
||||
}
|
||||
#else
|
||||
#define TRACE
|
||||
#endif
|
||||
|
||||
#endif // --> #ifndef TRACE
|
||||
|
||||
|
||||
/* 定义当前文件以及行的字符串获取的宏(获取的字符串形如:abc.cpp(2000)) */
|
||||
#ifndef __FILE_LINE__
|
||||
|
||||
|
||||
#define _TLN(LN) #LN
|
||||
#define __TLINE__(LN) _TLN(LN)
|
||||
#define __FILE_LINE__ __FILE__"("__TLINE__(__LINE__)")"
|
||||
|
||||
#endif // --> #ifndef __FILE_LINE__
|
||||
|
||||
/* 定义在编译器输出窗口输出内容的宏,但内容中会自动增加文件以及行号并在双击输出窗口后可以直接定位到消息所在行 */
|
||||
#ifndef __CPMSG__
|
||||
|
||||
#define __CPMSG__(MSG) message( __FILE_LINE__ " : " #MSG )
|
||||
|
||||
#endif // --> ifndef __CPMSG__
|
||||
|
||||
|
||||
/* 定义SafeDelete、SafeDeleteArray、SafeFree以及SafeRelease宏 */
|
||||
#ifndef SafeDelete
|
||||
#define SafeDelete(p) if (p) { delete p; p = NULL; }
|
||||
#endif
|
||||
|
||||
#ifndef SafeDeleteArray
|
||||
#define SafeDeleteArray(p) if (p) { delete [] p; p = NULL; }
|
||||
#endif
|
||||
|
||||
#ifndef SafeFree
|
||||
#define SafeFree(p) if (p) { free(p); p = NULL; }
|
||||
#endif
|
||||
|
||||
#ifndef SafeRelease
|
||||
#define SafeRelease(p) if (p){ p->Release(); p = NULL; }
|
||||
#endif
|
||||
|
||||
#define ArrayCount(a) (sizeof(a) / sizeof((a)[0]))
|
||||
|
||||
#endif
|
||||
21
sdk/public/_memchk.h
Normal file
21
sdk/public/_memchk.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef _MEMLEAK_H_
|
||||
#define _MEMLEAK_H_
|
||||
|
||||
#ifdef _MLIB_DUMP_MEMORY_LEAKS_
|
||||
|
||||
#include <malloc.h>
|
||||
#include <string>
|
||||
|
||||
#define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#ifdef WIN32
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
//解决placement new与内存检查机制冲突的问题
|
||||
#ifndef __PLACEMENT_NEW_INLINE
|
||||
#define new DEBUG_CLIENTBLOCK
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
476
sdk/public/_osdef.h
Normal file
476
sdk/public/_osdef.h
Normal file
@@ -0,0 +1,476 @@
|
||||
#ifndef _WYL_OS___DEFINITION_H_
|
||||
#define _WYL_OS___DEFINITION_H_
|
||||
|
||||
/* 去掉MFC的定义
|
||||
#ifdef _WIN32_WINNT
|
||||
#if (_WIN32_WINNT < 0x0400)
|
||||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0400
|
||||
#endif //
|
||||
#else
|
||||
#define _WIN32_WINNT 0x0400
|
||||
#endif
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#ifndef CONFIG_USE_WIN_SOCKET
|
||||
#define CONFIG_USE_WIN_SOCKET
|
||||
#endif
|
||||
|
||||
typedef __int64 int64;
|
||||
typedef __int32 int32;
|
||||
typedef __int16 int16;
|
||||
typedef __int8 int8;
|
||||
typedef unsigned __int64 uint64;
|
||||
typedef unsigned __int32 uint32;
|
||||
typedef unsigned __int16 uint16;
|
||||
typedef unsigned __int8 uint8;
|
||||
#include <windows.h>
|
||||
|
||||
#ifndef STDCALL
|
||||
#define STDCALL __stdcall
|
||||
#endif
|
||||
|
||||
|
||||
#define PTHREADRET void
|
||||
|
||||
#define I64FORMAT "%I64d"
|
||||
#define U64FORMAT "%I64u"
|
||||
#else
|
||||
#ifndef _MTICK64
|
||||
#define _MTICK64
|
||||
#endif
|
||||
|
||||
#ifndef TOLUA_RELEASE
|
||||
#define TOLUA_RELEASE
|
||||
#endif
|
||||
|
||||
#ifndef _ENABLE_OBJ_COUNT_STATICS_
|
||||
#define _ENABLE_OBJ_COUNT_STATICS_
|
||||
#endif
|
||||
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/socket.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <sched.h>
|
||||
#include <termios.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
//#include <system.h>
|
||||
|
||||
#ifndef CONFIG_USE_LINUX_SOCKET
|
||||
#define CONFIG_USE_LINUX_SOCKET
|
||||
#endif
|
||||
|
||||
#ifndef __max
|
||||
#define __max(x,y) ((x) < (y) ? (y):(x))
|
||||
#endif
|
||||
|
||||
#ifndef __min
|
||||
#define __min(x,y) ((x) < (y) ? (x):(y))
|
||||
#endif
|
||||
|
||||
#ifndef _tcslen
|
||||
#define _tcslen strlen
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef _stprintf
|
||||
#define _stprintf sprintf
|
||||
#endif
|
||||
|
||||
#ifndef sprintf_s
|
||||
#define sprintf_s snprintf
|
||||
#endif
|
||||
|
||||
#ifndef _tcscpy
|
||||
#define _tcscpy strcpy
|
||||
#endif
|
||||
|
||||
#define OutputDebugString(s) fprintf( stderr, "%s", s)
|
||||
|
||||
#define SetConsoleTitle(input) printf( "%c]0;%s%c", '\033', input, '\007');
|
||||
|
||||
|
||||
#ifndef _stprintf_s
|
||||
#define _stprintf_s sprintf
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef _tcscpy_s
|
||||
#define _tcscpy_s strcpy
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#ifndef uint64_t
|
||||
#ifdef __linux__
|
||||
#include <linux/types.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define CoInitialize(x);
|
||||
|
||||
#define CoUninitialize(x);
|
||||
|
||||
//#define UninitDefMsgOut(x);
|
||||
#define _setmbcp(x);
|
||||
|
||||
|
||||
typedef int64_t int64;
|
||||
typedef int32_t int32;
|
||||
typedef int16_t int16;
|
||||
typedef int8_t int8;
|
||||
typedef uint64_t uint64;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint8_t uint8;
|
||||
|
||||
//typedef int64 __int64 ;
|
||||
typedef int32 __int32 ;
|
||||
typedef int16 __int16 ;
|
||||
typedef int8 __int8 ;
|
||||
|
||||
typedef void *HANDLE;
|
||||
typedef HANDLE *PHANDLE;
|
||||
|
||||
//#undef FAR
|
||||
#undef NEAR
|
||||
//#define FAR far
|
||||
#define NEAR near
|
||||
#ifndef CONST
|
||||
#define CONST const
|
||||
#endif
|
||||
#define VOID void
|
||||
|
||||
#ifndef IN
|
||||
#define IN
|
||||
#endif
|
||||
|
||||
#ifndef OUT
|
||||
#define OUT
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#define INFINITE 0xFFFFFFFF
|
||||
|
||||
// cross platform for wylib
|
||||
typedef unsigned int DWORD;
|
||||
typedef int BOOL;
|
||||
typedef unsigned char BYTE;
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short WORD;
|
||||
typedef float FLOAT;
|
||||
typedef FLOAT *PFLOAT;
|
||||
typedef BOOL *PBOOL;
|
||||
typedef BOOL *LPBOOL;
|
||||
typedef BYTE *PBYTE;
|
||||
typedef BYTE *LPBYTE;
|
||||
typedef int *PINT;
|
||||
typedef int *LPINT;
|
||||
typedef WORD *PWORD;
|
||||
typedef WORD *LPWORD;
|
||||
typedef long *LPLONG;
|
||||
typedef DWORD *PDWORD;
|
||||
typedef DWORD *LPDWORD;
|
||||
typedef DWORD *DWORD_PTR;
|
||||
typedef DWORD COLORREF;
|
||||
typedef void *LPVOID;
|
||||
typedef CONST BYTE *LPCBYTE;
|
||||
typedef CONST void *LPCVOID;
|
||||
typedef void *PVOID;
|
||||
|
||||
typedef char CHAR;
|
||||
typedef signed char INT8;
|
||||
typedef unsigned char UCHAR;
|
||||
typedef unsigned char UINT8;
|
||||
typedef unsigned char BYTE;
|
||||
typedef short SHORT;
|
||||
typedef signed short INT16;
|
||||
typedef unsigned short USHORT;
|
||||
typedef unsigned short UINT16;
|
||||
typedef unsigned short WORD;
|
||||
typedef int INT;
|
||||
typedef signed int INT32;
|
||||
typedef unsigned int UINT;
|
||||
typedef unsigned int UINT32;
|
||||
typedef long long LONG;
|
||||
typedef unsigned long long ULONG;
|
||||
|
||||
|
||||
typedef int64_t LONGLONG;
|
||||
typedef int64_t LONG64;
|
||||
typedef int64_t INT64;
|
||||
typedef uint64_t ULONGLONG;
|
||||
typedef uint64_t DWORDLONG;
|
||||
typedef uint64_t ULONG64;
|
||||
typedef uint64_t DWORD64;
|
||||
typedef uint64_t UINT64;
|
||||
|
||||
|
||||
typedef int64_t LONG_PTR;
|
||||
typedef uint64_t ULONG_PTR;
|
||||
typedef unsigned int *PUINT;
|
||||
|
||||
typedef double DOUBLE;
|
||||
|
||||
typedef long long * PINT64;
|
||||
typedef CHAR * LPSTR ;
|
||||
typedef long long __int64 ;
|
||||
|
||||
typedef ULONGLONG * PULONGLONG;
|
||||
|
||||
typedef struct _POINTL
|
||||
{
|
||||
DWORD x;
|
||||
DWORD y;
|
||||
} POINT, *PPOINT, *NPPOINT, *LPPOINT;
|
||||
|
||||
//#define _ENABLE_OBJ_COUNT_STATICS_ 1
|
||||
|
||||
#define GetLastError() errno
|
||||
#define WSAGetLastError() errno
|
||||
|
||||
typedef uint64_t UINT_PTR, *PUINT_PTR;
|
||||
typedef int64_t INT_PTR, *PINT_PTR;
|
||||
|
||||
|
||||
#ifdef __x86_64__
|
||||
//typedef int64_t INT_PTR, *PINT_PTR;
|
||||
|
||||
//#define offsetof(s,m) (size_t)( (ptrdiff_t)&reinterpret_cast<const volatile char&>((((s *)0)->m)) )
|
||||
#elif __i386__
|
||||
//#define offsetof(s,m) (size_t)&reinterpret_cast<const volatile char&>((((s *)0)->m))
|
||||
//typedef int INT_PTR, *PINT_PTR;
|
||||
//typedef unsigned int UINT_PTR, *PUINT_PTR;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef UNICODE
|
||||
typedef wchar_t TCHAR ;
|
||||
#define _vsntprintf vswprintf
|
||||
//#define wstrchr _tcschr;
|
||||
#else
|
||||
typedef char* LPTSTR;
|
||||
typedef CONST CHAR *LPCSTR, *PCSTR;
|
||||
typedef LPCSTR LPCTSTR;
|
||||
|
||||
typedef char TCHAR ;
|
||||
#define _vsntprintf vsnprintf
|
||||
#define _tcscmp strcmp
|
||||
#define _tcschr strchr
|
||||
#define _tcsncmp strncmp
|
||||
#define _tcscat strcat
|
||||
#define _tcscpy strcpy
|
||||
#define _stscanf sscanf
|
||||
#define _tcsncpy strncpy
|
||||
#define _tcsnicmp strncasecmp
|
||||
#define _tcsncicmp strncasecmp
|
||||
#define _tcsicmp strcasecmp
|
||||
#define _stricmp strcasecmp
|
||||
#define _tcsstr strstr
|
||||
//#define strchr _tcschr;
|
||||
#endif
|
||||
|
||||
#define ExitThread pthread_exit
|
||||
#define __forceinline inline
|
||||
|
||||
#include<time.h>
|
||||
#ifdef __x86_64__
|
||||
#define __time64_t time_t
|
||||
#else
|
||||
#define __time32_t time_t
|
||||
#endif
|
||||
|
||||
#ifdef __x86_64__
|
||||
#define _mktime64 mktime
|
||||
#else
|
||||
#define _mktime32 mktime
|
||||
#endif
|
||||
|
||||
#ifdef __x86_64__
|
||||
#define _localtime64 localtime_r
|
||||
#else
|
||||
#define _localtime32 localtime_r
|
||||
#endif
|
||||
|
||||
#define LOBYTE(w) ((BYTE)(((DWORD)(w)) & 0xff))
|
||||
#define HIBYTE(w) ((BYTE)((((DWORD)(w)) >> 8) & 0xff))
|
||||
#define HIWORD(l) ((WORD)((((DWORD)(l)) >> 16) & 0xffff))
|
||||
#define LOWORD(l) ((WORD)(((DWORD)(l)) & 0xffff))
|
||||
#define MAKELONG(a, b) ((LONG)(((WORD)(((DWORD)(a)) & 0xffff)) | ((DWORD)((WORD)(((DWORD)(b)) & 0xffff))) << 16))
|
||||
#define MAKEWORD(a, b) ((WORD)(((BYTE)(((DWORD)(a)) & 0xff)) | ((WORD)((BYTE)(((DWORD)(b)) & 0xff))) << 8))
|
||||
|
||||
#define ULONG64 UINT64
|
||||
#define LONG64 INT64
|
||||
|
||||
#define MAXULONG64 ((ULONG64)~((ULONG64)0))
|
||||
#define MAXLONG64 ((LONG64)(MAXULONG64 >> 1))
|
||||
#define MINLONG64 ((LONG64)~MAXLONG64)
|
||||
|
||||
#define MAXUINT ((UINT)~((UINT)0))
|
||||
#define MAXINT ((INT)(MAXUINT >> 1))
|
||||
#define MININT ((INT)~MAXINT)
|
||||
|
||||
#define MAXBYTE 0xff
|
||||
|
||||
#ifndef STDCALL
|
||||
#define STDCALL
|
||||
#endif
|
||||
|
||||
#ifndef WINAPI
|
||||
#define WINAPI
|
||||
#endif
|
||||
|
||||
#define _T(x) x
|
||||
|
||||
#define ZeroMemory(Destination,Length) memset((Destination),0,(Length))
|
||||
|
||||
#define _tcsftime strftime
|
||||
#define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
#define CHAR_BIT 8
|
||||
#endif
|
||||
|
||||
#define _tprintf printf
|
||||
#define _sntprintf snprintf
|
||||
#define _snprintf snprintf
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 260
|
||||
#endif
|
||||
|
||||
#define InterlockedIncrement(x) __sync_add_and_fetch((x),1)
|
||||
#define InterlockedDecrement(x) __sync_sub_and_fetch((x),1)
|
||||
|
||||
#define InterlockedCompareExchange(x, y,z) __sync_val_compare_and_swap((x),(z),(y))
|
||||
#define InterlockedExchange(x, y) __sync_lock_test_and_set((x), (y))
|
||||
|
||||
#define InterlockedExchangeAdd(x,y) __sync_add_and_fetch((x),(y))
|
||||
|
||||
typedef unsigned int (*PTHREAD_START_ROUTINE )(void * lpThreadParameter );
|
||||
typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
|
||||
|
||||
|
||||
#define __try try
|
||||
#define __catch catch
|
||||
#define __finally finally
|
||||
|
||||
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||
((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \
|
||||
((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))
|
||||
|
||||
#define PTHREADRET void*
|
||||
|
||||
//Some Api From
|
||||
|
||||
|
||||
#define INVALID_HANDLE_VALUE ((long)-1)
|
||||
|
||||
#define CopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length))
|
||||
#define IsDebuggerPresent(x) 0
|
||||
#define DebugBreak(x)
|
||||
#define GetCurrentThreadId() syscall(SYS_gettid)
|
||||
#define _atoi64(v) strtoll(v, NULL, 10)
|
||||
#define _getts gets
|
||||
|
||||
typedef CHAR* PCHAR;
|
||||
|
||||
#ifndef INT_MAX
|
||||
#define INT_MAX 2147483647 /* maximum (signed) int value */
|
||||
#endif
|
||||
|
||||
#define SetCurrentDirectory chdir
|
||||
#define DeleteFileA remove
|
||||
|
||||
#define DUMMYSTRUCTNAME
|
||||
#if defined(MIDL_PASS)
|
||||
typedef struct _LARGE_INTEGER
|
||||
{
|
||||
#else // MIDL_PASS
|
||||
typedef union _LARGE_INTEGER
|
||||
{
|
||||
struct
|
||||
{
|
||||
DWORD LowPart;
|
||||
DWORD HighPart;
|
||||
} DUMMYSTRUCTNAME;
|
||||
struct
|
||||
{
|
||||
DWORD LowPart;
|
||||
DWORD HighPart;
|
||||
} u;
|
||||
#endif // MIDL_PASS
|
||||
LONGLONG QuadPart;
|
||||
} LARGE_INTEGER;
|
||||
|
||||
#define __declspec(dllexport)
|
||||
|
||||
#define TOLUA_RELEASE
|
||||
|
||||
#define RTL_CRITICAL_SECTION pthread_mutex_t
|
||||
#define CRITICAL_SECTION pthread_mutex_t
|
||||
#define LPCRITICAL_SECTION pthread_mutex_t *
|
||||
#define EnterCriticalSection pthread_mutex_lock
|
||||
#define LeaveCriticalSection pthread_mutex_unlock
|
||||
#define TryEnterCriticalSection(x) (!pthread_mutex_trylock(x))
|
||||
#define InitializeCriticalSection(x) pthread_mutex_init((x), (NULL))
|
||||
#define DeleteCriticalSection pthread_mutex_destroy
|
||||
|
||||
#define CALLBACK __attribute__((stdcall))
|
||||
#define EXPORTCALL __attribute__((stdcall))
|
||||
#define __cdecl __attribute__((cdecl))
|
||||
#define __stdcall __attribute__((stdcall))
|
||||
|
||||
#define closesocket(x) close((x))
|
||||
|
||||
typedef struct _COORD {
|
||||
SHORT X;
|
||||
SHORT Y;
|
||||
} COORD, *PCOORD;
|
||||
|
||||
#define ioctlsocket ioctl
|
||||
#define ERROR_SUCCESS 0
|
||||
typedef struct sockaddr SOCKADDR;
|
||||
|
||||
#ifndef SOCKET_ERROR
|
||||
#define SOCKET_ERROR -1
|
||||
#endif
|
||||
|
||||
#define GetCurrentProcessId() getpid()
|
||||
|
||||
#define I64FORMAT "%lld"
|
||||
#define U64FORMAT "%llu"
|
||||
#endif
|
||||
|
||||
#include "../../system/SysApi.h"
|
||||
#include "../../system/LinuxTimer.h"
|
||||
#endif // _WYL_OS_DEFINITION_H_
|
||||
207
sdk/public/types.h
Normal file
207
sdk/public/types.h
Normal file
@@ -0,0 +1,207 @@
|
||||
#ifndef _types_H_
|
||||
#define _types_H_
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <deque>
|
||||
#include <iomanip>
|
||||
#include <list>
|
||||
#include <sstream>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
//#include <basetyps.h>
|
||||
#include <assert.h>
|
||||
//#include <tchar.h>
|
||||
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(f) assert(f)
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef signed char int8;
|
||||
typedef signed short int16;
|
||||
typedef signed int int32;
|
||||
typedef long long int64;
|
||||
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned short uint16;
|
||||
typedef unsigned int uint32;
|
||||
typedef unsigned long long uint64;
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned short word;
|
||||
typedef unsigned int dword;
|
||||
typedef long long longlong;
|
||||
#define SCORE longlong
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
typedef wchar_t wchar;
|
||||
|
||||
#ifdef _UNICODE
|
||||
typedef std::wstring tstring;
|
||||
typedef wchar tchar;
|
||||
#else
|
||||
typedef std::string tstring;
|
||||
typedef char tchar;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define LLSTRING "%I64d"
|
||||
#else
|
||||
#define LLSTRING "%lld"
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// 功能函数
|
||||
inline const char* toString(int value)
|
||||
{
|
||||
static std::string str;
|
||||
str.resize(128, '\0');
|
||||
sprintf(&str[0], "%d", value);
|
||||
return str.c_str();
|
||||
}
|
||||
|
||||
inline const char* toString(int64 value)
|
||||
{
|
||||
static std::string str;
|
||||
str.resize(128, '\0');
|
||||
sprintf(&str[0], LLSTRING, value);
|
||||
return str.c_str();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T tmin(const T& a, const T& b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline T tmax(const T& a, const T& b)
|
||||
{
|
||||
return a < b ? b : a;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool removeVectorByValue(std::vector<T>& a, const T& b)
|
||||
{
|
||||
typename std::vector<T>::iterator itor = a.begin();
|
||||
for (;itor != a.end();itor++)
|
||||
{
|
||||
if((*itor) == b)
|
||||
{
|
||||
a.erase(itor);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool haveInVectorByValue(std::vector<T>& a, const T& b)
|
||||
{
|
||||
typename std::vector<T>::iterator itor = a.begin();
|
||||
for (;itor != a.end();itor++)
|
||||
{
|
||||
if((*itor) == b)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// inline const std::wstring& toStringW(int value)
|
||||
// {
|
||||
// static std::wstring str;
|
||||
// #if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
//
|
||||
// str.resize(128, L'\0');
|
||||
// _snwprintf(&str[0], 128, L"%d", value);
|
||||
// return str;
|
||||
// #endif
|
||||
// return str;
|
||||
// }
|
||||
//
|
||||
// static std::string w2s(const std::wstring& ws)
|
||||
// {
|
||||
// #if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
// std::string curLocale = setlocale(LC_ALL, 0); // curLocale = "C";
|
||||
// setlocale(LC_ALL, "chs");
|
||||
// size_t len = ws.size() * 2 + 1;
|
||||
// std::string result;
|
||||
// result.resize(len, '\0');
|
||||
//
|
||||
// wcstombs_s(&len, &result[0], len, ws.c_str(), len);
|
||||
// setlocale(LC_ALL, curLocale.c_str());
|
||||
// return result;
|
||||
// #endif
|
||||
// std::string str;
|
||||
// return str;
|
||||
// }
|
||||
|
||||
// static std::wstring s2w(const std::string& s)
|
||||
// {
|
||||
// #if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
// std::string curLocale = setlocale(LC_ALL, "chs");
|
||||
// size_t len = s.size() + 1;
|
||||
// std::wstring result;
|
||||
// result.resize(len, L'\0');
|
||||
// mbstowcs_s(&len, &result[0], len, s.c_str(),len);
|
||||
// setlocale(LC_ALL, curLocale.c_str());
|
||||
// return result;
|
||||
// #endif
|
||||
// std::wstring ret;
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// 宏定义
|
||||
#define countarray(ary) (sizeof(ary)/sizeof(ary[0]))
|
||||
#define zeromemory(x, size) memset(x, 0, size)
|
||||
|
||||
// #ifdef _UNICODE
|
||||
// #define t2s(text) w2s(text)
|
||||
// #define t2w(text) tstring(text)
|
||||
// #define s2t(text) s2w(text)
|
||||
// #define w2t(text) tstring(text)
|
||||
// #define T_T(str) L##str
|
||||
// //#define toString toStringW
|
||||
//
|
||||
// #define tstrcpyn(dst, src, len) wcscpy_s(dst, len, src)
|
||||
// #define tstrcpy(dst, src) wcscpy(dst, src)
|
||||
// #define tstrlen(str) wcslen(str)
|
||||
// #define tstrcmp(str1, str2) wcscmp(str1, str2)
|
||||
//
|
||||
// #else
|
||||
// #define t2s(text) tstring(text)
|
||||
// #define t2w(text) s2w(text)
|
||||
// #define s2t(text) tstring(text)
|
||||
// #define w2t(text) s2w(text)
|
||||
// #define T_T(str) str
|
||||
// #define toString toStringA
|
||||
//
|
||||
// #define tstrcpyn(dst, src, len) strcpy_s(dst, len, src)
|
||||
// #define tstrcpy(dst, src) strcpy(dst, src)
|
||||
// #define tstrlen(str) strlen(str)
|
||||
// #define tstrcmp(str1, str2) strcmp(str1, str2)
|
||||
// #endif
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // _types_H_
|
||||
Reference in New Issue
Block a user