Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef STRINGS_FUNC_H
00013 #define STRINGS_FUNC_H
00014
00015 #include "strings_type.h"
00016 #include "string_type.h"
00017 #include "gfx_type.h"
00018
00019 class StringParameters {
00020 StringParameters *parent;
00021 uint64 *data;
00022 WChar *type;
00023
00024 public:
00025 uint offset;
00026 uint num_param;
00027
00029 StringParameters(uint64 *data, uint num_param, WChar *type) :
00030 parent(NULL),
00031 data(data),
00032 type(type),
00033 offset(0),
00034 num_param(num_param)
00035 { }
00036
00038 template <size_t Tnum_param>
00039 StringParameters(int64 (&data)[Tnum_param]) :
00040 parent(NULL),
00041 data((uint64 *)data),
00042 type(NULL),
00043 offset(0),
00044 num_param(Tnum_param)
00045 {
00046 assert_compile(sizeof(data[0]) == sizeof(uint64));
00047 }
00048
00053 StringParameters(StringParameters &parent, uint size) :
00054 parent(&parent),
00055 data(parent.data + parent.offset),
00056 offset(0),
00057 num_param(size)
00058 {
00059 assert(size <= parent.num_param - parent.offset);
00060 if (parent.type == NULL) {
00061 this->type = NULL;
00062 } else {
00063 this->type = parent.type + parent.offset;
00064 }
00065 }
00066
00067 ~StringParameters()
00068 {
00069 if (this->parent != NULL) {
00070 this->parent->offset += this->num_param;
00071 }
00072 }
00073
00074 void ClearTypeInformation();
00075
00080 int64 GetInt64(WChar type = 0)
00081 {
00082 assert(this->offset < this->num_param);
00083 if (this->type != NULL) {
00084 assert(this->type[this->offset] == 0 || this->type[this->offset] == type);
00085 this->type[this->offset] = type;
00086 }
00087 return this->data[this->offset++];
00088 }
00089
00091 int32 GetInt32(WChar type = 0)
00092 {
00093 return (int32)this->GetInt64(type);
00094 }
00095
00096 void ShiftParameters(uint amount);
00097
00099 uint64 *GetDataPointer() const
00100 {
00101 return &this->data[this->offset];
00102 }
00103
00105 uint64 *GetPointerToOffset(uint offset) const
00106 {
00107 assert(offset < this->num_param);
00108 return &this->data[offset];
00109 }
00110
00112 bool HasTypeInformation() const
00113 {
00114 return this->type != NULL;
00115 }
00116
00118 WChar GetTypeAtOffset(uint offset) const
00119 {
00120 assert(offset < this->num_param);
00121 assert(this->HasTypeInformation());
00122 return this->type[offset];
00123 }
00124
00125 void SetParam(uint n, uint64 v)
00126 {
00127 assert(n < this->num_param);
00128 this->data[n] = v;
00129 }
00130
00131 uint64 GetParam(uint n) const
00132 {
00133 assert(n < this->num_param);
00134 return this->data[n];
00135 }
00136 };
00137 extern StringParameters _global_string_params;
00138
00139 char *InlineString(char *buf, StringID string);
00140 char *GetString(char *buffr, StringID string, const char *last);
00141 char *GetStringWithArgs(char *buffr, StringID string, StringParameters *args, const char *last, uint case_index = 0);
00142 const char *GetStringPtr(StringID string);
00143
00144 void InjectDParam(uint amount);
00145
00152 static inline void SetDParamX(uint64 *s, uint n, uint64 v)
00153 {
00154 s[n] = v;
00155 }
00156
00162 static inline void SetDParam(uint n, uint64 v)
00163 {
00164 _global_string_params.SetParam(n, v);
00165 }
00166
00167 void SetDParamStr(uint n, const char *str);
00168
00169 void CopyInDParam(int offs, const uint64 *src, int num);
00170 void CopyOutDParam(uint64 *dst, int offs, int num);
00171
00178 static inline uint64 GetDParamX(const uint64 *s, uint n)
00179 {
00180 return s[n];
00181 }
00182
00188 static inline uint64 GetDParam(uint n)
00189 {
00190 return _global_string_params.GetParam(n);
00191 }
00192
00193 extern TextDirection _current_text_dir;
00194
00195 void InitializeLanguagePacks();
00196 const char *GetCurrentLanguageIsoCode();
00197
00198 int CDECL StringIDSorter(const StringID *a, const StringID *b);
00199
00203 class MissingGlyphSearcher {
00204 public:
00206 virtual ~MissingGlyphSearcher() {}
00207
00212 virtual const char *NextString() = 0;
00213
00218 virtual FontSize DefaultSize() = 0;
00219
00223 virtual void Reset() = 0;
00224
00229 virtual bool Monospace() = 0;
00230
00236 virtual void SetFontNames(struct FreeTypeSettings *settings, const char *font_name) = 0;
00237
00238 bool FindMissingGlyphs(const char **str);
00239 };
00240
00241 void CheckForMissingGlyphs(bool base_font = true, MissingGlyphSearcher *search = NULL);
00242
00243 #endif