OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Public Member Functions | Static Public Member Functions | Data Fields | Private Member Functions
GRFText Struct Reference

Element of the linked list. More...

## Public Member Functions
void * | operator new (size_t size)
| Helper allocation function to disallow something.
void | operator delete (void *p)
| Free the memory we allocated.

## Static Public Member Functions
static GRFText * | New (byte langid, const char *text, size_t len)
| Allocate, and assign a new GRFText with the given text.
static GRFText * | Copy (GRFText *orig)
| Create a copy of this GRFText.

## Data Fields
GRFText * | next
| The next GRFText in this chain.
size_t | len
| The length of the stored string, used for copying.
byte | langid
| The language associated with this GRFText.
char | text []
| The actual (translated) text.

## Private Member Functions
| GRFText (byte langid_, const char *text_, size_t len_)
| Actually construct the GRFText.
void * | operator new (size_t size, size_t extra)
| Allocate memory for this class.

## Detailed Description

Element of the linked list.

Each of those elements represent the string, but according to a different lang.

Definition at line 69 of file newgrf_text.cpp.

## Constructor & Destructor Documentation

GRFText::GRFText | ( | byte | langid_,
|  | const char * | text_,
|  | size_t | len_
| ) |  |
| inline private

Actually construct the GRFText.

Parameters

  langid_ | The language of the text.
  text_ | The text to store in this GRFText.
  len_ | The length of the text to store.

Definition at line 121 of file newgrf_text.cpp.

References len, and text.

Referenced by New().

## Member Function Documentation

static GRFText* GRFText::Copy | ( | GRFText * | orig | ) |
| inline static

Create a copy of this GRFText.

Parameters

  orig | the grftext to copy.

Returns
  an exact copy of the given text.

Definition at line 91 of file newgrf_text.cpp.

References langid, len, New(), and text.

Referenced by DuplicateGRFText().

static GRFText* GRFText::New | ( | byte | langid,
|  | const char * | text,
|  | size_t | len
| ) |  |
| inline static

Allocate, and assign a new GRFText with the given text.

As these strings can have string terminations in them, e.g. due to "choice lists" we (sometimes) cannot rely on detecting the length by means of strlen. Also, if the length of already known not scanning the whole string is more efficient.

Parameters

  langid | The language of the text.
  text | The text to store in the new GRFText.
  len | The length of the text.

Definition at line 81 of file newgrf_text.cpp.

References GRFText(), and len.

Referenced by AddGRFString(), AddGRFTextToList(), and Copy().

void GRFText::operator delete | ( | void * | p | ) |
| inline

Free the memory we allocated.

Parameters

  p | memory to free.

Definition at line 110 of file newgrf_text.cpp.

References free().

void* GRFText::operator new | ( | size_t | size | ) |
| inline

Helper allocation function to disallow something.

Don't allow simple 'news'; they wouldn't have enough memory.

Parameters

  size | the amount of space not to allocate.

Definition at line 101 of file newgrf_text.cpp.

void* GRFText::operator new | ( | size_t | size,
|  | size_t | extra
| ) |  |
| inline private

Allocate memory for this class.

Parameters

  size | the size of the instance
  extra | the extra memory for the text

Returns
  the requested amount of memory for both the instance and the text

Definition at line 135 of file newgrf_text.cpp.

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

- src/newgrf_text.cpp