BVB Source Codes

CRYENGINE Show XMLCPB_StringTableReader.cpp Source code

Return Download CRYENGINE: download XMLCPB_StringTableReader.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /*************************************************************************
  4. *************************************************************************/
  5.  
  6. #include "StdAfx.h"
  7. #include "XMLCPB_StringTableReader.h"
  8. #include "XMLCPB_Reader.h"
  9.  
  10. using namespace XMLCPB;
  11.  
  12. //////////////////////////////////////////////////////////////////////////
  13. CStringTableReader::CStringTableReader(IGeneralMemoryHeap* pHeap)
  14.         : m_buffer(pHeap)
  15.         , m_stringAddrs(NAlloc::GeneralHeapAlloc(pHeap))
  16. {
  17. }
  18.  
  19. //////////////////////////////////////////////////////////////////////////
  20. const char* CStringTableReader::GetString(StringID stringId) const
  21. {
  22.         assert(stringId < m_stringAddrs.size());
  23.         char* pString = (char*)(m_buffer.GetPointer(m_stringAddrs[stringId]));
  24.         return pString;
  25. }
  26.  
  27. //////////////////////////////////////////////////////////////////////////
  28.  
  29. void CStringTableReader::ReadFromFile(CReader& Reader, IPlatformOS::ISaveReaderPtr pOSSaveReader, const SFileHeader::SStringTable& headerInfo)
  30. {
  31.         assert(m_stringAddrs.empty());
  32.  
  33.         m_stringAddrs.resize(headerInfo.m_numStrings);
  34.         FlatAddr* pstringAddrsTable = &(m_stringAddrs[0]);
  35.         Reader.ReadDataFromFile(pOSSaveReader, pstringAddrsTable, sizeof(FlatAddr) * headerInfo.m_numStrings);
  36.         for (uint32 i = 0; i < m_stringAddrs.size(); ++i)
  37.                 SwapIntegerValue(m_stringAddrs[i]);
  38.  
  39.         m_buffer.ReadFromFile(Reader, pOSSaveReader, headerInfo.m_sizeStringData);
  40. }
  41.  
  42. //////////////////////////////////////////////////////////////////////////
  43.  
  44. void CStringTableReader::ReadFromMemory(CReader& Reader, const uint8* pData, uint32 dataSize, const SFileHeader::SStringTable& headerInfo, uint32& outReadLoc)
  45. {
  46.         assert(m_stringAddrs.empty());
  47.  
  48.         m_stringAddrs.resize(headerInfo.m_numStrings);
  49.         FlatAddr* pstringAddrsTable = &(m_stringAddrs[0]);
  50.         Reader.ReadDataFromMemory(pData, dataSize, pstringAddrsTable, sizeof(FlatAddr) * headerInfo.m_numStrings, outReadLoc);
  51.  
  52.         m_buffer.ReadFromMemory(Reader, pData, dataSize, headerInfo.m_sizeStringData, outReadLoc);
  53. }
  54.  
  55. //////////////////////////////////////////////////////////////////////////
  56. // debug / statistics purposes
  57.  
  58. #ifndef _RELEASE
  59. void CStringTableReader::WriteStringsIntoTextFile(const char* pFileName)
  60. {
  61.         FILE* pFile = gEnv->pCryPak->FOpen(pFileName, "wb");
  62.         for (int i = 0; i < m_stringAddrs.size(); ++i)
  63.         {
  64.                 string logString;
  65.                 logString.Format("%s\r\n", GetString(i));
  66.                 gEnv->pCryPak->FWrite(logString.c_str(), logString.size(), pFile);
  67.         }
  68.         gEnv->pCryPak->FClose(pFile);
  69. }
  70. #endif
  71.  
downloadXMLCPB_StringTableReader.cpp 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