Ad van der Weiden / Mbed 2 deprecated tcpft

Dependencies:   mbed ConfigFile

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers myconfig.h Source File

myconfig.h

00001 #ifndef MYCONFIG_H
00002 #define MYCONFIG_H
00003 #include "ConfigFile.h"
00004 #include <string.h>
00005 
00006 class myConfig: public ConfigFile {
00007 public:
00008     static const int MAXLEN_VALUE = 128;//redeclared because inaccessible
00009     int getInt(char *key, int dflt=0) {
00010         char value[MAXLEN_VALUE];
00011         if (getValue(key, value, sizeof(value))) {
00012             int val=dflt;
00013             sscanf(value,"%d", &val);
00014             return val;
00015         }
00016         return dflt;
00017     }
00018     int getLookup(char *key, char*names[], int n) {
00019         char value[MAXLEN_VALUE];
00020         if (getValue(key, value, sizeof(value))) {
00021             for (int i = 0; i < n; i++)
00022                 if (strcmp(value, names[i])==0)
00023                     return i;
00024         }
00025         return n;
00026     }
00027 };
00028 
00029 #endif