MCPcopy Create free account
hub / github.com/Audio4Linux/JDSP4Linux / isElementLast

Method isElementLast

3rdparty/qtcsv-qt5/sources/reader.cpp:421–462  ·  view source on GitHub ↗

Check if current element is the last element @input: - str - string with data - startPos - start position of the current element in the string - separator - string or character that separate elements - textDelimiter - string that is used as text delimiter @output: - bool - True if the current element is the last element of the string, False otherwise

Source from the content-addressed store, hash-verified

419// - bool - True if the current element is the last element of the string,
420// False otherwise
421bool ReaderPrivate::isElementLast(
422 const QString& str,
423 const int& startPos,
424 const QString& separator,
425 const QString& txtDelim)
426{
427 if (str.isEmpty() ||
428 startPos < 0 ||
429 separator.isEmpty() ||
430 txtDelim.isEmpty())
431 {
432 return false;
433 }
434
435 // Check if string ends with text delimiter. If not, then this element
436 // do not ends on this line
437 if (false == str.endsWith(txtDelim)) { return false; }
438
439 // Check that this is really the end symbols of the
440 // element and we don't mix up it with double delimiter.
441 // Calc number of delimiter symbols from end
442 // to startPos that stands together.
443 int numOfDelimiters = 0;
444 for (int pos = str.size() - 1; startPos <= pos; --pos, ++numOfDelimiters)
445 {
446 QStringRef strRef = str.midRef(pos, txtDelim.size());
447 if (QStringRef::compare(strRef, txtDelim) != 0)
448 {
449 break;
450 }
451 }
452
453 // If we have odd number of delimiter symbols that stand together,
454 // then this is the even number of double delimiter symbols + last
455 // delimiter symbol. That means that this element is the last on the line.
456 if (numOfDelimiters % 2 == 1)
457 {
458 return true;
459 }
460
461 return false;
462}
463
464// Remove extra symbols (spaces, text delimeters...)
465// @input:

Callers

nothing calls this directly

Calls 3

compareFunction · 0.85
isEmptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected