Skip to content

Commit

Permalink
Add new method to look for a flag in all parameters (#16)
Browse files Browse the repository at this point in the history
* Add new method to look for a flag in all parameters

A NULL check is added to avoid crash if parameter is out of range.

* Renamce the iteration method to cmdParamExists

I find this makes more sense.

* Change cmdParamExists description grammar

Co-authored-by: Pascal Vizeli <[email protected]>
  • Loading branch information
MohammedNoureldin and pvizeli authored Apr 11, 2022
1 parent 9f278d3 commit 2b62f6f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/CmdParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,24 @@ class CmdParser
return false;
}

/**
* Checks if a parameter/flag exists among all
* other passed command parameters.
*
* @param value String to look for among the parameters
* @return TRUE if found
*/
bool cmdParamExists(CmdParserString value)
{
for (uint16_t i = 1; i < m_paramCount; i++) {
if (equalCmdParam(i, value)) {
return true;
}
}

return false;
}

#if defined(__AVR__) || defined(ESP8266)

/**
Expand Down

0 comments on commit 2b62f6f

Please sign in to comment.