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
00018 class StringParameters {
00019 StringParameters *parent;
00020 uint64 *data;
00021 WChar *type;
00022
00023 public:
00024 uint offset;
00025 uint num_param;
00026
00028 StringParameters(uint64 *data, uint num_param, WChar *type) :
00029 parent(NULL),
00030 data(data),
00031 type(type),
00032 offset(0),
00033 num_param(num_param)
00034 { }
00035
00037 template <size_t Tnum_param>
00038 StringParameters(int64 (&data)[Tnum_param]) :
00039 parent(NULL),
00040 data((uint64 *)data),
00041 type(NULL),
00042 offset(0),
00043 num_param(Tnum_param)
00044 {
00045 assert_compile(sizeof(data[0]) == sizeof(uint64));
00046 }
00047
00052 StringParameters(StringParameters &parent, uint size) :
00053 parent(&parent),
00054 data(parent.data + parent.offset),
00055 offset(0),
00056 num_param(size)
00057 {
00058 assert(size <= parent.num_param - parent.offset);
00059 if (parent.type == NULL) {
00060 this->type = NULL;
00061 } else {
00062 this->type = parent.type + parent.offset;
00063 }
00064 }
00065
00066 ~StringParameters()
00067 {
00068 if (this->parent != NULL) {
00069 this->parent->offset += this->num_param;
00070 }
00071 }
00072
00073 void ClearTypeInformation();
00074
00079 int64 GetInt64(WChar type = 0)
00080 {
00081 assert(this->offset < this->num_param);
00082 if (this->type != NULL) {
00083 assert(this->type[this->offset] == 0 || this->type[this->offset] == type);
00084 this->type[this->offset] = type;
00085 }
00086 return this->data[this->offset++];
00087 }
00088
00090 int32 GetInt32(WChar type = 0)
00091 {
00092 return (int32)this->GetInt64(type);
00093 }
00094
00095 void ShiftParameters(uint amount);
00096
00098 uint64 *GetDataPointer() const
00099 {
00100 return &this->data[this->offset];
00101 }
00102
00104 uint64 *GetPointerToOffset(uint offset) const
00105 {
00106 assert(offset < this->num_param);
00107 return &this->data[offset];
00108 }
00109
00111 bool HasTypeInformation() const
00112 {
00113 return this->type != NULL;
00114 }
00115
00117 WChar GetTypeAtOffset(uint offset) const
00118 {
00119 assert(offset < this->num_param);
00120 assert(this->HasTypeInformation());
00121 return this->type[offset];
00122 }
00123
00124 void SetParam(uint n, uint64 v)
00125 {
00126 assert(n < this->num_param);
00127 this->data[n] = v;
00128 }
00129
00130 uint64 GetParam(uint n) const
00131 {
00132 assert(n < this->num_param);
00133 return this->data[n];
00134 }
00135 };
00136 extern StringParameters _global_string_params;
00137
00138 char *InlineString(char *buf, StringID string);
00139 char *GetString(char *buffr, StringID string, const char *last);
00140 char *GetStringWithArgs(char *buffr, uint string, StringParameters *args, const char *last);
00141 const char *GetStringPtr(StringID string);
00142
00143 void InjectDParam(uint amount);
00144
00151 static inline void SetDParamX(uint64 *s, uint n, uint64 v)
00152 {
00153 s[n] = v;
00154 }
00155
00161 static inline void SetDParam(uint n, uint64 v)
00162 {
00163 _global_string_params.SetParam(n, v);
00164 }
00165
00166 void SetDParamStr(uint n, const char *str);
00167
00168 void CopyInDParam(int offs, const uint64 *src, int num);
00169 void CopyOutDParam(uint64 *dst, int offs, int num);
00170
00177 static inline uint64 GetDParamX(const uint64 *s, uint n)
00178 {
00179 return s[n];
00180 }
00181
00187 static inline uint64 GetDParam(uint n)
00188 {
00189 return _global_string_params.GetParam(n);
00190 }
00191
00192 extern TextDirection _current_text_dir;
00193
00194 void InitializeLanguagePacks();
00195 const char *GetCurrentLanguageIsoCode();
00196
00197 int CDECL StringIDSorter(const StringID *a, const StringID *b);
00198
00199 void CheckForMissingGlyphsInLoadedLanguagePack();
00200
00201 #endif