Skip to content

Commit 2b62f6f

Browse files
Add new method to look for a flag in all parameters (#16)
* 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]>
1 parent 9f278d3 commit 2b62f6f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/CmdParser.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,24 @@ class CmdParser
157157
return false;
158158
}
159159

160+
/**
161+
* Checks if a parameter/flag exists among all
162+
* other passed command parameters.
163+
*
164+
* @param value String to look for among the parameters
165+
* @return TRUE if found
166+
*/
167+
bool cmdParamExists(CmdParserString value)
168+
{
169+
for (uint16_t i = 1; i < m_paramCount; i++) {
170+
if (equalCmdParam(i, value)) {
171+
return true;
172+
}
173+
}
174+
175+
return false;
176+
}
177+
160178
#if defined(__AVR__) || defined(ESP8266)
161179

162180
/**

0 commit comments

Comments
 (0)