10#ifndef SAVELOAD_FILTER_H
11#define SAVELOAD_FILTER_H
16 std::shared_ptr<LoadFilter>
chain;
35 virtual size_t Read(uint8_t *buf,
size_t len) = 0;
51template <
typename T> std::shared_ptr<LoadFilter>
CreateLoadFilter(std::shared_ptr<LoadFilter> chain)
53 return std::make_shared<T>(chain);
59 std::shared_ptr<SaveFilter>
chain;
77 virtual void Write(uint8_t *buf,
size_t len) = 0;
84 if (this->chain !=
nullptr) this->chain->Finish();
94template <
typename T> std::shared_ptr<SaveFilter>
CreateSaveFilter(std::shared_ptr<SaveFilter> chain, uint8_t compression_level)
96 return std::make_shared<T>(chain, compression_level);
std::shared_ptr< SaveFilter > CreateSaveFilter(std::shared_ptr< SaveFilter > chain, uint8_t compression_level)
Instantiator for a save filter.
std::shared_ptr< LoadFilter > CreateLoadFilter(std::shared_ptr< LoadFilter > chain)
Instantiator for a load filter.
Interface for filtering a savegame till it is loaded.
virtual size_t Read(uint8_t *buf, size_t len)=0
Read a given number of bytes from the savegame.
virtual ~LoadFilter()=default
Make sure the writers are properly closed.
virtual void Reset()
Reset this filter to read from the beginning of the file.
std::shared_ptr< LoadFilter > chain
Chained to the (savegame) filters.
LoadFilter(std::shared_ptr< LoadFilter > chain)
Initialise this filter.
Interface for filtering a savegame till it is written.
virtual void Write(uint8_t *buf, size_t len)=0
Write a given number of bytes into the savegame.
virtual void Finish()
Prepare everything to finish writing the savegame.
SaveFilter(std::shared_ptr< SaveFilter > chain)
Initialise this filter.
std::shared_ptr< SaveFilter > chain
Chained to the (savegame) filters.
virtual ~SaveFilter()=default
Make sure the writers are properly closed.