All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CacheModelSerializer.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "Cache.h"
7 #include "Helpers.h"
8 #include "BinaryParsing.h"
9 #include <iosfwd>
10 
11 namespace Eegeo
12 {
13  namespace Web
14  {
15  namespace Cache
16  {
18  {
19  public:
21  virtual ~CacheModelSerializer();
22 
23  bool WriteToFile(const CacheModel& cacheModel, const std::string& filename);
24  bool ReadFromFile(const std::string& filename, CacheModel& cacheModel);
25 
26  private:
27  Helpers::IFileIO& m_fileIO;
29 
30  void WriteHeader(std::ostream& outputStream);
31  bool TryReadHeader(std::istream& inputStream, unsigned int& out_version);
32 
33  void WriteFooter(std::ostream& outputStream);
34  bool TryReadFooter(std::istream& inputStream);
35 
36  void WriteRecord(const CacheRecord& record, std::ostream& outputStream);
37  CacheRecord ReadRecord(std::istream& inputStream, const u32 version);
38  };
39  }
40  }
41 }