forked from bneedhamia/sdconfigfile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSDConfigFile2.h
More file actions
76 lines (62 loc) · 2.26 KB
/
SDConfigFile2.h
File metadata and controls
76 lines (62 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef SDConfigFile_h
#define SDConfigFile_h
/*
* SD card configuration file reading library
*
* Copyright (c) 2014, 2017 Bradford Needham
* (@bneedhamia, https://www.needhamia.com )
* Licensed under LGPL version 2.1
* a version of which should have been supplied with this file.
*
* The library supports one #define:
* #define SDCONFIGFILE_DEBUG 1 // to print file error messages.
*/
#include <Arduino.h>
#include <SPI.h>
#include <SdFat.h>
#define BUFFER_MARKER '*' // will mark in the config file where bytes are reserved for the value field
class SDConfigFile
{
private:
File _file; // the open configuration file
boolean _atEnd; // If true, there is no more of the file to read.
char *_line; // the current line of the file (see _lineLength)
// Allocated by begin().
uint8_t _lineSize; // size (bytes) of _line[]
uint8_t _lineLength; // length (bytes) of the current line so far.
int8_t _valueIdx; // position in _line[] where the value starts
// (or -1 if none)
// (the name part is at &_line[0])
void remove_chars(char* str, char c); // will clean up strings, remove unwanted characters
void setNewValue(const char *newValue);
public:
boolean begin(const char *configFileName, uint8_t maxLineLength, SdFat *SD);
void end();
boolean readNextSetting();
boolean nameIs(const char *name);
//const char *getRawLine();
const char *getName();
const char *getRawValue();
const char *getCleanValue();
const char *getCleanString();
//**********************************
void setValue(const char *newValue);
void setValue(bool newValue);
void setValue(int newValue);
void setValue(double newValue);
void setStringValue(const char *newValue);
void setBooleanValue(bool newValue);
void setIntValue(int newValue);
void setDoubleValue(double newValue);
//**********************************
void getValue(char* updateValue);
void getValue(char** updateValue);
void getValue(boolean* updateValue);
void getValue(int* updateValue);
void getValue(double* updateValue);
char *getStringValue();
boolean getBooleanValue();
int getIntValue();
double getDoubleValue();
};
#endif