| |
Main Page Namespace List Class Hierarchy Alphabetical List Compound List Namespace Members Compound Members
PLMTranslator Class ReferenceString provider (singleton class).
More...
#include <PLMTranslator.hpp>
List of all members.
Detailed Description
String provider (singleton class).
How to use:
- Get access to the object with Singleton().
- Initialize the service with a path name containing the translation files.
- Call NbLangs() and GetLangName() to build your own list of available (found) languages.
- Load one of the language files with Load*() (3 versions).
- Do not forget to delete the object somewhere before exit.
Note that it is possible to use the whole system without calling Init() by loading the file directly (with LoadFile(filename)). But in this case, only NbStrings() and GetCurFile() will run correctly, no other method should be called.
Member Enumeration Documentation
|
|
- Enumeration values:
-
| STATE_BAD |
not yet initialised |
| STATE_INIT |
properly initialised (files found) |
|
Member Function Documentation
| PLMTranslator* PLMTranslator::Singleton |
( |
|
) |
[static] |
|
|
|
Get an instance of this singleton class.
|
| int PLMTranslator::Init |
( |
const char * |
pathname, |
|
|
const char * |
ext = ".lang" |
|
) |
|
|
|
|
Initialise the whole service.
Look in the given path to find some language files and build an internal list of files. You can optionnaly give the file extension, this will restrict the tests to the corresponding files. Set ext to NULL to check all files. Can be called many times, but this will delete and rebuild the existing file list and the current string table is cleared, even if no files are found. Return the number of files found on success. Return 0 if no file is found or if the path is not valid. |
| const char * PLMTranslator::GetPath |
( |
|
) |
[inline] |
|
|
|
Return the current path used to call Init().
Return NULL if none. The returned string must not be modified or deleted. |
| int PLMTranslator::State |
( |
|
) |
[inline] |
|
|
|
Get the current state. Return one of the STATE_ enums.
|
| unsigned int PLMTranslator::NbLangs |
( |
|
) |
[inline] |
|
|
|
Get the number of languages (files) found in the current path.
Same value as the one returned by Init(). |
| const char* PLMTranslator::GetLangName |
( |
unsigned int |
index |
) |
const |
|
|
|
Get the name of the language at index index in the current list.
Never modify or delete the returned pointer. Return NULL if index is not valid. |
| const char* PLMTranslator::GetLangFile |
( |
unsigned int |
index |
) |
const |
|
|
|
Get the name of the file at index index in the current list.
Never modify or delete the returned pointer. Return NULL if index is not valid. |
| bool PLMTranslator::LoadIndex |
( |
unsigned int |
index |
) |
[inline] |
|
|
|
Try to load the language at index index in the current list.
Return true on success (a file may be valid and contain no string). Return false on failure (invalid file), the current array is not modified. |
| bool PLMTranslator::LoadFile |
( |
const char * |
filename |
) |
[inline] |
|
|
|
Try to directly load the given file.
The file is loaded from the current directory if the filename is not in absolute form. Return true on success. |
| bool PLMTranslator::LoadName |
( |
const char * |
langname |
) |
|
|
|
|
Try to load the language of name langname.
The argument must be a valid name, such as one returned by GetLangName() or GetCurName(). Return true on success, false if not Init() or name not found. |
| const char* PLMTranslator::GetCurName |
( |
|
) |
|
|
|
|
Return the name of the current loaded language. NULL if none.
|
| const char* PLMTranslator::GetCurFile |
( |
|
) |
|
|
|
|
Return the file name of the current loaded language. NULL if none.
|
| unsigned int PLMTranslator::GetCurIndex |
( |
|
) |
[inline] |
|
|
|
Return the index of the current loaded language. BAD_INDEX if none.
|
| unsigned int PLMTranslator::NbStrings |
( |
|
) |
[inline] |
|
|
|
Get the number of strings in the current loaded file.
|
| const char* PLMTranslator::GetString |
( |
unsigned int |
index |
) |
|
|
|
|
Get the string of index index from the current loaded array.
Return NULL if the index is not valid (valid = 0..NbString()-1). |
| void PLMTranslator::PrintInfo |
( |
bool |
showstr = false |
) |
const |
|
|
|
Print some information on the current log.
|
The documentation for this class was generated from the following file:
Generated by
Doxygen 1.2.18 on Tue Oct 26 12:07:39 2004.
|