SBB Host
Host communication with the self balancing bike.
Loading...
Searching...
No Matches
IniReader.h
Go to the documentation of this file.
1
2#ifndef INIREADER_H
3#define INIREADER_H
4
5#include "File.h"
6#include <string>
7#include <vector>
8
9#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) || defined(__WIN32__) || defined(WIN64) || defined(_WIN64) || defined(__WIN64) || defined(__WIN64__)
10#ifndef OS_WIN
11#define OS_WIN
12#endif
13#elif defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNUC__) || defined(__GNUG__) || defined(unix) || defined(__unix) || defined(__unix__)
14#ifndef OS_LINUX
15#define OS_LINUX
16#endif
17#else
18#error OS not supported
19#endif
20
21#ifdef OS_LINUX
22#define sscanf_s sscanf //in linux use sscanf for sscanf_s
23#endif
24
41class IniReader {
42public:
47 IniReader(const char* name);
48
53
60 bool getInt(const char* key, int* val);
61
68 bool getDouble(const char* key, double* val);
69
76 bool getHex(const char* key, unsigned int* val);
77
84 bool getString(const char* key, std::string* val);
85
92 bool getStringArray(const char* key, std::vector<std::string>* str_array);
93
100 bool getDoubleArray(const char* key, std::vector<double>* double_array);
101
106 bool isOpen();
107
108private:
110 std::string _name;
111};
112
113#endif
A class for file reading and writing.
Definition: File.h:30
A class for configuration-file reading.
Definition: IniReader.h:41
bool isOpen()
Check if open correctly.
bool getString(const char *key, std::string *val)
Get string variable.
bool getInt(const char *key, int *val)
Get integer variable.
bool getDoubleArray(const char *key, std::vector< double > *double_array)
Get a double vector.
bool getDouble(const char *key, double *val)
Get double variable.
std::string _name
Name of the configuration file.
Definition: IniReader.h:110
bool getHex(const char *key, unsigned int *val)
Get an hex number.
File * p_file
Poinnter to the File object.
Definition: IniReader.h:109
IniReader(const char *name)
Constructor.
bool getStringArray(const char *key, std::vector< std::string > *str_array)
Get a string vector.
~IniReader()
Desctructor.