#ifndef __CONFIG_FILE_H__ #define __CONFIG_FILE_H__ /* Usage * ConfigFile cf("config.txt"); * * std::string foo; * std::string water; * double four; * * foo = cf.Value("section_1","foo" ); * water = cf.Value("section_2","water"); * four = cf.Value("section_2","four" ); * * std::cout << foo << std::endl; * std::cout << water << std::endl; * std::cout << four << std::endl; * * From a config file like this: * * [section_1] * foo = bar * water= h2o * * [section_2] * foo = foo * water= wet * four = 4.2 */ #include #include #include #include "Value.h" class ConfigFile { std::multimap content_; typedef std::multimap::const_iterator content_iterator; public: ConfigFile(); ConfigFile(std::string const& configFile); bool Open(std::string const& configFile); std::string DumpConfig() const; Value const& GetValue(std::string const& section, std::string const& entry) const; std::vector GetValues(std::string const& section, std::string const& entry) const; Value const& GetValue(std::string const& section, std::string const& entry, double value); Value const& GetValue(std::string const& section, std::string const& entry, std::string const& value); }; namespace ConfigHelper { std::map ParseArguments(const std::string& args); int StringToInt(const std::string& input); } #endif