MCPcopy Create free account
hub / github.com/BlueAndi/Pixelix / isFormatSpecifierInStr

Method isFormatSpecifierInStr

lib/Utilities/src/Util.cpp:319–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317}
318
319bool Util::isFormatSpecifierInStr(const String& str, char specifier)
320{
321 bool isFound = false;
322 int32_t index = 0U;
323 const size_t STR_LENGTH = str.length();
324
325 while (STR_LENGTH > index)
326 {
327 index = str.indexOf('%', index);
328
329 if (0 > index)
330 {
331 break;
332 }
333
334 if (STR_LENGTH > (index + 1))
335 {
336 int32_t specifierIndex = index + 1;
337
338 /* Skip flags, width, and precision */
339 while ((STR_LENGTH > specifierIndex) &&
340 ((str[specifierIndex] == '-') || (str[specifierIndex] == '+') || (str[specifierIndex] == ' ') ||
341 (str[specifierIndex] == '#') || (str[specifierIndex] == '0') || (0 < std::isdigit(str[specifierIndex])) ||
342 (str[specifierIndex] == '.')))
343 {
344 ++specifierIndex;
345 }
346
347 if ((STR_LENGTH > specifierIndex) && (specifier == str[specifierIndex]))
348 {
349 isFound = true;
350 break;
351 }
352 }
353
354 ++index;
355 }
356
357 return isFound;
358}
359
360/******************************************************************************
361 * Local Functions

Callers

nothing calls this directly

Calls 2

indexOfMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected