microbit: fixed overload ambiguity in MicroBitStorage
MicroBitStorage accepts both ManagedString and char * variants, this caused ambiguity at compile time, and meant that the ManagedString variant was never selected when given character literals. This meant that the only way to access the ManagedString variant, was to explicitly wrap the character literals. This applies to: * put * get * remove The fix was to apply a const prefix to all member functions accepting a char *.
This commit is contained in:
parent
468d7e24c5
commit
174fa29c81
|
@ -112,7 +112,7 @@ class MicroBitStorage
|
|||
*
|
||||
* @return MICROBIT_OK on success, or MICROBIT_NO_RESOURCES if our storage page is full
|
||||
*/
|
||||
int put(char* key, uint8_t* data);
|
||||
int put(const char* key, uint8_t* data);
|
||||
|
||||
/**
|
||||
* Places a given key, and it's corresponding value into flash at the earliest
|
||||
|
@ -133,7 +133,7 @@ class MicroBitStorage
|
|||
*
|
||||
* @note it is up to the user to free the returned struct.
|
||||
*/
|
||||
KeyValuePair* get(char* key);
|
||||
KeyValuePair* get(const char* key);
|
||||
|
||||
/**
|
||||
* Retreives a KeyValuePair identified by a given key.
|
||||
|
@ -155,7 +155,7 @@ class MicroBitStorage
|
|||
* @return MICROBIT_OK on success, or MICROBIT_NOT_SUPPORTED if the given key
|
||||
* was not found in flash.
|
||||
*/
|
||||
int remove(char* key);
|
||||
int remove(const char* key);
|
||||
|
||||
/**
|
||||
* Removes a KeyValuePair identified by a given key.
|
||||
|
|
|
@ -173,7 +173,7 @@ void MicroBitStorage::scratchKeyValuePair(KeyValuePair pair, uint32_t* flashPoin
|
|||
*
|
||||
* @return MICROBIT_OK on success, or MICROBIT_NO_RESOURCES if our storage page is full
|
||||
*/
|
||||
int MicroBitStorage::put(char *key, uint8_t *data)
|
||||
int MicroBitStorage::put(const char *key, uint8_t *data)
|
||||
{
|
||||
KeyValuePair pair = KeyValuePair();
|
||||
|
||||
|
@ -266,7 +266,7 @@ int MicroBitStorage::put(ManagedString key, uint8_t* data)
|
|||
*
|
||||
* @note it is up to the user to free the returned struct.
|
||||
*/
|
||||
KeyValuePair* MicroBitStorage::get(char* key)
|
||||
KeyValuePair* MicroBitStorage::get(const char* key)
|
||||
{
|
||||
//calculate our offsets for our storage page
|
||||
uint32_t pg_size = NRF_FICR->CODEPAGESIZE;
|
||||
|
@ -331,7 +331,7 @@ KeyValuePair* MicroBitStorage::get(ManagedString key)
|
|||
* @return MICROBIT_OK on success, or MICROBIT_NOT_SUPPORTED if the given key
|
||||
* was not found in flash.
|
||||
*/
|
||||
int MicroBitStorage::remove(char* key)
|
||||
int MicroBitStorage::remove(const char* key)
|
||||
{
|
||||
//calculate our various offsets
|
||||
uint32_t pg_size = NRF_FICR->CODEPAGESIZE;
|
||||
|
|
Loading…
Reference in New Issue