Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:43:50

0001 #ifndef INI_FILE_PARSER
0002 #define INI_FILE_PARSER
0003 
0004 /**
0005  * @file IniFileParser.h
0006  * @version 2.0
0007  * @author Bryan BERTHOU (SPhN / CEA Saclay)
0008  * @author <contributor> Adrien KIELB (Modulo PI - Paris)
0009  * @date 18 September 2014
0010  * Last update : 19 September 2014
0011  */
0012 
0013 #include <map>
0014 #include <string>
0015 
0016 namespace ElemUtils {
0017 
0018 /**
0019  * @class IniFileParser
0020  * @brief
0021  */
0022 class IniFileParser {
0023 public:
0024     static std::string SECTION_KEY_CONCATENATOR;
0025 
0026     /**
0027      * Constructor
0028      *
0029      * @param configFilePath
0030      */
0031     IniFileParser();
0032 
0033     /**
0034      * Default destructor
0035      */
0036     virtual ~IniFileParser();
0037 
0038     void parse(const std::string & configFilePath);
0039 
0040     std::map<std::string, std::string> getValues();
0041 
0042     std::string getString(const std::string & key);
0043     std::string getString(const std::string & section, const std::string & key);
0044 
0045     bool checkIfAvailable(const std::string & section,
0046             const std::string & key) const;
0047     bool checkIfAvailable(const std::string & key) const;
0048 
0049     const std::string& getFilePath() const;
0050 
0051 private:
0052     std::string m_filePath;
0053 
0054     std::map<std::string, std::string> m_values;
0055     std::map<std::string, std::string>::iterator m_it;
0056 
0057     void analyse(std::string & fileLine, std::string & sectionName,
0058             const unsigned int fileLineNumber);
0059     void analyseSection(const std::string & fileLine, std::string & sectionName,
0060             const unsigned int fileLineNumber);
0061     void analyseValue(const std::string & fileLine,
0062             const std::string & sectionName);
0063     std::string makeKey(const std::string & sectionName,
0064             const std::string & key) const;
0065 };
0066 
0067 } // namespace ElemUtils
0068 
0069 #endif /* INI_FILE_PARSER */