Public Member Functions | Data Fields

# TemporaryStorageArray< TYPE, SIZE > Struct Template Reference

Class for temporary storage of data. More...

`#include <newgrf_storage.h>`

Inheritance diagram for TemporaryStorageArray< TYPE, SIZE >:

## Public Member Functions
| TemporaryStorageArray ()
| Simply construct the array.
void | StoreValue (uint pos, int32 value)
| Stores some value at a given position.
TYPE | GetValue (uint pos) const
| Gets the value from a given position.
void | ClearChanges (bool keep_changes)
| Clear the changes made since the last ClearChanges.
## Data Fields
TYPE | storage [SIZE]
| Memory to for the storage array.

## Detailed Description

### template<typename TYPE, uint SIZE>
struct TemporaryStorageArray< TYPE, SIZE >

Class for temporary storage of data.

On ClearChanges that data is always zero-ed.

Template Parameters:

  | TYPE | the type of variable to store.
  | SIZE | the size of the array.

Definition at line 135 of file newgrf_storage.h.

## Member Function Documentation

template<typename TYPE, uint SIZE>

void TemporaryStorageArray< TYPE, SIZE >::ClearChanges | ( | bool | keep_changes | ) | `[inline, virtual]`

Clear the changes made since the last ClearChanges.

This can be done in two ways:

- saving the changes permanently
- reverting to the previous version
  Parameters:

    | keep_changes | do we save or revert the changes since the last ClearChanges?

Implements BaseStorageArray.

Definition at line 171 of file newgrf_storage.h.

References TemporaryStorageArray< TYPE, SIZE >::storage.

template<typename TYPE, uint SIZE>

TYPE TemporaryStorageArray< TYPE, SIZE >::GetValue | ( | uint | pos | ) | const`[inline]`

Gets the value from a given position.

Parameters:

  | pos | the position to get the data from

Returns:
  the data from that position

Definition at line 163 of file newgrf_storage.h.

References TemporaryStorageArray< TYPE, SIZE >::storage.

Referenced by GetRegister(), StartTextRefStackUsage(), and CommandCost::UseTextRefStack().

template<typename TYPE, uint SIZE>

void TemporaryStorageArray< TYPE, SIZE >::StoreValue | ( | uint | pos,
|  | int32 | value |
| ) |  |  | `[inline, virtual]`

Stores some value at a given position.

Parameters:

  | pos | the position to write at
  | value | the value to write

Implements BaseStorageArray.

Definition at line 149 of file newgrf_storage.h.

References AddChangedStorage(), and TemporaryStorageArray< TYPE, SIZE >::storage.

Referenced by ClearRegister().

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

- src/newgrf_storage.h