
Own fork of MbedSmartRestMain
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
Diff: util/dict.h
- Revision:
- 98:e369fc75c000
- Parent:
- 95:5dfdc8568e9f
- Child:
- 100:dbcd3bc51758
--- a/util/dict.h Mon Apr 27 13:30:21 2015 +0000 +++ b/util/dict.h Thu May 07 09:57:55 2015 +0000 @@ -3,7 +3,7 @@ #include <string.h> #define MAX_KEY_LEN 50 #define MAX_VALUE_LEN 50 -#define MAX_ITEM_SIZE 5 +#define MAX_ITEM_SIZE 3 class Dict { @@ -43,11 +43,18 @@ } size_t maxSize() const { return MAX_ITEM_SIZE; } - size_t maxKeyLen() const { return MAX_KEY_LEN; } - size_t maxValueLen() const { return MAX_VALUE_LEN; } size_t size() const { return count; } bool empty() const { return count==0; } bool full() const { return count == MAX_ITEM_SIZE; } + void clear() { count = 0; } + size_t dump(char* buf) { + size_t l = 0; + for (size_t i = 0; i < count; ++i) { + l + sprintf(buf+l, "%s=%s;", items[i].key, items[i].value); + } + buf[l] = 0; + return l; + } virtual ~Dict() {} protected: size_t find(const char* k) const {