Chatterino
Functions
chatterino::_helpers_internal Namespace Reference

Functions

int skipSpace (const QStringRef &view, int startPos)
 
bool matchesIgnorePlural (const QStringRef &word, const QString &singular)
 
std::pair< uint64_t, bool > findUnitMultiplierToSec (const QStringRef &view, int &pos)
 

Function Documentation

◆ findUnitMultiplierToSec()

std::pair< uint64_t, bool > chatterino::_helpers_internal::findUnitMultiplierToSec ( const QStringRef &  view,
int &  pos 
)

Tries to find the unit starting at pos and returns its multiplier so valueInUnit * multiplier = valueInSeconds (e.g. 60 for minutes).

Supported units are 'w[eek(s)]', 'd[ay(s)]', 'h[our(s)]', 'm[inute(s)]', 's[econd(s)]'. The unit must be in lowercase.

Parameters
viewA view into a string
posThe starting position. This is set to the last position of the unit if it's a valid unit, undefined otherwise.
Returns
(multiplier, ok)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ matchesIgnorePlural()

bool chatterino::_helpers_internal::matchesIgnorePlural ( const QStringRef &  word,
const QString &  expected 
)

Checks if word equals expected (singular) or expected + 's' (plural).

Parameters
wordWord to test. Must not be empty.
expectedSingular of the expected word.
Returns
true if word is singular or plural of expected.
Here is the caller graph for this function:

◆ skipSpace()

int chatterino::_helpers_internal::skipSpace ( const QStringRef &  view,
int  startPos 
)

Skips all spaces. The caller must guarantee view.at(startPos).isSpace().

Parameters
viewThe string to skip spaces in.
startPosThe starting position (there must be a space in the view).
Returns
The position of the last space.
Here is the caller graph for this function: