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 126 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 178 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 148 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 138 of file newgrf_text.cpp.

References GRFText().

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 167 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 192 of file newgrf_text.cpp.

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 158 of file newgrf_text.cpp.


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

Generated on Sun May 8 07:31:08 2011 for OpenTTD by  doxygen 1.6.1