Falcon::StringTable Class Reference

#include <strtable.h>

Inheritance diagram for Falcon::StringTable:

Inheritance graph
[legend]

List of all members.

Public Member Functions

int32 add (String *str)
void build (wchar_t **table, bool bInternational)
 Builds the table from a source file initialization.
void build (char **table, bool bInternational)
 Builds the table from a source file initialization.
Stringfind (const String &source) const
int32 findId (const String &str) const
const Stringget (uint32 id) const
uint32 internatCount () const
 Returns the count of international strings added to this symbol table.
bool load (Stream *in)
 Restores a string table that was saved on a stream.
const Stringoperator[] (int32 id)
void reserve (int32 size)
bool save (Stream *out) const
 Save the string table in a stream.
bool saveTemplate (Stream *out, const String &modName, const String &origLangCode) const
 Saves a template file out of this string table.
int32 size () const
bool skip (Stream *in) const
 Skip the string table from a stream.
 StringTable (const StringTable &other)
 StringTable ()
 ~StringTable ()

Friends

class ModuleLoader


Constructor & Destructor Documentation

Falcon::StringTable::StringTable (  ) 

Falcon::StringTable::StringTable ( const StringTable other  ) 

Falcon::StringTable::~StringTable (  ) 


Member Function Documentation

int32 Falcon::StringTable::add ( String str  ) 

void Falcon::StringTable::build ( wchar_t **  table,
bool  bInternational 
)

Builds the table from a source file initialization.

Useful to build static string tables in modules and in the engine. Provide the function with an array of char pointers, the last of which being 0; this will create a suitable module string table where the first string in the array has id 0, the second has id 1 and so on.

Parameters:
table a vector of wchar_t * terminated by zero.
bInternational the string table contains items to be internationalized.

void Falcon::StringTable::build ( char **  table,
bool  bInternational 
)

Builds the table from a source file initialization.

Useful to build static string tables in modules and in the engine. Provide the function with an array of char pointers, the last of which being 0; this will create a suitable module string table where the first string in the array has id 0, the second has id 1 and so on.

Parameters:
table a vector of char * terminated by zero.
bInternational the string table contains items to be internationalized.

String* Falcon::StringTable::find ( const String source  )  const

int32 Falcon::StringTable::findId ( const String str  )  const

const String* Falcon::StringTable::get ( uint32  id  )  const [inline]

uint32 Falcon::StringTable::internatCount (  )  const [inline]

Returns the count of international strings added to this symbol table.

Note:
if this is zero, then the module writers shouldn't even create the template for the given module.

bool Falcon::StringTable::load ( Stream in  ) 

Restores a string table that was saved on a stream.

For more details see save().

See also:
save()
Parameters:
in the input stream where the table must be loaded from
Returns:
true on success, false on failure (format error).

const String* Falcon::StringTable::operator[] ( int32  id  )  [inline]

void Falcon::StringTable::reserve ( int32  size  )  [inline]

bool Falcon::StringTable::save ( Stream out  )  const

Save the string table in a stream.

The string table is saved as a block, without using the serialization function of the Falcon::String objects. The block has a string table specific format, so that the load() function can load the whole block back in memory and then create each string in the table as a static non-zero terminated or static zero terminated string (in the proper encoding). None of the serialized string is re-created as bufferized, as the memory in which the string raw data resides is held internally in this object. Also, notice that all the strings and the relative raw data memory is destroyed with this object.

The rationale for this behavior is that the StringTable object is meant to hold a specific set of strings that are related to some specific task. Usually, serialization and de-serialization of the string table occurs in module compilation and loading. As the vast majority of the strings in the table will be accessed read only, to provide flexible storage at load time for all of the would be unefficient.

The data block is aligned to a multiple of 4. I.e. if the function were to write 1438 bytes, it will actually deliver on the stream 1440 bytes, two of which being padding.

The function never fails, but if the output stream has a failure the function doesn't detect it. The output stream status must be checked on exit.

Parameters:
out the stream where to save the table.
Returns:
true on success, false on failure

bool Falcon::StringTable::saveTemplate ( Stream out,
const String modName,
const String origLangCode 
) const

Saves a template file out of this string table.

Template files are needed for internationalization. The template file will be written in an XML format. This function doesn't write the ?xml header of the xml file, as that requires the caller to know the encoding of the output stream.

The caller should do it instead.

Add encoding ID to common Stream interface.

A template file contains all the strings of the table so that the compiler of a translation set can associate them with translation.

Parameters:
out A Falcon::Stream for output.
modName The name of the moule to be written in the template file.
origLangCode the language code of this symbol table.

int32 Falcon::StringTable::size (  )  const [inline]

bool Falcon::StringTable::skip ( Stream in  )  const

Skip the string table from a stream.

This is useful when i.e. you have a string table embedded in a stream but you don't want to load it, for example because you want to use an external string table instead.


Friends And Related Function Documentation

friend class ModuleLoader [friend]


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

Generated on Mon Oct 19 10:11:47 2009 for Falcon_Core by  doxygen 1.5.8