Version initiale

Dependencies:   mbed

Fork of Le_Pont_V10116 by SAGNES Christophe

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers IniParser.h Source File

IniParser.h

00001 /*
00002  * IniParser.h
00003  *
00004  *  Created on: 5 sept. 2017
00005  *      Author: christophe.sagnes
00006  */
00007 
00008 #ifndef INIPARSER_H_
00009 #define INIPARSER_H_
00010 
00011 #include <fstream>
00012 #include <sstream>
00013 #include <string>
00014 #include <map>
00015 #include <iostream>
00016 #include "mbed.h"
00017 
00018 class INIParser {
00019 
00020  private:
00021     std::map<std::string, std::map<std::string, std::string> > ini;
00022     std::string FileName;
00023     bool AutoSave;
00024 
00025 public:
00026     INIParser(const std::string &, bool=false);
00027     virtual ~INIParser();
00028 
00029      // permet de recupérer une valeur, et retourne une valeur par defaut si la clef n'est pas trouvée
00030      template <class T> T GetValue(const std::string &, const std::string &, const T &);
00031      // permet d'enregistrer une valeur, ou d'en modifier une existante.
00032      template <class T> void SetValue(const std::string &, const std::string &, const T &);
00033      // enregistre la map dans un fichier.
00034      bool save(std::string="");
00035      
00036      // permet de recupérer un entier, et retourne une valeur par defaut si la clef n'est pas trouvée
00037      int GetInt(const std::string &, const std::string &, const int &);
00038 
00039 };
00040 
00041 #endif /* INIFILE_H_ */