BVB Source Codes

CRYENGINE Show ScriptSerialize.h Source code

Return Download CRYENGINE: download ScriptSerialize.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /*************************************************************************
  4.    -------------------------------------------------------------------------
  5.    $Id$
  6.    $DateTime$
  7.    Description: Helper classes for implementing serialization in script
  8.  
  9.    -------------------------------------------------------------------------
  10.    History:
  11.    - 24:11:2004   11:30 : Created by Craig Tiller
  12.  
  13. *************************************************************************/
  14. #ifndef __SCRIPTSERIALIZE_H__
  15. #define __SCRIPTSERIALIZE_H__
  16.  
  17. #pragma once
  18.  
  19. #include <vector>
  20.  
  21. enum EScriptSerializeType
  22. {
  23.         eSST_Bool        = 'B',
  24.         eSST_Float       = 'f',
  25.         eSST_Int8        = 'b',
  26.         eSST_Int16       = 's',
  27.         eSST_Int32       = 'i',
  28.         eSST_String      = 'S',
  29.         eSST_EntityId    = 'E',
  30.         eSST_Void        = '0',
  31.         eSST_Vec3        = 'V',
  32.         eSST_StringTable = 'T'
  33. };
  34.  
  35. class CScriptSerialize
  36. {
  37. public:
  38.         bool ReadValue(const char* name, EScriptSerializeType type, TSerialize, IScriptTable*);
  39.         bool WriteValue(const char* name, EScriptSerializeType type, TSerialize, IScriptTable*);
  40.  
  41. private:
  42.         string m_tempString;
  43. };
  44.  
  45. class CScriptSerializeAny
  46. {
  47. public:
  48.         CScriptSerializeAny()
  49.                 : m_type(eSST_Void)
  50.         {
  51.                 m_buffer[0] = 0;
  52.         }
  53.         CScriptSerializeAny(EScriptSerializeType type);
  54.         CScriptSerializeAny(const CScriptSerializeAny&);
  55.         ~CScriptSerializeAny();
  56.         CScriptSerializeAny& operator=(const CScriptSerializeAny&);
  57.  
  58.         void SerializeWith(TSerialize, const char* name = 0);
  59.         bool   SetFromFunction(IFunctionHandler* pFH, int param);
  60.         void   PushFuncParam(IScriptSystem* pSS) const;
  61.         bool   CopyFromTable(SmartScriptTable& tbl, const char* name);
  62.         void   CopyToTable(SmartScriptTable& tbl, const char* name);
  63.         string DebugInfo() const;
  64.  
  65. private:
  66.         static const size_t  BUFFER_SIZE = sizeof(string) > sizeof(Vec3) ? sizeof(string) : sizeof(Vec3);
  67.         char                 m_buffer[BUFFER_SIZE];
  68.         EScriptSerializeType m_type;
  69.  
  70.         template<class T>
  71.         T* Ptr()
  72.         {
  73.                 CRY_ASSERT(BUFFER_SIZE >= sizeof(T));
  74.                 return reinterpret_cast<T*>(m_buffer);
  75.         }
  76.         template<class T>
  77.         const T* Ptr() const
  78.         {
  79.                 CRY_ASSERT(BUFFER_SIZE >= sizeof(T));
  80.                 return reinterpret_cast<const T*>(m_buffer);
  81.         }
  82. };
  83.  
  84. // this class helps provide a bridge between script and ISerialize
  85. class CScriptRMISerialize : public ISerializable
  86. {
  87. public:
  88.         CScriptRMISerialize(const char* format);
  89.  
  90.         void SerializeWith(TSerialize);
  91.         bool   SetFromFunction(IFunctionHandler* pFH, int firstParam);
  92.         void   PushFunctionParams(IScriptSystem* pSS);
  93.         string DebugInfo();
  94.  
  95. private:
  96.         typedef std::vector<CScriptSerializeAny> TValueVec;
  97.         TValueVec m_values;
  98. };
  99.  
  100. #endif
  101.  
downloadScriptSerialize.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top