Added isKey method to Preferences (#4441)

Checks to see if a string is a key in the namespace. 

Fixes #4440
This commit is contained in:
lbernstone
2020-11-03 08:03:04 -07:00
committed by GitHub
parent 56a7ae8712
commit e2452c0dfc
2 changed files with 32 additions and 2 deletions

View File

@ -16,6 +16,10 @@
#include "Arduino.h"
typedef enum {
PT_I8, PT_U8, PT_I16, PT_U16, PT_I32, PT_U32, PT_I64, PT_U64, PT_STR, PT_BLOB, PT_INVALID
} PreferenceType;
class Preferences {
protected:
uint32_t _handle;
@ -48,6 +52,8 @@ class Preferences {
size_t putString(const char* key, String value);
size_t putBytes(const char* key, const void* value, size_t len);
bool isKey(const char* key);
PreferenceType getType(const char* key);
int8_t getChar(const char* key, int8_t defaultValue = 0);
uint8_t getUChar(const char* key, uint8_t defaultValue = 0);
int16_t getShort(const char* key, int16_t defaultValue = 0);
@ -63,7 +69,7 @@ class Preferences {
bool getBool(const char* key, bool defaultValue = false);
size_t getString(const char* key, char* value, size_t maxLen);
String getString(const char* key, String defaultValue = String());
size_t getBytesLength(const char* key);
size_t getBytesLength(const char* key);
size_t getBytes(const char* key, void * buf, size_t maxLen);
size_t freeEntries();
};