SourceMod::IPhraseCollection Class Reference

#include <public/ITranslator.h>

List of all members.

Public Member Functions

virtual IPhraseFileAddPhraseFile (const char *filename)=0
 Adds a phrase file to the collection, using a cached one if already found. The return value is provided for informational purposes and does not need to be saved. The life time of the return pointer is equal to the life time of the collection.
virtual unsigned int GetFileCount ()=0
 Returns the number of contained phrase files.
virtual IPhraseFileGetFile (unsigned int file)=0
 Returns the pointer to a contained phrase file.
virtual void Destroy ()=0
 Destroys the phrase collection, freeing all internal resources and invalidating the object.
virtual TransError FindTranslation (const char *key, unsigned int langid, Translation *pTrans)=0
 Attempts a translation across a given language. All contained files are searched for an appropriate match; the first valid match is returned.
virtual bool FormatString (char *buffer, size_t maxlength, const char *format, void **params, unsigned int numparams, size_t *pOutLength, const char **pFailPhrase)=0
 Formats a phrase given a parameter stack. The parameter stack size must exactly match the expected parameter count. If this count is too small or too large, the format fails.


Detailed Description

Represents a collection of phrase files.

Definition at line 118 of file ITranslator.h.


Member Function Documentation

virtual IPhraseFile* SourceMod::IPhraseCollection::AddPhraseFile ( const char *  filename  )  [pure virtual]

Adds a phrase file to the collection, using a cached one if already found. The return value is provided for informational purposes and does not need to be saved. The life time of the return pointer is equal to the life time of the collection.

This function will internally ignore dupliate additions but still return a valid pointer.

Parameters:
filename File name, without the ".txt" extension, of the phrase file in the translations folder.
Returns:
An IPhraseFile pointer, even if the file does not exist.

virtual unsigned int SourceMod::IPhraseCollection::GetFileCount (  )  [pure virtual]

Returns the number of contained phrase files.

Returns:
Number of contained phrase files.

virtual IPhraseFile* SourceMod::IPhraseCollection::GetFile ( unsigned int  file  )  [pure virtual]

Returns the pointer to a contained phrase file.

Parameters:
file File index, from 0 to GetFileCount()-1.
Returns:
IPhraseFile pointer, or NULL if out of range.

virtual TransError SourceMod::IPhraseCollection::FindTranslation ( const char *  key,
unsigned int  langid,
Translation pTrans 
) [pure virtual]

Attempts a translation across a given language. All contained files are searched for an appropriate match; the first valid match is returned.

Parameters:
key String containing the phrase name.
langid Language ID to translate to.
pTrans Translation buffer.
Returns:
Translation error code; on success, pTrans is valid. On failure, the contents of pTrans is undefined.

virtual bool SourceMod::IPhraseCollection::FormatString ( char *  buffer,
size_t  maxlength,
const char *  format,
void **  params,
unsigned int  numparams,
size_t *  pOutLength,
const char **  pFailPhrase 
) [pure virtual]

Formats a phrase given a parameter stack. The parameter stack size must exactly match the expected parameter count. If this count is too small or too large, the format fails.

Parameters:
buffer Buffer to store formatted text.
maxlength Maximum length of the buffer.
format String containing format information. This is equivalent to SourceMod's Format() native, and sub-translations are acceptable.
params An array of pointers to each parameter. Integer parameters must have a pointer to the integer. Float parameters must have a pointer to a float. String parameters must be a string pointer. Char parameters must be a pointer to a char. Translation parameters fill multiple indexes in the array. For T translations, the expected stack is: [phrase string pointer] [int target id pointer] [...] Where [...] is the required parameters for the translation, in the order expected by the phrase, not the phrase's translation. For example, say the format is: "%d %T" and the phrase's format is {1:s,2:f}, then the parameter stack should be: int *, const char *, int *, const char *, float * The t modifier is the same except the target id pointer would be removed: int *, const char *, const char *, float *
numparams Number of parameters in the params array.
pOutLength Optional pointer filled with output length on success.
pFailPhrase Optional pointer; on failure, is filled with NULL if the failure was not due to a failed translation phrase. Otherwise, it is filled with the given phrase name pointer from the parameter stack. Undefined on success.
Returns:
True on success. False if the parameter stack was not exactly the right length, or if a translation phrase could not be found.


The documentation for this class was generated from the following file:
Generated on Fri Nov 21 07:10:04 2008 for SourceMod SDK by  doxygen 1.5.1