2004-08-21 13:45:01 +02:00
|
|
|
/*
|
|
|
|
|
|
|
|
Stores sections of a translated string: constant strings, simple variables,
|
|
|
|
and JS function calls, allowing conversion to strings.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef I18N_TSCOMPONENT_H
|
|
|
|
#define I18N_TSCOMPONENT_H
|
|
|
|
|
|
|
|
#include "StrImmutable.h"
|
|
|
|
#include "BufferVariable.h"
|
|
|
|
#include "ScriptInterface.h"
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace I18n
|
|
|
|
{
|
|
|
|
class CLocale;
|
|
|
|
|
|
|
|
class TSComponent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual const StrImW ToString(CLocale* locale, std::vector<BufferVariable*>& vars) const = 0;
|
|
|
|
virtual ~TSComponent() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class TSComponentString : public TSComponent {
|
|
|
|
public:
|
|
|
|
TSComponentString(const wchar_t* s) : String(s) {};
|
|
|
|
|
|
|
|
const StrImW ToString(CLocale* locale, std::vector<BufferVariable*>& vars) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const StrImW String;
|
2005-08-09 17:55:44 +02:00
|
|
|
|
|
|
|
// squelch "unable to generate" warnings
|
|
|
|
TSComponentString(const TSComponentString& rhs);
|
|
|
|
const TSComponentString& operator=(const TSComponentString& rhs);
|
2004-08-21 13:45:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class TSComponentVariable : public TSComponent {
|
|
|
|
public:
|
|
|
|
TSComponentVariable(unsigned char id) : ID(id) {};
|
|
|
|
|
|
|
|
const StrImW ToString(CLocale* locale, std::vector<BufferVariable*>& vars) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
unsigned char ID;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TSComponentFunction : public TSComponent {
|
|
|
|
public:
|
|
|
|
TSComponentFunction(const char* name) : Name(name) {};
|
|
|
|
~TSComponentFunction();
|
|
|
|
|
|
|
|
const StrImW ToString(CLocale* locale, std::vector<BufferVariable*>& vars) const;
|
|
|
|
|
|
|
|
// AddParam is called when loading the function, building up the
|
|
|
|
// internal list of parameters (strings / ints / variables)
|
|
|
|
void AddParam(ScriptValue* p);
|
|
|
|
|
|
|
|
private:
|
|
|
|
const std::string Name;
|
|
|
|
std::vector<ScriptValue*> Params;
|
2005-08-09 17:55:44 +02:00
|
|
|
|
|
|
|
// squelch "unable to generate" warnings
|
|
|
|
TSComponentFunction(const TSComponentFunction& rhs);
|
|
|
|
const TSComponentFunction& operator=(const TSComponentFunction& rhs);
|
2004-08-21 13:45:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-08-21 14:57:10 +02:00
|
|
|
#endif // I18N_TSCOMPONENT_H
|