http and lots of formats
This commit is contained in:
16
public/appleauth/iauth.h
Normal file
16
public/appleauth/iauth.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef APPLE_AUTH_H
|
||||
#define APPLE_AUTH_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "tier2/iappsystem.h"
|
||||
|
||||
abstract_class IAppleAuth: public IAppSystem
|
||||
{
|
||||
public:
|
||||
virtual void SubmitLoginData( const char *szEmail, const char *szPassword ) = 0;
|
||||
virtual void Submit2FA( const char *szCode ) = 0;
|
||||
};
|
||||
|
||||
IAppleAuth *AppleAuth();
|
||||
|
||||
#endif
|
||||
@@ -3,11 +3,12 @@
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/utlvector.h"
|
||||
#include "tier1/utlstring.h"
|
||||
|
||||
struct HTTPHeaderParam_t
|
||||
{
|
||||
const char *m_szParamName;
|
||||
const char *m_szValue;
|
||||
CUtlString m_szParamName;
|
||||
CUtlString m_szValue;
|
||||
};
|
||||
|
||||
struct HTTPHeader_t
|
||||
@@ -21,21 +22,35 @@ struct HTTPResponse_t
|
||||
CUtlBuffer<HTTPHeaderParam_t> m_params;
|
||||
CUtlBuffer<char> m_message;
|
||||
uint32_t m_uCode;
|
||||
bool bIsValid;
|
||||
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 char *data ) = 0;
|
||||
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 ) = 0;
|
||||
virtual IHTTPClient *Connect( const char *szUrl, bool bSecure, uint16_t *pPort ) = 0;
|
||||
virtual void Disconnect( IHTTPClient *pClient ) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -54,6 +54,23 @@
|
||||
#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
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
#ifndef TIER2_JSON_H
|
||||
#define TIER2_JSON_H
|
||||
|
||||
#include "tier0/platform.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,
|
||||
};
|
||||
|
||||
abstract_class IJSONArray
|
||||
{
|
||||
public:
|
||||
virtual uint32_t GetCount() = 0;
|
||||
virtual IJSONObject *GetParameter( uint32_t i ) = 0;
|
||||
|
||||
virtual void SetArray( uint32_t uCount, IJSONValue *pValue ) = 0;
|
||||
|
||||
virtual void CopyTo( IJSONArray *pObject ) = 0;
|
||||
virtual void Free() = 0;
|
||||
};
|
||||
|
||||
abstract_class IJSONValue
|
||||
{
|
||||
public:
|
||||
virtual EJSONParameterType GetType( void ) = 0;
|
||||
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 IJSONObject *ReadString( const char *szString ) = 0;
|
||||
};
|
||||
|
||||
IJSONManager *JSONManager();
|
||||
|
||||
#endif
|
||||
|
||||
13
public/tier2/fileformats/plist.h
Normal file
13
public/tier2/fileformats/plist.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#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
|
||||
69
public/tier2/fileformats/xml.h
Normal file
69
public/tier2/fileformats/xml.h
Normal file
@@ -0,0 +1,69 @@
|
||||
#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
|
||||
21
public/tier2/tokenizer.h
Normal file
21
public/tier2/tokenizer.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#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( *fnIsAlphabetSymbol )( char c );
|
||||
CUtlVector<Token_t> Tokenize( const char *szString );
|
||||
CUtlVector<Token_t> Tokenize( const char *szString, fnIsAlphabetSymbol pfnIsAlphabetSymbol );
|
||||
|
||||
|
||||
#endif
|
||||
0
public/tier2/uuid.h
Normal file
0
public/tier2/uuid.h
Normal file
Reference in New Issue
Block a user