MCPcopy Create free account
hub / github.com/ZDoom/Raze / ParseLanguageCSV

Method ParseLanguageCSV

source/common/engine/stringtable.cpp:189–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187//==========================================================================
188
189bool FStringTable::ParseLanguageCSV(int filenum, const char* buffer, size_t size)
190{
191 if (size < 11) return false;
192 if (strnicmp(buffer, "default,", 8) && strnicmp(buffer, "identifier,", 11 )) return false;
193 auto data = parseCSV(buffer, size);
194
195 int labelcol = -1;
196 int filtercol = -1;
197 TArray<std::pair<int, unsigned>> langrows;
198 bool hasDefaultEntry = false;
199
200 if (data.Size() > 0)
201 {
202 for (unsigned column = 0; column < data[0].Size(); column++)
203 {
204 auto &entry = data[0][column];
205 if (entry.CompareNoCase("filter") == 0)
206 {
207 filtercol = column;
208 }
209 else if (entry.CompareNoCase("identifier") == 0)
210 {
211 labelcol = column;
212 }
213 else
214 {
215 auto languages = entry.Split(" ", FString::TOK_SKIPEMPTY);
216 for (auto &lang : languages)
217 {
218 if (lang.CompareNoCase("default") == 0)
219 {
220 langrows.Push(std::make_pair(column, default_table));
221 hasDefaultEntry = true;
222 }
223 else if (lang.Len() < 4)
224 {
225 lang.ToLower();
226 langrows.Push(std::make_pair(column, MAKE_ID(lang[0], lang[1], lang[2], 0)));
227 }
228 }
229 }
230 }
231
232 for (unsigned i = 1; i < data.Size(); i++)
233 {
234 auto &row = data[i];
235 if (filtercol > -1)
236 {
237 auto filterstr = row[filtercol];
238 if (filterstr.IsNotEmpty())
239 {
240 bool ok = false;
241 if (sysCallbacks.CheckGame)
242 {
243 auto filter = filterstr.Split(" ", FString::TOK_SKIPEMPTY);
244 for (auto& entry : filter)
245 {
246 if (sysCallbacks.CheckGame(entry.GetChars()))

Callers

nothing calls this directly

Calls 9

CompareNoCaseMethod · 0.80
SplitMethod · 0.80
LenMethod · 0.80
IsNotEmptyMethod · 0.80
StripLeftRightMethod · 0.80
SizeMethod · 0.45
PushMethod · 0.45
ToLowerMethod · 0.45
GetCharsMethod · 0.45

Tested by

no test coverage detected