made it work with new fpc
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
#ifndef APPLE_AUTH_H
|
||||
#define APPLE_AUTH_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "tier2/iappsystem.h"
|
||||
|
||||
enum EAppleAuthDaemonStatus
|
||||
{
|
||||
APPLE_AUTH_DAEMON_NOT_LOGGED_IN,
|
||||
APPLE_AUTH_DAEMON_LOGGED_IN,
|
||||
};
|
||||
|
||||
enum EAppleAuthStatus
|
||||
{
|
||||
APPLE_AUTH_FAILURE,
|
||||
APPLE_AUTH_SUCCESS,
|
||||
APPLE_AUTH_NEED_2FA,
|
||||
APPLE_AUTH_NEED_SMS_2FA,
|
||||
};
|
||||
|
||||
abstract_class IAppleAuth: public IAppSystem
|
||||
{
|
||||
public:
|
||||
virtual void LaunchLoginDaemon() = 0;
|
||||
virtual EAppleAuthDaemonStatus GetStatus() = 0;
|
||||
virtual EAppleAuthStatus SubmitLoginData( const char *szEmail, const char *szPassword ) = 0;
|
||||
virtual EAppleAuthStatus Submit2FA( const char *szCode ) = 0;
|
||||
};
|
||||
|
||||
#define APPLE_AUTH_INTERFACE_VERSION "AppleAuth001"
|
||||
|
||||
#endif
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef ASMRIGS_AS_H
|
||||
#define ASMRIGS_AS_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
|
||||
struct AsOptions_t
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
CUtlBuffer<uint8_t> Assemble( const char *szAssembly, AsOptions_t stOptions );
|
||||
|
||||
#endif
|
||||
@@ -1,6 +0,0 @@
|
||||
#ifndef ASMRIGS_LD_H
|
||||
#define ASMRIGS_LD_H
|
||||
|
||||
#include "tier0/interface.h"
|
||||
|
||||
#endif
|
||||
@@ -1,55 +0,0 @@
|
||||
#ifndef ASMRIGS_TOKEN_PARSER
|
||||
#define ASMRIGS_TOKEN_PARSER
|
||||
|
||||
#include "tier2/tokenizer.h"
|
||||
|
||||
class CTokenParser
|
||||
{
|
||||
public:
|
||||
bool IsEOF();
|
||||
const char *PeekToken();
|
||||
bool IsToken( const char *szString );
|
||||
const char *PeekStringLiteral();
|
||||
bool Continue();
|
||||
|
||||
Token_t *m_pTokens;
|
||||
Token_t *m_pTokensEnd;
|
||||
Token_t *m_pCurrentToken;
|
||||
};
|
||||
|
||||
inline const char *CTokenParser::PeekToken()
|
||||
{
|
||||
if ( m_pCurrentToken->m_bIsQuoted )
|
||||
return NULL;
|
||||
return m_pCurrentToken->m_szValue;
|
||||
}
|
||||
inline bool CTokenParser::IsEOF()
|
||||
{
|
||||
if (m_pCurrentToken == m_pTokensEnd)
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
inline bool CTokenParser::IsToken( const char *szString )
|
||||
{
|
||||
if ( !V_strcmp(szString, m_pCurrentToken->m_szValue))
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
inline const char *CTokenParser::PeekStringLiteral()
|
||||
{
|
||||
if ( !m_pCurrentToken->m_bIsQuoted )
|
||||
return NULL;
|
||||
return m_pCurrentToken->m_szValue;
|
||||
}
|
||||
|
||||
inline bool CTokenParser::Continue()
|
||||
{
|
||||
m_pCurrentToken++;
|
||||
if ( m_pCurrentToken == m_pTokensEnd )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,61 +0,0 @@
|
||||
#ifndef HTTP_H
|
||||
#define HTTP_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/utlvector.h"
|
||||
#include "tier1/utlstring.h"
|
||||
|
||||
struct HTTPHeaderParam_t
|
||||
{
|
||||
CUtlString m_szParamName;
|
||||
CUtlString m_szValue;
|
||||
};
|
||||
|
||||
struct HTTPHeader_t
|
||||
{
|
||||
uint32_t m_nParamCount;
|
||||
HTTPHeaderParam_t *m_params;
|
||||
};
|
||||
|
||||
struct HTTPResponse_t
|
||||
{
|
||||
CUtlBuffer<HTTPHeaderParam_t> m_params;
|
||||
CUtlBuffer<char> m_message;
|
||||
uint32_t m_uCode;
|
||||
bool m_bIsComplete;
|
||||
};
|
||||
|
||||
struct WebSocketPacket_t
|
||||
{
|
||||
size_t m_uSize;
|
||||
void *m_pData;
|
||||
};
|
||||
|
||||
abstract_class IHTTPClient
|
||||
{
|
||||
public:
|
||||
virtual void Post( const char *szResource, HTTPHeader_t *pHeader, uint32_t uDataSize, const void *data ) = 0;
|
||||
virtual void Get( const char *szResource, HTTPHeader_t *pHeader ) = 0;
|
||||
|
||||
virtual bool WebSocket_Connect( const char *szResource ) = 0;
|
||||
virtual void WebSocket_Close( void ) = 0;
|
||||
virtual void WebSocket_SendText( const char *szData ) = 0;
|
||||
virtual CUtlString WebSocket_RecvText() = 0;
|
||||
virtual void WebSocket_SendBinary( size_t uSize, const void *pData ) = 0;
|
||||
virtual WebSocketPacket_t WebSocket_RecvBinary() = 0;
|
||||
|
||||
virtual HTTPResponse_t GetResponse() = 0;
|
||||
};
|
||||
|
||||
abstract_class IHTTPClientManager
|
||||
{
|
||||
public:
|
||||
virtual IHTTPClient *Connect( const char *szUrl, bool bSecure, uint16_t *pPort ) = 0;
|
||||
virtual void Disconnect( IHTTPClient *pClient ) = 0;
|
||||
};
|
||||
|
||||
#define HTTP_CLIENT_INTERFACE_VERSION "FHTTPClientMgr001"
|
||||
extern IHTTPClientManager *g_pHttpClientMgr;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,43 +1,28 @@
|
||||
#ifndef GAME_WINDOW_H
|
||||
#define GAME_WINDOW_H
|
||||
|
||||
#include "tier2/iappsystem.h"
|
||||
#include "gamesystem.h"
|
||||
#include "tier0/platform.h"
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
|
||||
enum EGraphicsAPI
|
||||
{
|
||||
GRAPHICS_API_METAL,
|
||||
GRAPHICS_API_VULKAN,
|
||||
};
|
||||
|
||||
abstract_class IGameWindow: public IAppSystem
|
||||
abstract_class IGameWindow: public IGameSystem
|
||||
{
|
||||
public:
|
||||
virtual void UpdateWindow() = 0;
|
||||
virtual uint32_t GetRenderWidth() = 0;
|
||||
virtual uint32_t GetRenderHeight() = 0;
|
||||
|
||||
|
||||
// Rendering info
|
||||
virtual void SetRenderImage( IImage *pImage ) = 0;
|
||||
virtual bool BIsRenderResolutionUpdated() = 0;
|
||||
virtual void GetRenderWidth() = 0;
|
||||
virtual void GetRenderHeight() = 0;
|
||||
virtual EGraphicsAPI GetGraphicsAPI() = 0;
|
||||
|
||||
// Vulkan stuff
|
||||
virtual int GetVulkanInstanceExtensionCount() = 0;
|
||||
virtual const char **GetVulkanInstanceExtensions() = 0;
|
||||
|
||||
virtual void CreateVulkanSurface( void *pInstance, void *pDevice ) = 0;
|
||||
virtual void DestroyVulkanSurface( void *pInstance, void *pDevice ) = 0;
|
||||
|
||||
virtual void *GetVulkanSurface() = 0;
|
||||
virtual void *GetVulkanFence( int iFrame ) = 0;
|
||||
virtual void *GetVulkanDrawSemaphore( int iFrame ) = 0;
|
||||
virtual void *GetVulkanPresentSemaphore( int iFrame ) = 0;
|
||||
virtual IImage *GetVulkanSwapchainImage( int iFrame ) = 0;
|
||||
virtual void *CreateVulkanSurface( void *pInstance ) = 0;
|
||||
virtual void DestroyVulkanSurface( void *pInstance ) = 0;
|
||||
};
|
||||
|
||||
extern IGameWindow *gamewindow;
|
||||
abstract_class IGameWindowManager: public IGameSystem
|
||||
{
|
||||
public:
|
||||
virtual IGameWindow *CreateWindow() = 0;
|
||||
virtual void DestroyWindow( IGameWindow* pWindow ) = 0;
|
||||
|
||||
virtual int GetVulkanInstanceExtensionCount() = 0;
|
||||
virtual const char **GetVulkanInstanceExtensions() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "tier0/platform.h"
|
||||
#include "tier2/iappsystem.h"
|
||||
class IGameWindow;
|
||||
class IGameWindowManager;
|
||||
|
||||
#define VULKAN_FRAMES_IN_FLIGHT 2
|
||||
|
||||
@@ -87,7 +88,7 @@ enum ETopologyMode
|
||||
abstract_class IRenderingObject
|
||||
{
|
||||
public:
|
||||
virtual ~IRenderingObject() = 0;
|
||||
virtual ~IRenderingObject() = default;
|
||||
virtual void SetDebugName( const char *szName ) = 0;
|
||||
};
|
||||
|
||||
@@ -97,6 +98,7 @@ public:
|
||||
abstract_class IBuffer : public IRenderingObject
|
||||
{
|
||||
public:
|
||||
virtual ~IBuffer() = default;
|
||||
virtual void Lock() = 0;
|
||||
virtual void Unlock() = 0;
|
||||
virtual void *Map() = 0;
|
||||
@@ -126,7 +128,7 @@ public:
|
||||
abstract_class IShader
|
||||
{
|
||||
public:
|
||||
virtual ~IShader() = 0;
|
||||
virtual ~IShader() = default;
|
||||
virtual uint32_t PSGetResourceByName( const char *szName ) = 0;
|
||||
virtual uint32_t VSGetResourceByName( const char *szName ) = 0;
|
||||
};
|
||||
@@ -141,7 +143,7 @@ public:
|
||||
abstract_class IMaterial
|
||||
{
|
||||
public:
|
||||
virtual ~IMaterial() = 0;
|
||||
virtual ~IMaterial() = default;
|
||||
virtual void VSSetShaderResource( uint32_t uRegister, IRenderingObject *pResource ) = 0;
|
||||
virtual void PSSetShaderResource( uint32_t uRegister, IRenderingObject *pResource ) = 0;
|
||||
virtual void VSSetConstantsBuffer( uint32_t uRegister, IBuffer *pImage ) = 0;
|
||||
@@ -185,13 +187,6 @@ abstract_class IRenderContext: public IAppSystem
|
||||
{
|
||||
public:
|
||||
virtual void Frame( float fTime ) = 0;
|
||||
|
||||
virtual void SetOutputImage( IImage *pImage ) = 0;
|
||||
|
||||
virtual bool BIsOutputImageOutdated() = 0;
|
||||
virtual uint32_t GetNewOutputImageWidth() = 0;
|
||||
virtual uint32_t GetNewOutputImageHeight() = 0;
|
||||
virtual EImageFormat GetNewOutputImageFormat() = 0;
|
||||
|
||||
virtual IVertexBuffer *CreateVertexBuffer( uint32_t nSize ) = 0;
|
||||
virtual IIndexBuffer *CreateIndexBuffer( uint32_t nSize ) = 0;
|
||||
@@ -212,12 +207,16 @@ public:
|
||||
virtual IRenderCommandList *CreateCommandList() = 0;
|
||||
virtual void DestroyCommandList( IRenderCommandList *pCommandList ) = 0;
|
||||
virtual void SubmitCommandList(IRenderCommandList *pList) = 0;
|
||||
|
||||
virtual void SetMainWindowManager( IGameWindowManager *pWindowManager ) = 0;
|
||||
|
||||
virtual void RenderGameWindow( IGameWindow *pWindow ) = 0;
|
||||
virtual void RegisterGameWindow( IGameWindow *pWindow ) = 0;
|
||||
virtual void UnregisterGameWindow( IGameWindow *pWindow ) = 0;
|
||||
};
|
||||
|
||||
#define RENDER_CONTEXT_INTERFACE_NAME "RenderContext001"
|
||||
#define MATERIAL_SYSTEM_INTERFACE_NAME "MaterialSystem001"
|
||||
#define RENDER_CONTEXT_INTERFACE_VERSION "RenderContext001"
|
||||
#define MATERIAL_SYSTEM_INTERFACE_VERSION "MaterialSystem001"
|
||||
|
||||
abstract_class IMaterialSystem: public IAppSystem
|
||||
{
|
||||
@@ -226,7 +225,5 @@ public:
|
||||
virtual void RenderGameWindow( IGameWindow *pWindow ) = 0;
|
||||
};
|
||||
|
||||
extern IRenderContext *g_pRenderContext;
|
||||
extern IMaterialSystem *g_pMaterialSystem;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
//================= Copyright kotofyt, All rights reserved ==================//
|
||||
// Purpose: Command line handler for argc and argv. It also allows to find
|
||||
// parameters and push your own.
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef TIER0_COMMANDLINE_H
|
||||
#define TIER0_COMMANDLINE_H
|
||||
|
||||
|
||||
#include "tier0/platform.h"
|
||||
|
||||
abstract_class ICommandLine
|
||||
{
|
||||
public:
|
||||
virtual void CreateCommandLine( int argc, char **argv ) = 0;
|
||||
|
||||
virtual bool CheckParam( const char *psz ) = 0;
|
||||
virtual char *ParamValue( const char* psz, const char *szDefaultValue = 0 ) = 0;
|
||||
|
||||
virtual void AddParam( char *psz ) = 0;
|
||||
virtual void RemoveParam( char *psz ) = 0;
|
||||
|
||||
virtual int ParamCount() = 0;
|
||||
virtual int FindParam( const char *psz ) = 0;
|
||||
virtual const char *GetParam(int nIndex) = 0;
|
||||
};
|
||||
|
||||
ICommandLine *CommandLine();
|
||||
|
||||
#endif
|
||||
@@ -1,130 +0,0 @@
|
||||
//================= Copyright kotofyt, All rights reserved ==================//
|
||||
// Purpose: A header which implements or redefines libc implementation.
|
||||
// It is defined with V_ prefix to differentiate own implementation from
|
||||
// given libc by the OS.
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef TIER0_STDLIB_H
|
||||
#define TIER0_STDLIB_H
|
||||
|
||||
#include "tier0/minmax_on.h"
|
||||
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "ctype.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// string.h
|
||||
//-----------------------------------------------------------------------------
|
||||
#define V_memcpy memcpy
|
||||
#define V_memmove memmove
|
||||
#define V_memchr memchr
|
||||
#define V_memcmp memcmp
|
||||
#define V_memset memset
|
||||
|
||||
#define V_strcat strcat
|
||||
#define V_strncat strncat
|
||||
#define V_strchr strchr
|
||||
#define V_strrchr strrchr
|
||||
#define V_strcmp strcmp
|
||||
#define V_strncmp strncmp
|
||||
#define V_strcoll strcoll
|
||||
#define V_strcpy strcpy
|
||||
#define V_strncpy strncpy
|
||||
#define V_strlen strlen
|
||||
#define V_strnlen strnlen
|
||||
#define V_strspn strspn
|
||||
#define V_strcspn strcspn
|
||||
#define V_strpbrk strpbrk
|
||||
#define V_strstr strstr
|
||||
#define V_strtok strtok
|
||||
#define V_strxfrm strxfrm
|
||||
|
||||
#ifdef __WIN32__
|
||||
#define V_stricmp stricmp
|
||||
#else
|
||||
#define V_stricmp strcasecmp
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// stdio.h
|
||||
//-----------------------------------------------------------------------------
|
||||
#define V_fclose fclose
|
||||
#define V_fopen fopen
|
||||
#define V_freopen freopen
|
||||
#define V_fdopen fdopen
|
||||
#define V_remove remove
|
||||
#define V_rename rename
|
||||
#define V_rewind rewind
|
||||
#define V_tmpfile tmpfile
|
||||
|
||||
#define V_feof feof
|
||||
#define V_ferror ferror
|
||||
#define V_fflush fflush
|
||||
#define V_fgetpos fgetpos
|
||||
#define V_fgetc getc
|
||||
#define V_fgets gets
|
||||
#define V_fputc putc
|
||||
#define V_fputs puts
|
||||
#define V_ftell ftell
|
||||
#define V_fseek fseek
|
||||
#define V_fsetpos fsetpos
|
||||
#define V_fread fread
|
||||
#define V_fwrite fwrite
|
||||
#define V_getc getc
|
||||
#define V_getchar getchar
|
||||
#define V_gets gets
|
||||
#define V_printf printf
|
||||
#define V_vprintf vprintf
|
||||
#define V_fprintf fprintf
|
||||
#define V_vfprintf vfprintf
|
||||
#define V_sprintf sprintf
|
||||
#define V_snprintf snprintf
|
||||
#define V_vsprintf vsprintf
|
||||
#define V_vsnprintf vsnprintf
|
||||
#define V_perror perror
|
||||
#define V_putc putc
|
||||
#define V_putchar putchar
|
||||
#define V_fputchar fputchar
|
||||
#define V_scanf scanf
|
||||
#define V_sscanf sscanf
|
||||
#define V_vscanf vscanf
|
||||
#define V_fscanf fscanf
|
||||
#define V_vfscanf vfscanf
|
||||
#define V_vsscanf vsscanf
|
||||
#define V_setbuf setbuf
|
||||
#define V_setvbuf setvbuf
|
||||
#define V_tmpnam tmpnam
|
||||
#define V_ungetc ungetc
|
||||
#define V_puts puts
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// stdlib.h
|
||||
//-----------------------------------------------------------------------------
|
||||
#define V_atoi atoi
|
||||
#define V_atof atof
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ctype.h
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define V_isalnum isalnum
|
||||
#define V_isalpha isalpha
|
||||
#define V_isblank isblank
|
||||
#define V_iscntrl iscntrl
|
||||
#define V_isdigit isdigit
|
||||
#define V_isgraph isgraph
|
||||
#define V_islower islower
|
||||
#define V_isprint isprint
|
||||
#define V_ispunct ispunct
|
||||
#define V_isspace isspace
|
||||
#define V_isupper isupper
|
||||
#define V_isxdigit isxdigit
|
||||
#define V_tolower tolower
|
||||
#define V_toupper toupper
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,20 +0,0 @@
|
||||
//================= Copyright kotofyt, All rights reserved ==================//
|
||||
// Purpose: A memory allocator for C and C++.
|
||||
// For now it uses libc but it is possible to use own allocators
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef TIER0_MEM_H
|
||||
#define TIER0_MEM_H
|
||||
|
||||
#include "platform.h"
|
||||
#include "lib.h"
|
||||
|
||||
PLATFORM_INTERFACE void *V_malloc( int nSize );
|
||||
PLATFORM_INTERFACE void V_free( void *pMem );
|
||||
PLATFORM_INTERFACE void *V_realloc( void *pMem, int nSize );
|
||||
|
||||
void *operator new( size_t nCount );
|
||||
void *operator new ( size_t nCount, void *pPtr );
|
||||
void operator delete( void *pMem ) noexcept;
|
||||
|
||||
#endif
|
||||
@@ -1,9 +0,0 @@
|
||||
//================= Copyright kotofyt, All rights reserved ==================//
|
||||
// Purpose: Disables min and max. Used for C++ interoperability
|
||||
//===========================================================================//
|
||||
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#undef max
|
||||
#endif
|
||||
@@ -1,8 +0,0 @@
|
||||
//================= Copyright kotofyt, All rights reserved ==================//
|
||||
// Purpose: Enables min and max. Used for C++ interoperability
|
||||
//===========================================================================//
|
||||
|
||||
#include "minmax_off.h"
|
||||
|
||||
#define max(x, y) (((x) > (y)) ? (x) : (y))
|
||||
#define min(x, y) (((x) < (y)) ? (x) : (y))
|
||||
@@ -1,21 +0,0 @@
|
||||
//================= Copyright kotofyt, All rights reserved ==================//
|
||||
// Purpose:
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef TIER0_NETWORK_H
|
||||
#define TIER0_NETWORK_H
|
||||
|
||||
#include "platform.h"
|
||||
#ifdef __linux__
|
||||
#include "arpa/inet.h"
|
||||
#endif
|
||||
#ifdef __WIN32__
|
||||
#include "winsock2.h"
|
||||
#include "ws2tcpip.h"
|
||||
#endif
|
||||
|
||||
|
||||
PLATFORM_INTERFACE void Net_Init();
|
||||
PLATFORM_INTERFACE void Net_Deinit();
|
||||
|
||||
#endif
|
||||
@@ -1,114 +0,0 @@
|
||||
//================= Copyright kotofyt, All rights reserved ==================//
|
||||
// Purpose: Multi-platform implementation of some of the functions which
|
||||
// are provided by each OS differently.
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef TIER0_PLATFORM_H
|
||||
#define TIER0_PLATFORM_H
|
||||
|
||||
#include "stdint.h"
|
||||
#include "stddef.h"
|
||||
|
||||
#ifdef __WIN32__
|
||||
#define DLL_EXPORT extern "C"
|
||||
#define DLL_IMPORT extern "C"
|
||||
|
||||
#define DLL_CLASS_EXPORT
|
||||
#define DLL_CLASS_IMPORT
|
||||
|
||||
#define DLL_GLOBAL_EXPORT extern
|
||||
#define DLL_GLOBAL_IMPORT extern
|
||||
#else
|
||||
#define DLL_EXPORT extern "C" __attribute__ ((visibility("default")))
|
||||
#define DLL_IMPORT extern "C"
|
||||
|
||||
#define DLL_CLASS_EXPORT __attribute__ ((visibility("default")))
|
||||
#define DLL_CLASS_IMPORT
|
||||
|
||||
#define DLL_GLOBAL_EXPORT __attribute ((visibility("default")))
|
||||
#define DLL_GLOBAL_IMPORT extern
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TIER0_STATIC
|
||||
|
||||
#define GLOBAL_USED __attribute__((used))
|
||||
|
||||
#else
|
||||
|
||||
#define GLOBAL_USED __attribute__((used))
|
||||
|
||||
#ifdef TIER0_IMPLEMENTATION
|
||||
#define PLATFORM_INTERFACE DLL_EXPORT
|
||||
#define PLATFORM_OVERLOAD DLL_GLOBAL_EXPORT
|
||||
#define PLATFORM_CLASS DLL_CLASS_EXPORT
|
||||
#else
|
||||
#define PLATFORM_INTERFACE DLL_IMPORT
|
||||
#define PLATFORM_OVERLOAD DLL_GLOBAL_IMPORT
|
||||
#define PLATFORM_CLASS DLL_CLASS_IMPORT
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
#define POSIX
|
||||
#endif
|
||||
|
||||
#define SWAP16(x) (uint16_t)((((x) >> 8) & 0x00FF) | \
|
||||
(((x) << 8) & 0xFF00))
|
||||
|
||||
#define SWAP32(x) (uint32_t)((((x) >> 24) & 0x000000FF) | \
|
||||
(((x) >> 8) & 0x0000FF00) | \
|
||||
(((x) << 8) & 0x00FF0000) | \
|
||||
(((x) << 24) & 0xFF000000))
|
||||
|
||||
#define SWAP64(x) ((uint64_t)( \
|
||||
(((x) >> 56) & 0x00000000000000FFULL) | \
|
||||
(((x) >> 40) & 0x000000000000FF00ULL) | \
|
||||
(((x) >> 24) & 0x0000000000FF0000ULL) | \
|
||||
(((x) >> 8) & 0x00000000FF000000ULL) | \
|
||||
(((x) << 8) & 0x000000FF00000000ULL) | \
|
||||
(((x) << 24) & 0x0000FF0000000000ULL) | \
|
||||
(((x) << 40) & 0x00FF000000000000ULL) | \
|
||||
(((x) << 56) & 0xFF00000000000000ULL) ))
|
||||
|
||||
#define abstract_class class
|
||||
|
||||
PLATFORM_INTERFACE void Plat_FatalErrorFunc( const char *szFormat, ... );
|
||||
|
||||
typedef void( *ListDirCallbackFn )( const char *szPath );
|
||||
PLATFORM_INTERFACE void Plat_ListDirRecursive( const char *szPath, ListDirCallbackFn file, ListDirCallbackFn dir );
|
||||
PLATFORM_INTERFACE void Plat_ListDir( const char *szPath, ListDirCallbackFn file, ListDirCallbackFn dir );
|
||||
PLATFORM_INTERFACE char *Plat_GetExtension( const char *szPath );
|
||||
|
||||
PLATFORM_INTERFACE void Plat_MakeDir( const char *szPath, int iPermissions );
|
||||
|
||||
PLATFORM_INTERFACE void Plat_TrapSignals( void (*pfn)() );
|
||||
PLATFORM_INTERFACE void Plat_Backtrace( void );
|
||||
|
||||
PLATFORM_INTERFACE void *Plat_LoadLibrary( const char *psz );
|
||||
PLATFORM_INTERFACE void *Plat_GetProc( void *lib, const char *psz );
|
||||
PLATFORM_INTERFACE void Plat_UnloadLibrary( void *psz );
|
||||
|
||||
PLATFORM_INTERFACE void Plat_SetEnv( const char *szVar, const char *psz );
|
||||
PLATFORM_INTERFACE const char *Plat_GetEnv( const char *szVar );
|
||||
|
||||
PLATFORM_INTERFACE void Plat_SetWorkingDir( const char *psz );
|
||||
PLATFORM_INTERFACE const char *Plat_GetWorkingDir( void );
|
||||
|
||||
PLATFORM_INTERFACE const char *Plat_GetExecutablePath( void );
|
||||
PLATFORM_INTERFACE const char *Plat_GetParentDir( const char *psz );
|
||||
|
||||
PLATFORM_INTERFACE const char *Plat_GetUNIXExecutable( const char *psz );
|
||||
PLATFORM_INTERFACE const char *Plat_GetWindowsExecutable( const char *psz );
|
||||
PLATFORM_INTERFACE const char *Plat_GetPlatformExecutable( const char *psz );
|
||||
|
||||
PLATFORM_INTERFACE const char *Plat_GetDarwinSharedLib( const char *psz );
|
||||
PLATFORM_INTERFACE const char *Plat_GetUNIXSharedLib( const char *psz );
|
||||
PLATFORM_INTERFACE const char *Plat_GetWindowsSharedLib( const char *psz );
|
||||
PLATFORM_INTERFACE const char *Plat_GetPlatformSharedLib( const char *psz );
|
||||
|
||||
PLATFORM_INTERFACE double Plat_GetTime( void );
|
||||
PLATFORM_INTERFACE void Plat_Exit( int status );
|
||||
|
||||
#endif
|
||||
@@ -1,10 +0,0 @@
|
||||
#ifndef TIER0_RAND_H
|
||||
#define TIER0_RAND_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
|
||||
PLATFORM_INTERFACE void Plat_InitRandom();
|
||||
PLATFORM_INTERFACE void Plat_ShutdownRandom();
|
||||
PLATFORM_INTERFACE void Plat_URandom( size_t uBufferSize, uint8_t *szBuffer );
|
||||
|
||||
#endif
|
||||
@@ -1,7 +0,0 @@
|
||||
#ifndef APPINIT_H
|
||||
#define APPINIT_H
|
||||
|
||||
|
||||
void AppInitializePath();
|
||||
|
||||
#endif
|
||||
@@ -1,5 +0,0 @@
|
||||
//================= Copyright kotofyt, All rights reserved ==================//
|
||||
// Purpose: BAN STL. I hate it.
|
||||
//===========================================================================//
|
||||
|
||||
#define std no_you_do_not_use_std
|
||||
@@ -1,38 +0,0 @@
|
||||
#ifndef INTERFACE_H
|
||||
#define INTERFACE_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
|
||||
typedef void *( *CreateInterfaceFn )( const char *szName, int *pReturnCode );
|
||||
typedef void *( *InstantiateInterfaceFn )( void );
|
||||
|
||||
class CInterfaceRegistry
|
||||
{
|
||||
public:
|
||||
CInterfaceRegistry( InstantiateInterfaceFn fn, const char *szName );
|
||||
|
||||
InstantiateInterfaceFn m_CreateFn;
|
||||
const char *m_szName;
|
||||
|
||||
CInterfaceRegistry *m_pNext;
|
||||
};
|
||||
|
||||
|
||||
#define EXPOSE_INTERFACE( className, interfaceName, versionName ) \
|
||||
static void *__Create##className##_interface() { return ( interfaceName* )( new className ); }; \
|
||||
static CInterfaceRegistry __Create##className##_registry( __Create##className##_interface, versionName );
|
||||
|
||||
#define EXPOSE_INTERFACE_FN( functionName, interfaceName, versionName ) \
|
||||
static CInterfaceRegistry __Create##interfaceName##_registry( functionName, versionName );
|
||||
|
||||
#define EXPOSE_INTERFACE_GLOBALVAR( className, interfaceName, versionName, globalVarName ) \
|
||||
static void *__Create##className##_interface() { return ( interfaceName* )( &globalVarName ); }; \
|
||||
static CInterfaceRegistry __Create##className##_registry( __Create##className##_interface, versionName );
|
||||
|
||||
|
||||
DLL_EXPORT void *CreateInterface( const char *szName, int *pReturnCode );
|
||||
|
||||
CreateInterfaceFn Sys_GetFactory( void *pLibrary );
|
||||
CreateInterfaceFn Sys_GetFactory( const char *szLibrary );
|
||||
|
||||
#endif
|
||||
@@ -1,5 +0,0 @@
|
||||
//================= Copyright kotofyt, All rights reserved ==================//
|
||||
// Purpose: Unban STL because C++ doesn't like using something different.
|
||||
//===========================================================================//
|
||||
|
||||
#undef std
|
||||
@@ -1,370 +0,0 @@
|
||||
//================= Copyright kotofyt, All rights reserved ==================//
|
||||
// Purpose: Memory buffers for C++. They store data on heap as you have C
|
||||
// arrays for stack.
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef TIER1_UTL_BUFFER_H
|
||||
#define TIER1_UTL_BUFFER_H
|
||||
|
||||
|
||||
#include "tier0/mem.h"
|
||||
#include "tier0/platform.h"
|
||||
#include "tier0/lib.h"
|
||||
|
||||
template <typename T>
|
||||
class CUtlBuffer;
|
||||
template <typename T>
|
||||
class CUtlResizableBuffer;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This buffer contains static data allocated on heap.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
class CUtlBuffer
|
||||
{
|
||||
public:
|
||||
CUtlBuffer( void );
|
||||
CUtlBuffer( size_t nSize );
|
||||
CUtlBuffer( const CUtlBuffer<T>& buffer );
|
||||
CUtlBuffer( const CUtlResizableBuffer<T>& buffer );
|
||||
~CUtlBuffer( void );
|
||||
|
||||
size_t GetSize( void ) const;
|
||||
T* GetMemory(void) const;
|
||||
|
||||
operator T*( void ) const;
|
||||
T& operator []( const size_t nIndex );
|
||||
T operator []( const size_t nIndex ) const;
|
||||
CUtlBuffer<T>& operator=(const CUtlBuffer<T>& other);
|
||||
private:
|
||||
T* m_pData = NULL;
|
||||
size_t m_nSize = 0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
CUtlBuffer<T>::CUtlBuffer() : m_nSize(0)
|
||||
{
|
||||
m_pData = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
CUtlBuffer<T>::CUtlBuffer( size_t nSize ) : m_nSize(nSize)
|
||||
{
|
||||
if ( nSize == 0 )
|
||||
nSize = 1;
|
||||
m_pData = (T*)V_malloc(sizeof(T)*nSize);
|
||||
V_memset(m_pData, 0, sizeof(T)*nSize);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
CUtlBuffer<T>::CUtlBuffer( const CUtlBuffer<T>& buffer ) : m_nSize(buffer.m_nSize)
|
||||
{
|
||||
m_pData = (T*)V_malloc(sizeof(T)*buffer.m_nSize);
|
||||
V_memcpy(m_pData,buffer.m_pData,sizeof(T)*buffer.m_nSize);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
CUtlBuffer<T>::CUtlBuffer( const CUtlResizableBuffer<T>& buffer ) : m_nSize(buffer.GetSize())
|
||||
{
|
||||
m_pData = (T*)V_malloc(sizeof(T)*buffer.GetSize());
|
||||
V_memcpy(m_pData,buffer.GetMemory(),sizeof(T)*buffer.GetSize());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
CUtlBuffer<T>::~CUtlBuffer()
|
||||
{
|
||||
if ( m_pData != 0)
|
||||
V_free(m_pData);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gets memory size.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
size_t CUtlBuffer<T>::GetSize( void ) const
|
||||
{
|
||||
return m_nSize;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gets memory address.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
T* CUtlBuffer<T>::GetMemory( void ) const
|
||||
{
|
||||
return m_pData;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gets memory address using casting.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
CUtlBuffer<T>::operator T*( void ) const
|
||||
{
|
||||
return m_pData;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Indexes buffer for writing.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
T& CUtlBuffer<T>::operator []( const size_t nIndex )
|
||||
{
|
||||
if ( m_pData == 0)
|
||||
Plat_FatalErrorFunc("Buffer was not initialized\n");
|
||||
|
||||
if ( nIndex >= m_nSize )
|
||||
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu\n", m_nSize/sizeof(T), nIndex);
|
||||
|
||||
return m_pData[nIndex];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Indexes buffer for reading.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
T CUtlBuffer<T>::operator []( const size_t nIndex ) const
|
||||
{
|
||||
if ( nIndex >= m_nSize )
|
||||
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu\n",m_nSize, nIndex);
|
||||
return m_pData[nIndex];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Assigns buffer.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
CUtlBuffer<T>& CUtlBuffer<T>::operator=(const CUtlBuffer<T>& other)
|
||||
{
|
||||
if ( this != &other )
|
||||
{
|
||||
if ( m_pData != 0)
|
||||
V_free(m_pData);
|
||||
m_pData = (T*)V_malloc(sizeof(T)*other.m_nSize);
|
||||
m_nSize = other.m_nSize;
|
||||
V_memcpy(m_pData, other.m_pData, sizeof(T)*other.m_nSize);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This buffer contains static data allocated on heap which can be resized.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
class CUtlResizableBuffer
|
||||
{
|
||||
public:
|
||||
CUtlResizableBuffer( void );
|
||||
CUtlResizableBuffer( size_t nSize );
|
||||
CUtlResizableBuffer( const CUtlBuffer<T>& buffer );
|
||||
CUtlResizableBuffer( const CUtlResizableBuffer<T>& buffer );
|
||||
~CUtlResizableBuffer();
|
||||
|
||||
size_t GetSize() const;
|
||||
size_t GetRealSize() const;
|
||||
void Resize( size_t nSize, size_t nDataOffset = 0 );
|
||||
void* GetMemory(void) const;
|
||||
|
||||
operator T*( void ) const;
|
||||
T& operator []( const size_t nIndex );
|
||||
T operator []( const size_t nIndex ) const;
|
||||
CUtlResizableBuffer<T>& operator=(const CUtlResizableBuffer<T>& other);
|
||||
private:
|
||||
size_t CalculateMemorySize(size_t nSize);
|
||||
T* m_pData = NULL;
|
||||
size_t m_nSize = 0;
|
||||
size_t m_nAllocatedSize = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
CUtlResizableBuffer<T>::CUtlResizableBuffer()
|
||||
{
|
||||
m_pData = NULL;
|
||||
m_nSize = 0;
|
||||
m_nAllocatedSize = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
CUtlResizableBuffer<T>::CUtlResizableBuffer( size_t nSize )
|
||||
{
|
||||
Resize(nSize);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
CUtlResizableBuffer<T>::CUtlResizableBuffer( const CUtlBuffer<T>& buffer ) : m_nSize(buffer.nSize)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constructor.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
CUtlResizableBuffer<T>::CUtlResizableBuffer( const CUtlResizableBuffer<T>& buffer ) : m_nSize(buffer.m_nSize)
|
||||
{
|
||||
*this = buffer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
CUtlResizableBuffer<T>::~CUtlResizableBuffer()
|
||||
{
|
||||
for ( size_t i = 0; i < m_nSize; i++)
|
||||
m_pData[i].~T();
|
||||
if (m_pData)
|
||||
V_free(m_pData);
|
||||
m_pData = 0;
|
||||
m_nSize = 0;
|
||||
m_nAllocatedSize = 0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gets memory size.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
size_t CUtlResizableBuffer<T>::GetSize( void ) const
|
||||
{
|
||||
return m_nSize;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gets memory size.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
size_t CUtlResizableBuffer<T>::GetRealSize( void ) const
|
||||
{
|
||||
return m_nAllocatedSize;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Resizes memory.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void CUtlResizableBuffer<T>::Resize( size_t nSize, size_t nDataOffset )
|
||||
{
|
||||
if (nSize > m_nAllocatedSize)
|
||||
{
|
||||
size_t nAllocationSize = CalculateMemorySize(nSize);
|
||||
T *pData = (T*)V_malloc(nAllocationSize*sizeof(T));
|
||||
for (size_t i = 0; i < m_nSize; i++)
|
||||
{
|
||||
new (&pData[i+nDataOffset]) T(m_pData[i]);
|
||||
m_pData[i].~T();
|
||||
}
|
||||
V_free(m_pData);
|
||||
m_pData = pData;
|
||||
m_nAllocatedSize = nAllocationSize;
|
||||
}
|
||||
for ( size_t i = m_nSize+nDataOffset; i < nSize; ++i )
|
||||
new (&m_pData[i]) T();
|
||||
m_nSize = nSize;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gets memory address.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void* CUtlResizableBuffer<T>::GetMemory( void ) const
|
||||
{
|
||||
return m_pData;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Gets memory address using casting.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
CUtlResizableBuffer<T>::operator T*( void ) const
|
||||
{
|
||||
return m_pData;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Indexes buffer for writing.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
T& CUtlResizableBuffer<T>::operator []( const size_t nIndex )
|
||||
{
|
||||
if ( m_pData == 0)
|
||||
Plat_FatalErrorFunc("Buffer was not initialized\n");
|
||||
|
||||
if ( nIndex >= m_nSize )
|
||||
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu\n",m_nSize, nIndex);
|
||||
|
||||
return m_pData[nIndex];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Indexes buffer for reading.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
T CUtlResizableBuffer<T>::operator []( const size_t nIndex ) const
|
||||
{
|
||||
if ( nIndex >= m_nSize )
|
||||
Plat_FatalErrorFunc("Out of bounds indexing: size is %lu and index is %lu\n",m_nSize, nIndex);
|
||||
return m_pData[nIndex];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Assigns buffer.
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
CUtlResizableBuffer<T>& CUtlResizableBuffer<T>::operator=(const CUtlResizableBuffer<T>& other)
|
||||
{
|
||||
if ( this != &other )
|
||||
{
|
||||
if (m_pData)
|
||||
{
|
||||
for (size_t i = 0; i < m_nSize; i++)
|
||||
m_pData[i].~T();
|
||||
V_free(m_pData);
|
||||
}
|
||||
m_pData = (T*)V_malloc(other.m_nAllocatedSize*sizeof(T));
|
||||
m_nAllocatedSize = other.m_nAllocatedSize;
|
||||
m_nSize = other.m_nSize;
|
||||
for ( size_t i = 0; i < other.m_nSize; i++)
|
||||
new (&m_pData[i]) T(other.m_pData[i]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Calculates memory size that is
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
size_t CUtlResizableBuffer<T>::CalculateMemorySize(size_t nSize)
|
||||
{
|
||||
size_t x = nSize;
|
||||
if (x == 0) return 1;
|
||||
x--;
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
#if SIZE_MAX > UINT32_MAX
|
||||
x |= x >> 32;
|
||||
#endif
|
||||
return x + 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,64 +0,0 @@
|
||||
//================= Copyright kotofyt, All rights reserved ==================//
|
||||
// C++ only supports std::initializer_list, so we need to get around compiler.
|
||||
//
|
||||
// fuck C++ once
|
||||
// fuck C++ twice
|
||||
// fuck C++ thrice
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef TIER1_UTL_INITIALIZER_LIST_H
|
||||
#define TIER1_UTL_INITIALIZER_LIST_H
|
||||
|
||||
#include "stddef.h"
|
||||
|
||||
// from GCC
|
||||
namespace std
|
||||
{
|
||||
template<class _E>
|
||||
class initializer_list
|
||||
{
|
||||
public:
|
||||
typedef _E value_type;
|
||||
typedef const _E& reference;
|
||||
typedef const _E& const_reference;
|
||||
typedef size_t size_type;
|
||||
typedef const _E* iterator;
|
||||
typedef const _E* const_iterator;
|
||||
|
||||
private:
|
||||
iterator _M_array;
|
||||
size_type _M_len;
|
||||
|
||||
constexpr initializer_list(const_iterator __a, size_type __l)
|
||||
: _M_array(__a), _M_len(__l) { }
|
||||
|
||||
public:
|
||||
constexpr initializer_list() noexcept
|
||||
: _M_array(0), _M_len(0) { }
|
||||
|
||||
constexpr size_type
|
||||
size() const noexcept { return _M_len; }
|
||||
|
||||
constexpr const_iterator
|
||||
begin() const noexcept { return _M_array; }
|
||||
|
||||
constexpr const_iterator
|
||||
end() const noexcept { return begin() + size(); }
|
||||
};
|
||||
|
||||
template<class _Tp>
|
||||
constexpr const _Tp*
|
||||
begin(initializer_list<_Tp> __ils) noexcept
|
||||
{ return __ils.begin(); }
|
||||
|
||||
template<class _Tp>
|
||||
constexpr const _Tp*
|
||||
end(initializer_list<_Tp> __ils) noexcept
|
||||
{ return __ils.end(); }
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
using CUtlInitializerList = std::initializer_list<T>;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,6 +0,0 @@
|
||||
#ifndef TIER1_UTL_STRING_H
|
||||
#define TIER1_UTL_STRING_H
|
||||
|
||||
#include "tier1/utlvector.h"
|
||||
|
||||
#endif
|
||||
@@ -1,25 +0,0 @@
|
||||
//================= Copyright kotofyt, All rights reserved ==================//
|
||||
// Purpose: Mutexes for C++
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef TIER1_UTL_MUTEX_H
|
||||
#define TIER1_UTL_MUTEX_H
|
||||
|
||||
#include "pthread.h"
|
||||
|
||||
class CUtlLock
|
||||
{
|
||||
public:
|
||||
CUtlLock();
|
||||
~CUtlLock();
|
||||
|
||||
CUtlLock(const CUtlLock&) = delete;
|
||||
CUtlLock& operator=(const CUtlLock&) = delete;
|
||||
|
||||
void Lock();
|
||||
void Unlock();
|
||||
private:
|
||||
pthread_mutex_t m_lock;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,275 +0,0 @@
|
||||
//================= Copyright kotofyt, All rights reserved ==================//
|
||||
// Purpose: Own implementation of string.
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef TIER1_UTL_STRING_H
|
||||
#define TIER1_UTL_STRING_H
|
||||
|
||||
#include "tier1/utlvector.h"
|
||||
#include "tier0/lib.h"
|
||||
#include "stdarg.h"
|
||||
|
||||
class CUtlString {
|
||||
public:
|
||||
CUtlString( void );
|
||||
CUtlString( const char *psz, ... );
|
||||
CUtlString( const CUtlString &sz );
|
||||
|
||||
void AppendTail( const char *psz );
|
||||
void AppendTail( char ch );
|
||||
void AppendHead( const char *psz );
|
||||
void AppendHead( char ch );
|
||||
void AppendAt( size_t nPosition, const char *psz );
|
||||
|
||||
void RemoveTail( size_t nCount );
|
||||
void RemoveHead( size_t nCount );
|
||||
void RemoveAt( size_t nPosition, size_t nCount );
|
||||
|
||||
CUtlString GetFileName();
|
||||
CUtlString GetFileExtension();
|
||||
CUtlString GetDirectory();
|
||||
CUtlString RemoveHeadFile();
|
||||
|
||||
char *GetString( void );
|
||||
size_t GetLenght( void );
|
||||
operator char*( void );
|
||||
operator CUtlVector<char>&( void );
|
||||
CUtlString& operator=(const CUtlString &sz);
|
||||
bool operator==(const char* psz);
|
||||
bool operator!=(const char* psz);
|
||||
bool operator==(CUtlString& string);
|
||||
bool operator!=(CUtlString& string);
|
||||
private:
|
||||
CUtlVector<char> m_data = 0;
|
||||
};
|
||||
inline CUtlString::CUtlString( void )
|
||||
{
|
||||
m_data.Reserve(1);
|
||||
m_data[0]=0;
|
||||
}
|
||||
|
||||
inline CUtlString::CUtlString( const char *szFormat, ... )
|
||||
{
|
||||
if (szFormat == 0)
|
||||
{
|
||||
m_data.Reserve(1);
|
||||
m_data[0]=0;
|
||||
return;
|
||||
}
|
||||
va_list vlArgs;
|
||||
va_start(vlArgs, szFormat);
|
||||
va_list vlArgs2;
|
||||
va_copy(vlArgs2, vlArgs);
|
||||
size_t nSize = V_vsnprintf(NULL, 0, szFormat, vlArgs2);
|
||||
m_data.Reserve(nSize + 1);
|
||||
va_end(vlArgs2);
|
||||
V_vsnprintf(m_data.GetData(), nSize + 1, szFormat, vlArgs);
|
||||
m_data.Resize(nSize + 1);
|
||||
va_end(vlArgs);
|
||||
}
|
||||
|
||||
inline CUtlString::CUtlString( const CUtlString &sz )
|
||||
{
|
||||
m_data = sz.m_data;
|
||||
};
|
||||
|
||||
inline void CUtlString::AppendTail( const char *psz )
|
||||
{
|
||||
m_data.Resize(V_strlen(m_data.GetData()));
|
||||
m_data.AppendTail(psz,V_strlen(psz));
|
||||
m_data.Reserve(m_data.GetSize()+1);
|
||||
m_data[m_data.GetSize()] = 0;
|
||||
}
|
||||
|
||||
inline void CUtlString::AppendHead( const char *psz )
|
||||
{
|
||||
m_data.AppendHead(psz,V_strlen(psz));
|
||||
}
|
||||
|
||||
inline void CUtlString::AppendTail( char ch )
|
||||
{
|
||||
m_data.Resize(V_strlen(m_data.GetData()));
|
||||
m_data.AppendTail(ch);
|
||||
m_data.Reserve(m_data.GetSize()+1);
|
||||
m_data[m_data.GetSize()] = 0;
|
||||
}
|
||||
|
||||
inline void CUtlString::AppendHead( char ch )
|
||||
{
|
||||
m_data.AppendHead(ch);
|
||||
}
|
||||
inline void CUtlString::AppendAt( size_t nPosition, const char *psz )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline void CUtlString::RemoveTail( size_t nCount )
|
||||
{
|
||||
m_data.RemoveTail(nCount);
|
||||
m_data[m_data.GetSize()-1] = 0;
|
||||
}
|
||||
|
||||
inline void CUtlString::RemoveHead( size_t nCount )
|
||||
{
|
||||
m_data.RemoveHead(nCount);
|
||||
}
|
||||
|
||||
inline void CUtlString::RemoveAt( size_t nPosition, size_t nCount )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline CUtlString CUtlString::GetFileName()
|
||||
{
|
||||
CUtlString szFileName = GetString();
|
||||
if (GetLenght() == 0)
|
||||
return "";
|
||||
|
||||
char *pLast = &m_data[GetLenght()-1];
|
||||
while (pLast != m_data.GetData())
|
||||
{
|
||||
if (*pLast=='/')
|
||||
{
|
||||
pLast++;
|
||||
break;
|
||||
}
|
||||
pLast--;
|
||||
}
|
||||
|
||||
return pLast;
|
||||
}
|
||||
|
||||
inline CUtlString CUtlString::GetFileExtension()
|
||||
{
|
||||
CUtlString szFileName = GetString();
|
||||
|
||||
char *pLast = &m_data[GetLenght()-1];
|
||||
while (pLast != m_data.GetData())
|
||||
{
|
||||
if (*pLast=='.')
|
||||
break;
|
||||
if (*pLast=='/')
|
||||
return NULL;
|
||||
pLast--;
|
||||
}
|
||||
|
||||
return pLast+1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline CUtlString CUtlString::GetDirectory()
|
||||
{
|
||||
if (GetLenght() == 0)
|
||||
return NULL;
|
||||
size_t iNumDeleted = 0;
|
||||
char *pLast = &m_data[GetLenght()-1];
|
||||
CUtlString szDirectory = GetString();
|
||||
while (pLast != m_data.GetData())
|
||||
{
|
||||
if (*pLast=='/')
|
||||
{
|
||||
iNumDeleted++;
|
||||
break;
|
||||
}
|
||||
pLast--;
|
||||
iNumDeleted++;
|
||||
}
|
||||
|
||||
szDirectory.RemoveTail(iNumDeleted);
|
||||
|
||||
return szDirectory;
|
||||
}
|
||||
|
||||
inline CUtlString CUtlString::RemoveHeadFile()
|
||||
{
|
||||
size_t iLenght = GetLenght();
|
||||
size_t iNumDeleted = 0;
|
||||
char *pc = GetString();
|
||||
CUtlString szDirectory = pc;
|
||||
|
||||
if (GetLenght() == 0)
|
||||
return NULL;
|
||||
while ( iNumDeleted < iLenght )
|
||||
{
|
||||
if (*pc == '/')
|
||||
goto remove_slashes;
|
||||
pc++;
|
||||
iNumDeleted++;
|
||||
}
|
||||
return NULL;
|
||||
remove_slashes:
|
||||
while ( iNumDeleted < iLenght )
|
||||
{
|
||||
if (*pc != '/')
|
||||
{
|
||||
szDirectory.RemoveHead(iNumDeleted);
|
||||
return szDirectory;
|
||||
}
|
||||
pc++;
|
||||
iNumDeleted++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline char *CUtlString::GetString( void )
|
||||
{
|
||||
return m_data.GetData();
|
||||
}
|
||||
|
||||
inline size_t CUtlString::GetLenght( void )
|
||||
{
|
||||
return V_strlen(GetString());
|
||||
}
|
||||
|
||||
inline CUtlString::operator char*( void )
|
||||
{
|
||||
return GetString();
|
||||
}
|
||||
|
||||
inline CUtlString::operator CUtlVector<char>&( void )
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
inline CUtlString &CUtlString::operator=(const CUtlString &sz)
|
||||
{
|
||||
if (this != &sz)
|
||||
{
|
||||
m_data = sz.m_data;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool CUtlString::operator==(const char *psz)
|
||||
{
|
||||
if (psz==0)
|
||||
psz = "";
|
||||
if (!V_strcmp(GetString(), psz))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool CUtlString::operator!=(const char *psz)
|
||||
{
|
||||
if (psz==0)
|
||||
psz = "";
|
||||
if (!V_strcmp(GetString(), psz))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool CUtlString::operator==(CUtlString &string)
|
||||
{
|
||||
if (!V_strcmp(GetString(), string.GetString()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool CUtlString::operator!=(CUtlString &string)
|
||||
{
|
||||
if (!V_strcmp(GetString(), string.GetString()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
@@ -1,447 +0,0 @@
|
||||
//================= Copyright kotofyt, All rights reserved ==================//
|
||||
// Purpose: Own implementation of vectors, it is better to use them in local
|
||||
// namespaces for own .
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef TIER1_UTL_VECTOR_H
|
||||
#define TIER1_UTL_VECTOR_H
|
||||
|
||||
#include "tier0/lib.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
#include "tier1/utlinitlist.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Basic vector implementation. There isn't much in them but they work.
|
||||
//-----------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
class CUtlVector
|
||||
{
|
||||
public:
|
||||
CUtlVector( void );
|
||||
CUtlVector( size_t nSize );
|
||||
CUtlVector( CUtlInitializerList<T> initalizerList );
|
||||
CUtlVector( const CUtlVector &vector );
|
||||
~CUtlVector();
|
||||
|
||||
void AppendHead( const T &data );
|
||||
void AppendHead( const T *pData, size_t n );
|
||||
void AppendTail( const T &data );
|
||||
void AppendTail( const T *data, size_t n );
|
||||
void AppendAt( size_t nIndex, const T &data );
|
||||
void AppendAt( size_t nIndex, const T *data, size_t n );
|
||||
|
||||
void RemoveHead();
|
||||
void RemoveHead( size_t n );
|
||||
void RemoveTail();
|
||||
void RemoveTail( size_t n );
|
||||
void RemoveAt( size_t nIndex );
|
||||
void RemoveAt( size_t nIndex, size_t n );
|
||||
|
||||
T *GetData( void );
|
||||
size_t GetSize( void );
|
||||
void Resize( size_t nSize, size_t nDataOffset = 0 );
|
||||
void Reserve( size_t nSize, size_t nDataOffset = 0 );
|
||||
|
||||
T &operator[]( size_t nIndex );
|
||||
T &operator[]( size_t nIndex ) const;
|
||||
CUtlVector<T> &operator=(const CUtlVector<T> &vec);
|
||||
|
||||
// Iterator stuff
|
||||
// Do we really need it?
|
||||
struct Iterator {
|
||||
T *m_pCurrent;
|
||||
Iterator( T *pCurrent ) : m_pCurrent(pCurrent) {}
|
||||
T& operator*( void ) const { return *m_pCurrent;}
|
||||
Iterator& operator++( void ) {
|
||||
++m_pCurrent;
|
||||
return *this;
|
||||
}
|
||||
bool operator!=( const Iterator& other ) const
|
||||
{
|
||||
return m_pCurrent != other.m_pCurrent;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Iterator begin( void ) const
|
||||
{
|
||||
return Iterator((T*)m_data.GetMemory());
|
||||
}
|
||||
Iterator end( void ) const
|
||||
{
|
||||
return Iterator((T*)m_data.GetMemory()+m_nSize);
|
||||
}
|
||||
|
||||
private:
|
||||
size_t m_nSize = 0;
|
||||
CUtlResizableBuffer<T> m_data;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//----------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
CUtlVector<T>::CUtlVector( void )
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//----------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
CUtlVector<T>::CUtlVector( size_t nSize )
|
||||
{
|
||||
m_data.Resize(nSize);
|
||||
V_memset(m_data.GetMemory(),0,m_data.GetSize()*sizeof(T));
|
||||
m_nSize = nSize;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Fancy constructor
|
||||
//----------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
CUtlVector<T>::CUtlVector( CUtlInitializerList<T> initalizerList )
|
||||
{
|
||||
m_data.Resize(initalizerList.size());
|
||||
V_memset(m_data.GetMemory(),0,m_data.GetSize()*sizeof(T));
|
||||
m_nSize = m_data.GetSize();
|
||||
for (size_t i = 0; i<m_nSize; i++)
|
||||
m_data[i] = initalizerList.begin()[i];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
CUtlVector<T>::CUtlVector( const CUtlVector& vector )
|
||||
{
|
||||
*this = vector;
|
||||
}
|
||||
template<typename T>
|
||||
CUtlVector<T>::~CUtlVector()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CUtlVector<T>::AppendHead( const T &data )
|
||||
{
|
||||
AppendHead(&data,1);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CUtlVector<T>::AppendHead( const T *pData, size_t n )
|
||||
{
|
||||
size_t nOldSize = m_nSize;
|
||||
m_data.Resize(m_nSize+n);
|
||||
for (size_t i = nOldSize; i > 0; --i)
|
||||
{
|
||||
new (&m_data[i + n - 1]) T(m_data[i - 1]);
|
||||
m_data[i - 1].~T();
|
||||
}
|
||||
for (size_t i = 0; i < n; ++i)
|
||||
{
|
||||
new (&m_data[i]) T(pData[i]);
|
||||
}
|
||||
m_nSize+=n;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CUtlVector<T>::AppendTail( const T &data )
|
||||
{
|
||||
AppendTail(&data,1);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CUtlVector<T>::AppendTail( const T *pData, size_t n )
|
||||
{
|
||||
m_data.Resize(m_data.GetSize()+n);
|
||||
for ( size_t i = 0; i < n; i++ )
|
||||
new (&m_data[i+m_nSize]) T(pData[i]);
|
||||
m_nSize+=n;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CUtlVector<T>::AppendAt( size_t nIndex, const T &data )
|
||||
{
|
||||
AppendAt(nIndex, &data, 1);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CUtlVector<T>::AppendAt( size_t nIndex, const T *pData, size_t n )
|
||||
{
|
||||
size_t nOldSize = m_nSize;
|
||||
m_data.Resize(m_nSize+n);
|
||||
for (size_t i = nOldSize; i > nIndex; --i)
|
||||
{
|
||||
new (&m_data[i + n - 1]) T(m_data[i - 1]);
|
||||
m_data[i - 1].~T();
|
||||
}
|
||||
for (size_t i = 0; i < n; ++i)
|
||||
{
|
||||
new (&m_data[nIndex + i]) T(pData[i]);
|
||||
}
|
||||
m_nSize+=n;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CUtlVector<T>::RemoveHead()
|
||||
{
|
||||
RemoveHead( 1 );
|
||||
}
|
||||
template<typename T>
|
||||
void CUtlVector<T>::RemoveHead( size_t n )
|
||||
{
|
||||
RemoveAt(0, n);
|
||||
}
|
||||
template<typename T>
|
||||
void CUtlVector<T>::RemoveTail()
|
||||
{
|
||||
RemoveTail( 1 );
|
||||
}
|
||||
template<typename T>
|
||||
void CUtlVector<T>::RemoveTail( size_t n )
|
||||
{
|
||||
if (n > m_nSize)
|
||||
n = m_nSize;
|
||||
m_data.Resize(m_nSize-n);
|
||||
m_nSize -= n;
|
||||
}
|
||||
template<typename T>
|
||||
void CUtlVector<T>::RemoveAt( size_t nIndex )
|
||||
{
|
||||
RemoveAt( nIndex, 1 );
|
||||
}
|
||||
template<typename T>
|
||||
void CUtlVector<T>::RemoveAt( size_t nIndex, size_t n )
|
||||
{
|
||||
if ( nIndex >= m_nSize )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ( nIndex + n > m_nSize )
|
||||
{
|
||||
n = m_nSize - nIndex;
|
||||
}
|
||||
for ( size_t i = nIndex; i < nIndex + n; i++ )
|
||||
{
|
||||
m_data[i].~T();
|
||||
}
|
||||
|
||||
size_t nElementsToMove = m_nSize - (nIndex + n);
|
||||
for ( size_t i = 0; i < nElementsToMove; i++ )
|
||||
{
|
||||
new (&m_data[nIndex + i]) T(m_data[nIndex + n + i]);
|
||||
m_data[nIndex + n + i].~T();
|
||||
}
|
||||
m_nSize -= n;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T *CUtlVector<T>::GetData( void )
|
||||
{
|
||||
return (T*)m_data.GetMemory();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
size_t CUtlVector<T>::GetSize( void )
|
||||
{
|
||||
return m_nSize;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CUtlVector<T>::Resize( size_t nSize, size_t nDataOffset )
|
||||
{
|
||||
m_data.Resize(nSize, nDataOffset);
|
||||
m_nSize = nSize;
|
||||
}
|
||||
template<typename T>
|
||||
void CUtlVector<T>::Reserve( size_t nSize, size_t nDataOffset )
|
||||
{
|
||||
m_data.Resize(nSize, nDataOffset);
|
||||
}
|
||||
template<typename T>
|
||||
CUtlVector<T> &CUtlVector<T>::operator=(const CUtlVector<T> &vec)
|
||||
{
|
||||
if (this != &vec)
|
||||
{
|
||||
m_nSize = vec.m_nSize;
|
||||
m_data = vec.m_data;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T &CUtlVector<T>::operator[]( size_t nIndex )
|
||||
{
|
||||
return m_data[nIndex];
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T &CUtlVector<T>::operator[]( size_t nIndex ) const
|
||||
{
|
||||
return m_data[nIndex];
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Self referencing arrays are quite cool.
|
||||
// They allow to append stuff in head and tail of the array and use less memory
|
||||
// copying. Downside is their indexing is O(n/2)
|
||||
//
|
||||
// Implements the same stuff as CUtlVector does.
|
||||
//-----------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
class CUtlSelfReferencingVector
|
||||
{
|
||||
private:
|
||||
template<typename A>
|
||||
struct SelfData_t;
|
||||
public:
|
||||
CUtlSelfReferencingVector();
|
||||
~CUtlSelfReferencingVector();
|
||||
|
||||
void AppendHead( const T& data );
|
||||
void AppendTail( const T& data );
|
||||
void AppendAt( size_t nIndex, const T& data );
|
||||
|
||||
void RemoveHead( void );
|
||||
void RemoveTail( void );
|
||||
void RemoveAt( size_t nIndex );
|
||||
|
||||
T &GetFirst();
|
||||
T &GetLast();
|
||||
|
||||
size_t GetSize();
|
||||
|
||||
T operator[]( size_t nIndex );
|
||||
T& operator[]( size_t nIndex ) const;
|
||||
|
||||
|
||||
// Iterator stuff
|
||||
struct Iterator {
|
||||
SelfData_t<T> *m_pCurrent;
|
||||
Iterator( SelfData_t<T> *pCurrent ) : m_pCurrent(pCurrent) {}
|
||||
T& operator*( void ) const { return m_pCurrent->data;}
|
||||
Iterator& operator++( void ) {
|
||||
if (m_pCurrent) m_pCurrent = m_pCurrent->pNext;
|
||||
return *this;
|
||||
}
|
||||
bool operator!=( const Iterator& other ) const
|
||||
{
|
||||
return m_pCurrent != other.m_pCurrent;
|
||||
}
|
||||
};
|
||||
|
||||
Iterator begin( void ) const
|
||||
{
|
||||
return Iterator(m_pHead);
|
||||
}
|
||||
Iterator end( void ) const
|
||||
{
|
||||
return Iterator(NULL);
|
||||
}
|
||||
|
||||
private:
|
||||
size_t m_nSize = 0;
|
||||
|
||||
template<typename A>
|
||||
struct SelfData_t
|
||||
{
|
||||
SelfData_t *pNext = NULL;
|
||||
SelfData_t *pPrev = NULL;
|
||||
A data;
|
||||
};
|
||||
SelfData_t<T> *m_pTail = NULL;
|
||||
SelfData_t<T> *m_pHead = NULL;
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//----------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
CUtlSelfReferencingVector<T>::CUtlSelfReferencingVector()
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Destructor
|
||||
//----------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
CUtlSelfReferencingVector<T>::~CUtlSelfReferencingVector()
|
||||
{
|
||||
SelfData_t<T> *pNext = NULL;
|
||||
for (SelfData_t<T> *pCurrent = m_pHead; pCurrent; pCurrent=pNext)
|
||||
{
|
||||
pNext = pCurrent->pNext;
|
||||
delete pCurrent;
|
||||
}
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Inserts new element in the start of the vector.
|
||||
//----------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
void CUtlSelfReferencingVector<T>::AppendHead( const T& data )
|
||||
{
|
||||
SelfData_t<T>* pData = new SelfData_t<T>;
|
||||
pData->data = data;
|
||||
pData->pNext = m_pHead;
|
||||
if (m_pHead)
|
||||
m_pHead->pPrev = pData;
|
||||
pData->pPrev = 0;
|
||||
m_pHead = pData;
|
||||
if (m_pTail == 0)
|
||||
m_pTail = m_pHead;
|
||||
m_nSize++;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Inserts new element in the end of the vector.
|
||||
//----------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
void CUtlSelfReferencingVector<T>::AppendTail( const T& data )
|
||||
{
|
||||
SelfData_t<T>* pData = new SelfData_t<T>;
|
||||
pData->data = data;
|
||||
if (m_pTail)
|
||||
m_pTail->pNext = pData;
|
||||
pData->pPrev = m_pTail;
|
||||
m_pTail = pData;
|
||||
if (m_pHead == 0)
|
||||
m_pHead = m_pTail;
|
||||
|
||||
m_nSize++;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Removes element in the start of the vector.
|
||||
//----------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
void CUtlSelfReferencingVector<T>::RemoveHead( void )
|
||||
{
|
||||
if (m_pHead == m_pTail)
|
||||
m_pHead = 0;
|
||||
};
|
||||
//----------------------------------------------------------------------------
|
||||
// Removes element in the end of the vector.
|
||||
//----------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
void CUtlSelfReferencingVector<T>::RemoveTail( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T &CUtlSelfReferencingVector<T>::GetFirst()
|
||||
{
|
||||
return m_pHead->data;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T &CUtlSelfReferencingVector<T>::GetLast()
|
||||
{
|
||||
return m_pTail->data;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,33 +0,0 @@
|
||||
#ifndef TIER2_INI_H
|
||||
#define TIER2_INI_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "tier1/utlvector.h"
|
||||
|
||||
abstract_class IINISection
|
||||
{
|
||||
public:
|
||||
virtual bool GetBoolValue( const char *szKeyName ) = 0;
|
||||
virtual int GetIntValue( const char *szKeyName ) = 0;
|
||||
virtual const char *GetStringValue( const char *szKeyName ) = 0;
|
||||
virtual CUtlString GetUTLStringValue( const char *szKeyName ) = 0;
|
||||
};
|
||||
|
||||
abstract_class IINIFile
|
||||
{
|
||||
public:
|
||||
virtual IINISection *GetSection( const char *szSectionName ) = 0;
|
||||
};
|
||||
|
||||
abstract_class IINIManager
|
||||
{
|
||||
public:
|
||||
virtual IINIFile *ReadFile( const char *psz ) = 0;
|
||||
virtual IINIFile *ReadString( const char *psz ) = 0;
|
||||
virtual void ReleaseFile( IINIFile *pFile ) = 0;
|
||||
};
|
||||
|
||||
IINIManager *INIManager();
|
||||
|
||||
#endif
|
||||
@@ -1,87 +0,0 @@
|
||||
#ifndef TIER2_JSON_H
|
||||
#define TIER2_JSON_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/utlstring.h"
|
||||
|
||||
class IJSONObject;
|
||||
class IJSONArray;
|
||||
class IJSONValue;
|
||||
|
||||
enum EJSONParameterType
|
||||
{
|
||||
JSON_PARAMETER_NULL,
|
||||
JSON_PARAMETER_STRING,
|
||||
JSON_PARAMETER_NUMBER,
|
||||
JSON_PARAMETER_BOOLEAN,
|
||||
JSON_PARAMETER_ARRAY,
|
||||
JSON_PARAMETER_OBJECT,
|
||||
};
|
||||
|
||||
enum EJSONParameterNotes
|
||||
{
|
||||
JSON_PARAMETER_NOTE_NONE = 0,
|
||||
JSON_PARAMETER_NOTE_BINARY,
|
||||
};
|
||||
|
||||
abstract_class IJSONArray
|
||||
{
|
||||
public:
|
||||
virtual uint32_t GetCount() = 0;
|
||||
virtual IJSONValue *GetParameter( uint32_t i ) = 0;
|
||||
|
||||
virtual void SetArray( uint32_t uCount, IJSONValue **ppValues ) = 0;
|
||||
|
||||
virtual void CopyTo( IJSONArray *pObject ) = 0;
|
||||
virtual void Free() = 0;
|
||||
};
|
||||
|
||||
abstract_class IJSONValue
|
||||
{
|
||||
public:
|
||||
virtual EJSONParameterType GetType( void ) = 0;
|
||||
virtual
|
||||
virtual const char *GetStringValue() = 0;
|
||||
virtual float GetNumberValue() = 0;
|
||||
virtual bool GetBooleanValue() = 0;
|
||||
virtual IJSONArray *GetArray() = 0;
|
||||
virtual IJSONObject *GetObject() = 0;
|
||||
|
||||
virtual void MakeNULL() = 0;
|
||||
virtual void SetStringValue( const char *szString ) = 0;
|
||||
virtual void SetNumberValue( float fValue ) = 0;
|
||||
virtual void SetBooleanValue( bool bValue ) = 0;
|
||||
virtual void SetArrayValue( IJSONArray *pValue ) = 0;
|
||||
virtual void SetObjectValue( IJSONObject *pValue ) = 0;
|
||||
|
||||
virtual void CopyTo( IJSONValue *pObject ) = 0;
|
||||
virtual void Free() = 0;
|
||||
};
|
||||
|
||||
abstract_class IJSONObject
|
||||
{
|
||||
public:
|
||||
virtual IJSONValue *GetValue( const char *szName ) = 0;
|
||||
virtual void SetValue( const char *szName, IJSONValue *pValue ) = 0;
|
||||
|
||||
virtual void CopyTo( IJSONObject *pObject ) = 0;
|
||||
virtual void Free() = 0;
|
||||
};
|
||||
|
||||
abstract_class IJSONManager
|
||||
{
|
||||
public:
|
||||
virtual IJSONObject *CreateObject( ) = 0;
|
||||
virtual void FreeObject( IJSONObject *pObject ) = 0;
|
||||
virtual IJSONArray *CreateArray( ) = 0;
|
||||
virtual void FreeArray( IJSONArray *pArray ) = 0;
|
||||
virtual IJSONValue *CreateValue( ) = 0;
|
||||
virtual void FreeValue( IJSONValue *pValue ) = 0;
|
||||
|
||||
virtual IJSONValue *ReadString( const char *szString ) = 0;
|
||||
virtual CUtlString WriteString( IJSONValue *pValue ) = 0;
|
||||
};
|
||||
|
||||
IJSONManager *JSONManager();
|
||||
|
||||
#endif
|
||||
@@ -1,13 +0,0 @@
|
||||
#ifndef TIER2_PLIST_H
|
||||
#define TIER2_PLIST_H
|
||||
|
||||
#include "tier2/fileformats/json.h"
|
||||
|
||||
abstract_class IPropertyListManager
|
||||
{
|
||||
public:
|
||||
virtual IJSONObject *ReadString( const char *psz ) = 0;
|
||||
};
|
||||
|
||||
IPropertyListManager *PropertyListManager();
|
||||
#endif
|
||||
@@ -1,69 +0,0 @@
|
||||
#ifndef TIER2_XML_H
|
||||
#define TIER2_XML_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/utlstring.h"
|
||||
|
||||
struct XMLParam_t
|
||||
{
|
||||
CUtlString m_szName;
|
||||
CUtlString m_szValue;
|
||||
};
|
||||
|
||||
enum EXMLObjectType
|
||||
{
|
||||
XML_OBJECT_ELEMENT,
|
||||
XML_OBJECT_TEXT,
|
||||
XML_OBJECT_COMMENT,
|
||||
XML_OBJECT_CDATA,
|
||||
XML_OBJECT_PROCESSING_INSTRUCTION,
|
||||
XML_OBJECT_DOCUMENT_TYPE,
|
||||
};
|
||||
|
||||
abstract_class IXMLObject
|
||||
{
|
||||
public:
|
||||
virtual EXMLObjectType GetType() = 0;
|
||||
virtual const char *GetValue() = 0;
|
||||
virtual void SetType( EXMLObjectType eType ) = 0;
|
||||
virtual void SetValue( const char *psz ) = 0;
|
||||
|
||||
virtual CUtlVector<XMLParam_t> &GetParams() = 0;
|
||||
|
||||
virtual CUtlVector<IXMLObject*> &GetChildren() = 0;
|
||||
|
||||
virtual void Free() = 0;
|
||||
|
||||
inline IXMLObject *FindFirstTag( const char *szName )
|
||||
{
|
||||
for ( auto &c: GetChildren() )
|
||||
{
|
||||
if ( c->GetType() != XML_OBJECT_ELEMENT ) continue;
|
||||
if ( V_strcmp(c->GetValue(), szName) ) continue;
|
||||
return c;
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
};
|
||||
|
||||
struct XMLFile_t
|
||||
{
|
||||
IXMLObject *m_pRoot;
|
||||
CUtlString m_szRootObjectName;
|
||||
CUtlString m_szFPI;
|
||||
CUtlString m_szURI;
|
||||
};
|
||||
|
||||
abstract_class IXMLManager
|
||||
{
|
||||
public:
|
||||
virtual XMLFile_t ReadString( const char *szData ) = 0;
|
||||
virtual CUtlString WriteString( IXMLObject *pObject ) = 0;
|
||||
|
||||
virtual IXMLObject *CreateObject() = 0;
|
||||
virtual void FreeObject( IXMLObject *pObject ) = 0;
|
||||
};
|
||||
|
||||
IXMLManager *XMLManager();
|
||||
|
||||
#endif
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef APP_SYSTEM_H
|
||||
#define APP_SYSTEM_H
|
||||
|
||||
#include "tier1/interface.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// App system is a module which has different applications based on the user's system.
|
||||
// For example rendering could use either Vulkan or Metal based on the system.
|
||||
//----------------------------------------------------------------------------
|
||||
abstract_class IAppSystem
|
||||
{
|
||||
public:
|
||||
virtual void Init() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,73 +0,0 @@
|
||||
#ifndef FILESYSTEM_H
|
||||
#define FILESYSTEM_H
|
||||
|
||||
#include "iappsystem.h"
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/utlbuffer.h"
|
||||
|
||||
enum EFileMode
|
||||
{
|
||||
FILEMODE_READ = 0x01,
|
||||
FILEMODE_WRITE = 0x02,
|
||||
FILEMODE_APPEND = 0x04,
|
||||
};
|
||||
|
||||
enum ESeekMode
|
||||
{
|
||||
SEEKMODE_RELATIVE_CURRENT,
|
||||
SEEKMODE_RELATIVE_START,
|
||||
SEEKMODE_RELATIVE_END,
|
||||
};
|
||||
|
||||
abstract_class IFileSystem;
|
||||
|
||||
class IFileHandle
|
||||
{
|
||||
public:
|
||||
IFileSystem *m_pFileSystem;
|
||||
};
|
||||
|
||||
abstract_class IDirectoryHandle
|
||||
{
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// IFileSystem is an app system which manages files, could have different
|
||||
// file systems etc. Because of that there is base file system which manages
|
||||
// others. PAK files are opened first, then mounted stuff comes second and
|
||||
// host's system last.
|
||||
//----------------------------------------------------------------------------
|
||||
abstract_class IFileSystem: public IAppSystem
|
||||
{
|
||||
public:
|
||||
virtual IFileHandle *Open( const char *szFileName, int eOpCode ) = 0;
|
||||
virtual size_t Write( IFileHandle *pFile, const void *pData, size_t nDataSize ) = 0;
|
||||
virtual size_t Read( IFileHandle *pFile, void *pData, size_t nDataSize ) = 0;
|
||||
|
||||
virtual size_t Seek( IFileHandle *pFile, ESeekMode eSeekMode, size_t nOffset ) = 0;
|
||||
virtual size_t Tell( IFileHandle *pFile ) = 0;
|
||||
virtual size_t Size( IFileHandle *pFile ) = 0;
|
||||
|
||||
virtual void Close( IFileHandle *pFile ) = 0;
|
||||
|
||||
// Some cool stuff
|
||||
virtual CUtlBuffer<unsigned char> Read( IFileHandle *pFile ) = 0;
|
||||
|
||||
// Leaks memory
|
||||
// Should be cleaned by the user
|
||||
virtual const char *ReadString( IFileHandle *pFile ) = 0;
|
||||
|
||||
// Directory stuff
|
||||
virtual IDirectoryHandle *OpenDir( const char *szDirName ) = 0;
|
||||
virtual void CloseDir( IDirectoryHandle *pDir ) = 0;
|
||||
|
||||
IFileSystem *m_pNext;
|
||||
|
||||
void RegisterFileSystem();
|
||||
};
|
||||
|
||||
#define FILESYSTEM_INTERFACE_VERSION "FileSystem001"
|
||||
|
||||
extern IFileSystem *filesystem;
|
||||
|
||||
#endif
|
||||
@@ -1,29 +0,0 @@
|
||||
#ifndef TIER2_TOKENIZER_H
|
||||
#define TIER2_TOKENIZER_H
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "tier1/utlvector.h"
|
||||
|
||||
struct Token_t
|
||||
{
|
||||
CUtlString m_szValue;
|
||||
bool m_bIsQuoted;
|
||||
|
||||
uint32_t m_iLine;
|
||||
uint32_t m_iCharacter;
|
||||
};
|
||||
|
||||
typedef bool( *IsAlphabetSymbolFn )( char c );
|
||||
|
||||
struct TokenizeProperties_t
|
||||
{
|
||||
IsAlphabetSymbolFn m_pfnIsAlphabetSymbol;
|
||||
IsAlphabetSymbolFn m_pfnIsFirstAlphabetSymbol;
|
||||
bool m_bAllowSlashToContinueString;
|
||||
};
|
||||
|
||||
CUtlVector<Token_t> Tokenize( const char *szString );
|
||||
CUtlVector<Token_t> Tokenize( const char *szString, IsAlphabetSymbolFn pfnIsAlphabetSymbol );
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef BRB_LEXER_H
|
||||
#define BRB_LEXER_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
|
||||
abstract_class ILexerWord
|
||||
{
|
||||
public:
|
||||
virtual int GetType() = 0;
|
||||
};
|
||||
|
||||
abstract_class ILexer
|
||||
{
|
||||
public:
|
||||
virtual ILexerWord *ParseTokens( CUtlVector<Token_t> tokens ) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user