OpenTTD Source: ZlibSaveFilter Struct Reference

OpenTTD Source 15.0-RC2

Public Member Functions | Data Fields
ZlibSaveFilter Struct Reference

Filter using Zlib compression. More...

Inheritance diagram for ZlibSaveFilter:

## Public Member Functions
| ZlibSaveFilter (std::shared_ptr< SaveFilter > chain, uint8_t compression_level)
| Initialise this filter.
| ~ZlibSaveFilter ()
| Clean up what we allocated.
void | WriteLoop (uint8_t *p, size_t len, int mode)
| Helper loop for writing the data.
void | Write (uint8_t *buf, size_t size) override
| Write a given number of bytes into the savegame.
void | Finish () override
| Prepare everything to finish writing the savegame.
Public Member Functions inherited from SaveFilter
| SaveFilter (std::shared_ptr< SaveFilter > chain)
| Initialise this filter.
virtual | ~SaveFilter ()=default
| Make sure the writers are properly closed.

## Data Fields
z_stream | z {}
| Stream state we are writing to.
uint8_t | fwrite_buf [MEMORY_CHUNK_SIZE]
| Buffer for writing to the file.
Data Fields inherited from SaveFilter
std::shared_ptr< SaveFilter > | chain
| Chained to the (savegame) filters.

## Detailed Description

Filter using Zlib compression.

Definition at line 2605 of file saveload.cpp.

## Constructor & Destructor Documentation

## ◆ ZlibSaveFilter()

ZlibSaveFilter::ZlibSaveFilter | ( | std::shared_ptr< SaveFilter > | chain,
|  | uint8_t | compression_level
| ) |  |
| inline

Initialise this filter.

Parameters

  chain | The next filter in this chain.
  compression_level | The requested level of compression.

Definition at line 2614 of file saveload.cpp.

References SlError(), and z.

## ◆ ~ZlibSaveFilter()

ZlibSaveFilter::~ZlibSaveFilter | ( |  | ) |
| inline

Clean up what we allocated.

Definition at line 2620 of file saveload.cpp.

References z.

## Member Function Documentation

## ◆ Finish()

void ZlibSaveFilter::Finish | ( |  | ) |
| inlineoverridevirtual

Prepare everything to finish writing the savegame.

Reimplemented from SaveFilter.

Definition at line 2664 of file saveload.cpp.

References SaveFilter::chain, and WriteLoop().

## ◆ Write()

void ZlibSaveFilter::Write | ( | uint8_t * | buf,
|  | size_t | len
| ) |  |
| inlineoverridevirtual

Write a given number of bytes into the savegame.

Parameters

  buf | The bytes to write.
  len | The number of bytes to write.

Implements SaveFilter.

Definition at line 2659 of file saveload.cpp.

References WriteLoop().

## ◆ WriteLoop()

void ZlibSaveFilter::WriteLoop | ( | uint8_t * | p,
|  | size_t | len,
|  | int | mode
| ) |  |
| inline

Helper loop for writing the data.

Parameters

  p | The bytes to write.
  len | Amount of bytes to write.
  mode | Mode for deflate.

For the poor next soul who sees many valgrind warnings of the "Conditional jump or move depends on uninitialised value(s)" kind: According to the author of zlib it is not a bug and it won't be fixed. http://groups.google.com/group/comp.compression/browse_thread/thread/b154b8def8c2a3ef/cdf9b8729ce17ee2 [Mark Adler, Feb 24 2004, 'zlib-1.2.1 valgrind warnings' in the newsgroup comp.compression]

Definition at line 2631 of file saveload.cpp.

References SaveFilter::chain, fwrite_buf, SlError(), and z.

Referenced by Finish(), and Write().

## Field Documentation

## ◆ fwrite_buf

uint8_t ZlibSaveFilter::fwrite_buf[MEMORY_CHUNK_SIZE]

Buffer for writing to the file.

Definition at line 2607 of file saveload.cpp.

Referenced by WriteLoop().

## ◆ z

z_stream ZlibSaveFilter::z {}

Stream state we are writing to.

Definition at line 2606 of file saveload.cpp.

Referenced by WriteLoop(), ZlibSaveFilter(), and ~ZlibSaveFilter().

The documentation for this struct was generated from the following file:

- src/saveload/saveload.cpp