OpenTTD
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 GRFTextNew (byte langid, const char *text, size_t len)
 Allocate, and assign a new GRFText with the given text.
static GRFTextCopy (GRFText *orig)
 Create a copy of this GRFText.

Data Fields

GRFTextnext
 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_ 
)
inlineprivate

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)
inlinestatic

Create a copy of this GRFText.

Parameters
origthe 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 
)
inlinestatic

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
langidThe language of the text.
textThe text to store in the new GRFText.
lenThe 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
pmemory 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
sizethe 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 
)
inlineprivate

Allocate memory for this class.

Parameters
sizethe size of the instance
extrathe 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: