BVB Source Codes

CRYENGINE Show XMLCPB_BufferReader.h Source code

Return Download CRYENGINE: download XMLCPB_BufferReader.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /*************************************************************************
  4. *************************************************************************/
  5.  
  6. #pragma once
  7.  
  8. #ifndef XMLCPB_BUFFERREADER_H
  9.         #define XMLCPB_BUFFERREADER_H
  10.  
  11.         #include "../XMLCPB_Common.h"
  12.         #include <CryCore/Platform/IPlatformOS.h>
  13.  
  14. namespace XMLCPB {
  15.  
  16. class CReader;
  17.  
  18. struct SBufferReader
  19. {
  20.         explicit SBufferReader(IGeneralMemoryHeap* pHeap)
  21.                 : m_pHeap(pHeap)
  22.                 , m_pBuffer(NULL)
  23.                 , m_bufferSize(0)
  24.         {
  25.         }
  26.  
  27.         ~SBufferReader()
  28.         {
  29.                 if (m_pBuffer)
  30.                         m_pHeap->Free(m_pBuffer);
  31.         }
  32.  
  33.         inline const uint8* GetPointer(FlatAddr addr) const
  34.         {
  35.                 assert(addr < m_bufferSize);
  36.                 return &(m_pBuffer[addr]);
  37.         }
  38.  
  39.         inline void CopyTo(uint8* pDst, FlatAddr srcAddr, uint32 bytesToCopy) const
  40.         {
  41.                 assert(srcAddr < m_bufferSize);
  42.                 assert(srcAddr + bytesToCopy <= m_bufferSize);
  43.  
  44.                 memcpy(pDst, GetPointer(srcAddr), bytesToCopy);
  45.         }
  46.  
  47.         void ReadFromFile(CReader& Reader, IPlatformOS::ISaveReaderPtr& pOSSaveReader, uint32 readSize);
  48.         void ReadFromMemory(CReader& Reader, const uint8* pData, uint32 dataSize, uint32 readSize, uint32& outReadLoc);
  49.  
  50. private:
  51.         SBufferReader(const SBufferReader&);
  52.         SBufferReader& operator=(const SBufferReader&);
  53.  
  54. private:
  55.         _smart_ptr<IGeneralMemoryHeap> m_pHeap;
  56.         uint8*                         m_pBuffer;
  57.         size_t                         m_bufferSize;
  58. };
  59.  
  60. }  // end namespace
  61.  
  62. #endif
  63.  
downloadXMLCPB_BufferReader.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