BVB Source Codes

CRYENGINE Show XMLCPB_Writer.h Source code

Return Download CRYENGINE: download XMLCPB_Writer.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. #ifndef XMLCPB_WRITER_H
  8.         #define XMLCPB_WRITER_H
  9.  
  10.         #include "XMLCPB_StringTableWriter.h"
  11.         #include "XMLCPB_AttrSetTableWriter.h"
  12.         #include "XMLCPB_NodeLiveWriter.h"
  13.  
  14. namespace XMLCPB {
  15.  
  16. // CWriter should not be used directly from outside. use CWriterInterface instead.
  17.  
  18. class CWriterBase
  19. {
  20. public:
  21.         ~CWriterBase();
  22. };
  23.  
  24. class CWriter : public CWriterBase
  25. {
  26. public:
  27.  
  28.         CWriter();
  29.         ~CWriter();
  30.  
  31.         // used from outside, thru the CWriterInterface
  32.         void               Init(const char* pRootName, const char* pFileName);
  33.         CNodeLiveWriterRef GetRoot();
  34.         void               Done();          // should be called when everything is added and finished.
  35.         bool               FinishWritingFile();
  36.         bool               WriteAllIntoMemory(uint8*& rpData, uint32& outSize);        // used to write all into a memory buffer (as opposite to a file ).
  37.  
  38.         // used internally, from other XMLCPB modules
  39.         void                 WriteDataIntoFile(void* pSrc, uint32 numBytes);
  40.         void                 WriteDataIntoMemory(uint8*& rpData, void* pSrc, uint32 numBytes, uint32& outWriteLoc);
  41.         CStringTableWriter&  GetAttrNamesTable()        { return m_tableAttrNames; }
  42.         CStringTableWriter&  GetStrDataTable()          { return m_tableStrData; }
  43.         CStringTableWriter&  GetStrDataConstantsTable() { return m_tableStrDataConstants; }
  44.         CStringTableWriter&  GetTagsTable()             { return m_tableTags; }
  45.         CAttrSetTableWriter& GetAttrSetTable()          { return m_tableAttrSets; }
  46.         CBufferWriter&       GetMainBuffer()            { return m_mainBuffer; }
  47.         CNodeLiveWriter*     GetNodeLive(NodeLiveID nodeId);
  48.         void                 FreeNodeLive(NodeLiveID nodeId);
  49.         CNodeLiveWriter*     CreateAndAddLiveNode(const char* pName);
  50.         void                 NotifyRootNodeStartCompact();
  51.         bool                 IsSavingIntoFile() const    { return m_isSavingIntoFile; }
  52.         void                 NotifyNodeCompacted()       { m_counterCompactedNodes++; }
  53.         NodeGlobalID         GetLastUsedGlobalId() const { return m_counterCompactedNodes - 1; }  // globalId is just the order of the node in the big buffer
  54.         void                 NotifyInternalError()       { m_hasInternalError = true; }
  55.         bool                 HasInternalError() const    { return m_hasInternalError; }
  56.  
  57.         #ifdef XMLCPB_COLLECT_STATS
  58.         void LogStatistics();
  59.         #endif
  60.  
  61. private:
  62.  
  63.         void CreateFileHeader(SFileHeader& fileHeader);
  64.  
  65. private:
  66.  
  67.         std::vector<_smart_ptr<CNodeLiveWriter>> m_liveNodes;  // nodes that are not done yet. TODO: this maybe could be better as an array of objects instead pointers. could get rid of the reference target too that way
  68.         CBufferWriter                            m_mainBuffer; // where the bulk of binary data is being stored as the nodes get done. it is actually an array of smaller buffers.
  69.         CStringTableWriter                       m_tableTags;
  70.         CStringTableWriter                       m_tableAttrNames;
  71.         CStringTableWriter                       m_tableStrData;
  72.         CStringTableWriter                       m_tableStrDataConstants; // this actually should not be here. it is used only inside CAttrWriter, for optimizations. Is not there because then it would need to be an static member. also, this table is not saved into the file.
  73.         CAttrSetTableWriter                      m_tableAttrSets;
  74.         CBufferWriter::SAddr                     m_rootAddr; // this only has a meaning after the root has been compacted, which only happens at the end of the process
  75.         class CZLibCompressor*                   m_compressor;
  76.         int              m_firstFreeLiveNode;              // to speed a bit the search for free spaces in the livenodes table.
  77.         uint32           m_safecheckIDCounter;             // safecheckID is used in the nodes to avoid using the wrong node.
  78.         uint32           m_counterCompactedNodes;
  79.         bool             m_isSavingIntoFile;
  80.         bool             m_hasInternalError;               // usually means that one of the hard coded limits have been surpassed. (more than X attrs, more than X different tags, etc)
  81.         static const int MAX_NUM_LIVE_NODES = 256;
  82.         static const int MAIN_BUFFER_SIZE_INCREMENT = 64 * 1024;
  83. };
  84.  
  85. }  // end namespace
  86.  
  87. #endif
  88.  
downloadXMLCPB_Writer.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