1
0
forked from 0ad/0ad
0ad/source/i18n/BufferVariable.h
Ykkrosh 0e55379b36 Initial i18n integration
This was SVN commit r1029.
2004-08-21 11:45:01 +00:00

88 lines
1.9 KiB
C++
Executable File

/*
BufferVariable stores the parameters that have been passed to a StringBuffer,
providing hashes and strings on request.
*/
#ifndef I18N_BUFFERVARIABLE_H
#define I18N_BUFFERVARIABLE_H
#include "Common.h"
#include "StrImmutable.h"
#include <assert.h>
namespace I18n
{
class CLocale;
enum {
vartype_int,
vartype_double,
vartype_string,
vartype_rawstring, // won't be translated automatically
};
class BufferVariable
{
public:
char Type;
virtual StrImW ToString(CLocale*) = 0;
virtual u32 Hash() = 0;
virtual ~BufferVariable() {};
};
// Factory constructor type thing, sort of
template<typename T>
BufferVariable* NewBufferVariable(T v);
class BufferVariable_int : public BufferVariable
{
public:
int value;
BufferVariable_int(int v) : value(v) { Type = vartype_int; }
StrImW ToString(CLocale*);
u32 Hash();
// Equality testing is required by the cache
bool operator== (BufferVariable_int&);
};
class BufferVariable_double : public BufferVariable
{
public:
double value;
BufferVariable_double(double v) : value(v) { Type = vartype_double; }
StrImW ToString(CLocale*);
u32 Hash();
bool operator== (BufferVariable_double&);
};
class BufferVariable_string : public BufferVariable
{
public:
StrImW value;
BufferVariable_string(StrImW v) : value(v) { Type = vartype_string; }
StrImW ToString(CLocale*);
u32 Hash();
bool operator== (BufferVariable_string&);
};
class BufferVariable_rawstring : public BufferVariable
{
public:
StrImW value;
BufferVariable_rawstring(StrImW v) : value(v) { Type = vartype_rawstring; }
StrImW ToString(CLocale*);
u32 Hash();
bool operator== (BufferVariable_rawstring&);
};
// BufferVariable==BufferVariable compares their Types, and then
// uses the appropriate operator== if they're the same
bool operator== (BufferVariable&, BufferVariable&);
}
#endif // I18N_BUFFERVARIABLE_H