Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of ConfigFile by
ConfigFile Class Reference
Simple config file object Only supports reading config files. More...
#include <ConfigFile.h>
Public Member Functions | |
| ConfigFile (char *name) | |
| Make new ConfigFile object. | |
| bool | Value (char *key, char *value, size_t maxlen, char *def) |
| Read value. | |
| bool | Value (char *key, int *value, int def) |
| Read Integer value. | |
| bool | Value (char *key, float *value, float def) |
| Read Float value. | |
Detailed Description
Simple config file object Only supports reading config files.
Tries to limit memory usage. Note: the file handle is kept open during the lifetime of this object. To close the file: destroy this ConfigFile object! A simple way is to enclose the creation of this object inside a code block Example:
char ip[16]; int port; { ConfigFile cfg("/local/config.txt"); cfg.Value("ip", ip, sizeof(ip), "192.168.1.10"); cfg.Value("port", &port, 80); }
Definition at line 63 of file ConfigFile.h.
Constructor & Destructor Documentation
| ConfigFile | ( | char * | name ) |
Make new ConfigFile object.
Open config file. Note: the file handle is kept open during the lifetime of this object. To close the file: destroy this ConfigFile object!
- Parameters:
-
file Filename of the configuration file.
Definition at line 26 of file ConfigFile.cpp.
Member Function Documentation
| bool Value | ( | char * | key, |
| char * | value, | ||
| size_t | maxlen, | ||
| char * | def | ||
| ) |
Read value.
If file is not open, or key does not exist: copy default value (return false)
- Parameters:
-
key name of the key in the file value pointer to buffer that receives the value maxlen the maximum length of the value. If the actual value is longer, it is truncated def Default value. If the key is not found in the file, this value is copied.
- Returns:
- "true" if the key is found "false" is key is not found (default value is returned)
Definition at line 41 of file ConfigFile.cpp.
| bool Value | ( | char * | key, |
| float * | value, | ||
| float | def | ||
| ) |
Read Float value.
If file is not open, or key does not exist: copy default value (return false)
- Parameters:
-
key name of the key in the file value pointer to integer that receives the value def Default value. If the key is not found in the file, this value is copied.
- Returns:
- "true" if the key is found "false" is key is not found (default value is returned)
Definition at line 133 of file ConfigFile.cpp.
| bool Value | ( | char * | key, |
| int * | value, | ||
| int | def | ||
| ) |
Read Integer value.
If file is not open, or key does not exist: copy default value (return false)
- Parameters:
-
key name of the key in the file value pointer to integer that receives the value def Default value. If the key is not found in the file, this value is copied.
- Returns:
- "true" if the key is found "false" is key is not found (default value is returned)
Definition at line 119 of file ConfigFile.cpp.
Generated on Wed Jul 13 2022 02:50:03 by
1.7.2
