From 8d387f547a2d313b2adce9a949ec72c1d2c8b373 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Mon, 13 Jun 2016 08:51:40 +0200 Subject: [PATCH] upps --- src/CmdParser.hpp | 69 +++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/src/CmdParser.hpp b/src/CmdParser.hpp index 6a81d6a..d8ad176 100644 --- a/src/CmdParser.hpp +++ b/src/CmdParser.hpp @@ -4,8 +4,8 @@ * https://github.com/pvizeli/CmdParser */ -#ifndef CMDPARSER_H -#define CMDPARSER_H +#ifndef _CMDPARSER_H_ +#define _CMDPARSER_H_ #if defined(__AVR__) #include @@ -22,7 +22,9 @@ const uint8_t CMDPARSER_CHAR_DQ = 0x22; const uint8_t CMDPARSER_CHAR_EQ = 0x3D; const uint16_t CMDPARSER_ERROR = 0xFFFF; -typedef PGM_P CmdParserString_P; +#if defined(__AVR__) || defined(ESP8266) +typedef PGM_P CmdParserString_P; +#endif typedef const char *CmdParserString; /** @@ -110,22 +112,6 @@ class CmdParser return false; } - /** - * Check if param equal with value case sensitive. - * - * @param idx Number of param to get - * @param value String to compare in PROGMEM - * @return TRUE is equal - */ - bool equalCmdParam_P(uint16_t idx, CmdParserString_P value) - { - if (strcasecmp_P(this->getCmdParam(idx), value) == 0) { - return true; - } - - return false; - } - /** * Check if command equal with value case sensitive. * @@ -138,26 +124,37 @@ class CmdParser } /** - * Check if command equal with value case sensitive. + * Check if value equal from key case sensitive. * + * @param key Key store in SRAM for search in cmd * @param value String to compare in PROGMEM * @return TRUE is equal */ + bool equalValueFromKey(CmdParserString key, CmdParserString value) + { + if (strcasecmp(this->getValueFromKey(key, false), value) == 0) { + return true; + } + + return false; + } + +#if defined(__AVR__) || defined(ESP8266) + + /** + * @see equalCommand + */ bool equalCommand_P(CmdParserString_P value) { return this->equalCmdParam_P(0, value); } /** - * Check if value equal from key case sensitive. - * - * @param key Key store in SRAM for search in cmd - * @param value String to compare in PROGMEM - * @return TRUE is equal + * @see equalValueFromKey */ - bool equalValueFromKey(CmdParserString key, CmdParserString value) + bool equalValueFromKey_P(CmdParserString key, CmdParserString value) { - if (strcasecmp(this->getValueFromKey(key, false), value) == 0) { + if (strcasecmp_P(this->getValueFromKey(key, true), value) == 0) { return true; } @@ -165,15 +162,11 @@ class CmdParser } /** - * Check if value equal from key case sensitive. - * - * @param key Key store in PROGMEM for search in cmd - * @param value String to compare in PROGMEM - * @return TRUE is equal + * @see equalCmdParam */ - bool equalValueFromKey_P(CmdParserString key, CmdParserString value) + bool equalCmdParam_P(uint16_t idx, CmdParserString_P value) { - if (strcasecmp_P(this->getValueFromKey(key, true), value) == 0) { + if (strcasecmp_P(this->getCmdParam(idx), value) == 0) { return true; } @@ -181,17 +174,15 @@ class CmdParser } /** - * If KeyValue option is set, search the value from a key pair. - * KEY=Value i.e. KEY is upper case @see setOptCmdUpper. - * - * @param key Key store in PROGMEM for search in cmd - * @return String with value or NULL if not exists + * @see getValueFromKey */ char *getValueFromKey_P(CmdParserString_P key) { return this->getValueFromKey(key, true); } +#endif + /** * Set parser option to ignore " quote for string. * Default is off