/* * Copyright (c) 2002, Stefan Farfeleder * $Id: conffile.h,v 1.1 2002/09/08 19:27:58 stefan Exp $ */ #ifndef JFK_CONFIG_H #define JFK_CONFIG_H #include #include namespace JFK { struct variable { const char* name; /* name of the variable */ const char* def_val; /* value if not occuring in the config-file */ /* Returns 'true' if 's' is an acceptable value for the variable */ bool (*value_checker)(const std::string& s); }; class conffile { public: conffile(const variable* ce, size_t n, const char* filename); void read(); void write(); const std::string getvar(const std::string& name) const; void setvar(const std::string& name, const std::string& val); private: struct varmap_entry { std::string value; const variable* ce; }; typedef std::map varmap; std::string fn; varmap m; }; } #endif