From e7cf2fa020669bd88beefe634dd61e7bd33e2383 Mon Sep 17 00:00:00 2001 From: anschrammh Date: Sun, 17 Nov 2019 19:31:06 +0100 Subject: [PATCH] Added a handy way to retrieve the configuration of a config file without having to instantiate a parser - but I do not like it - might be removed in the future --- src/app/SDCardManager.cpp | 6 ++++++ src/app/SDCardManager.h | 14 +++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/app/SDCardManager.cpp b/src/app/SDCardManager.cpp index 821826e..d53e1c1 100644 --- a/src/app/SDCardManager.cpp +++ b/src/app/SDCardManager.cpp @@ -54,3 +54,9 @@ boolean SDCardManager::isMounted() { return _mounted; } + +CFGDictionary *SDCardManager::getCFGFile(const char *cfgFile) +{ + CFGFileParser cfgFileParser(*this, cfgFile); + return (CFGDictionary *) cfgFileParser.parseFile(); +} diff --git a/src/app/SDCardManager.h b/src/app/SDCardManager.h index 5ff2bf5..b5b3ad4 100644 --- a/src/app/SDCardManager.h +++ b/src/app/SDCardManager.h @@ -2,21 +2,29 @@ #define SDCARDMANAGER_H #include #include "definition.h" +#include "CFGDictionary.h" +#include "CFGParameterValue.h" +#include "CFGFileParser.h" class SDCardManager : public SDClass { friend class SAB; public: SDCardManager(const Pin csPin, SPISettings cfg); - double getSize(const SizeUnit sizeUnit = GBYTE); boolean mountSD(); void unMountSD(); - boolean isMounted(); - + /* + * Quick way to retrieve the keys and values of a config file. + * If you need to performe other actions on the file, you will have to use the CFGFileParser object instead + * Remember to free the returned object ie : delete + */ + CFGDictionary *getCFGFile(const char *cfgFile); + protected: SDCardManager(); + private: const Pin _csPin; SPISettings _spiCfg;