Simple config file class with added support for floats

Fork of ConfigFile by peter brier

Committer:
pbrier
Date:
Thu Jan 27 21:08:51 2011 +0000
Revision:
0:57f3e167586f
Child:
1:a802df951169
1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pbrier 0:57f3e167586f 1 /*
pbrier 0:57f3e167586f 2 * ConfigFile.cpp
pbrier 0:57f3e167586f 3 * Simple Config file reader class
pbrier 0:57f3e167586f 4 *
pbrier 0:57f3e167586f 5 * Copyright (c) 2011 Peter Brier
pbrier 0:57f3e167586f 6 *
pbrier 0:57f3e167586f 7 * This file is part of the LaOS project (see: http://wiki.protospace.nl/index.php/LaOS)
pbrier 0:57f3e167586f 8 *
pbrier 0:57f3e167586f 9 * LaOS is free software: you can redistribute it and/or modify
pbrier 0:57f3e167586f 10 * it under the terms of the GNU General Public License as published by
pbrier 0:57f3e167586f 11 * the Free Software Foundation, either version 3 of the License, or
pbrier 0:57f3e167586f 12 * (at your option) any later version.
pbrier 0:57f3e167586f 13 *
pbrier 0:57f3e167586f 14 * LaOS is distributed in the hope that it will be useful,
pbrier 0:57f3e167586f 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
pbrier 0:57f3e167586f 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
pbrier 0:57f3e167586f 17 * GNU General Public License for more details.
pbrier 0:57f3e167586f 18 *
pbrier 0:57f3e167586f 19 * You should have received a copy of the GNU General Public License
pbrier 0:57f3e167586f 20 * along with LaOS. If not, see <http://www.gnu.org/licenses/>.
pbrier 0:57f3e167586f 21 *
pbrier 0:57f3e167586f 22 * Reads a setting, based on the key. (case sensitive)
pbrier 0:57f3e167586f 23 * If the key is not found, the default value is returned.
pbrier 0:57f3e167586f 24 *
pbrier 0:57f3e167586f 25 * Simple, not (time) efficient. For every request, the complete file is reset and read again
pbrier 0:57f3e167586f 26 * file format:
pbrier 0:57f3e167586f 27 *
pbrier 0:57f3e167586f 28 * ; comment
pbrier 0:57f3e167586f 29 * key value [newline || comment]
pbrier 0:57f3e167586f 30 *
pbrier 0:57f3e167586f 31 *
pbrier 0:57f3e167586f 32 * note: NULL key does nothing
pbrier 0:57f3e167586f 33 */
pbrier 0:57f3e167586f 34
pbrier 0:57f3e167586f 35 #include "mbed.h"
pbrier 0:57f3e167586f 36
pbrier 0:57f3e167586f 37 #ifndef _CONFIG_FILE_H_
pbrier 0:57f3e167586f 38 #define _CONFIG_FILE_H_
pbrier 0:57f3e167586f 39
pbrier 0:57f3e167586f 40 class ConfigFile {
pbrier 0:57f3e167586f 41 public:
pbrier 0:57f3e167586f 42 ConfigFile(char *name);
pbrier 0:57f3e167586f 43 ~ConfigFile();
pbrier 0:57f3e167586f 44 bool Value(char *key, char *value, size_t maxlen, char *def);
pbrier 0:57f3e167586f 45 bool Value(char *key, int *value, int def);
pbrier 0:57f3e167586f 46 private:
pbrier 0:57f3e167586f 47 FILE *fp;
pbrier 0:57f3e167586f 48 };
pbrier 0:57f3e167586f 49
pbrier 0:57f3e167586f 50 #endif