diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /public/tier1/uniqueid.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'public/tier1/uniqueid.h')
| -rw-r--r-- | public/tier1/uniqueid.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/public/tier1/uniqueid.h b/public/tier1/uniqueid.h new file mode 100644 index 0000000..fd3fe26 --- /dev/null +++ b/public/tier1/uniqueid.h @@ -0,0 +1,56 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +// Utilities for globally unique IDs +//=============================================================================// + +#ifndef UNIQUEID_H +#define UNIQUEID_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "tier1/utlvector.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +struct UniqueId_t; +class CUtlBuffer; + + +//----------------------------------------------------------------------------- +// Defines a globally unique ID +//----------------------------------------------------------------------------- +struct UniqueId_t +{ + unsigned char m_Value[16]; +}; + + +//----------------------------------------------------------------------------- +// Methods related to unique ids +//----------------------------------------------------------------------------- +void CreateUniqueId( UniqueId_t *pDest ); +void InvalidateUniqueId( UniqueId_t *pDest ); +bool IsUniqueIdValid( const UniqueId_t &id ); +bool IsUniqueIdEqual( const UniqueId_t &id1, const UniqueId_t &id2 ); +void UniqueIdToString( const UniqueId_t &id, char *pBuf, int nMaxLen ); +bool UniqueIdFromString( UniqueId_t *pDest, const char *pBuf, int nMaxLen = 0 ); +void CopyUniqueId( const UniqueId_t &src, UniqueId_t *pDest ); +bool Serialize( CUtlBuffer &buf, const UniqueId_t &src ); +bool Unserialize( CUtlBuffer &buf, UniqueId_t &dest ); + +inline bool operator ==( const UniqueId_t& lhs, const UniqueId_t& rhs ) +{ + return !Q_memcmp( (void *)&lhs.m_Value[ 0 ], (void *)&rhs.m_Value[ 0 ], sizeof( lhs.m_Value ) ); +} + + +#endif // UNIQUEID_H + |