CmFileSerializer.h 1003 B

1234567891011121314151617181920212223242526272829303132
  1. #pragma once
  2. #include "CmPrerequisitesUtil.h"
  3. namespace CamelotFramework
  4. {
  5. // TODO - Low priority. Eventually I'll want to generalize BinarySerializer to Serializer class, then I can make this class accept
  6. // a generic Serializer interface so it may write both binary, plain-text or some other form of data.
  7. class CM_UTILITY_EXPORT FileSerializer
  8. {
  9. public:
  10. FileSerializer();
  11. ~FileSerializer();
  12. void encode(IReflectable* object, String fileLocation);
  13. std::shared_ptr<IReflectable> decode(String fileLocation);
  14. private:
  15. std::ofstream mOutputStream;
  16. UINT8* mWriteBuffer;
  17. std::ifstream mInputStream;
  18. UINT8* flushBuffer(UINT8* bufferStart, int bytesWritten, UINT32& newBufferSize);
  19. /************************************************************************/
  20. /* CONSTANTS */
  21. /************************************************************************/
  22. private:
  23. static const UINT32 WRITE_BUFFER_SIZE = 2048;
  24. };
  25. }