Config.h revision 10447:a465576671d4
1#ifndef __LIBUTIL_CONFIG_H__ 2#define __LIBUTIL_CONFIG_H__ 3 4#include <iostream> 5 6#include "Map.h" 7 8namespace LibUtil 9{ 10 class Config : public StringMap 11 { 12 public: 13 Config(const String& delimiter_ = "=", const String& comment_ = "#", const String& sentry_ = "End"); 14 Config(const Config& config_); 15 virtual ~Config(); 16 17 public: 18 // Make a copy of this instance 19 virtual Config* clone() const; 20 // Load the config from file 21 virtual void readFile(const String& filename_); 22 // Parse string and overwrite the Config instance if keys exist 23 virtual void readString(const String& str_); 24 25 // Write or read map using standard IO 26 friend std::ostream& operator<<(std::ostream& ost_, const Config& config_); 27 friend std::istream& operator>>(std::istream& ist_, Config& config_); 28 29 protected: 30 String mDelimiter; 31 String mComment; 32 String mSentry; 33 }; 34} 35 36#endif // __LIBUTIL_CONFIG_H__ 37 38