
Hi guys, I feel as part of the Boost community and having worked on multiple platforms that we're missing something to manage reading/writing configuration information for an application thread safely across platforms. The best example I know of that handles this job is Qt's QSettings which writes to the registry on windows, inis on linux, and some sort of xml on Mac OS X. The inspiration for this comes from the fact that I am looking to build web browser plugins that run on multiple platforms. I started by looking at how I could extend boost::program_options, and decided it wasn't the right tool because it was primarily for reading configurations, but not really writing to them. Likewise, it doesn't appear to provide anything in terms of thread safety. The interface should model after several things already in existence such as: QSettings, std::map, and tbb::concurrent_hash_map. It should also take into consideration how systems such as the Windows Registry works, as well as browser specific configuration systems like the one that comes with Mozilla Firefox, and of course file based storage. It should be easily extensible with a simple interface to implement a new backend with minimal work. At a later date, I think it should also be able to support things like boost::property_map or boost::fusion to make it easy to insert and extract objects from the underlying configuration system with automatic type conversion. I'm not sure how to combine it with boost::fusion or boost::property_map yet, so I'm hoping that's where you guys come in. Thanks, Dan Here is a preliminary interface: namespace boost { namespace dynamic_config { template<typename charT> class backend { public: enum operation_performed { none, // e.g. no value changed insert, update }; bool insert(basic_string<charT> key, (int, basic_string<charT>, bool, int64_t, char) value); // These values may be easily implementable with boost::variant, or separately if enable_if is used. bool update(basic_string<charT> key, (see above..) value); // Note this returns operation performed because optional locking will be done around these functions, so combining insert with update replaces a possible race condition over those 2 operations performed separately operation_performed replace(basic_string<charT> key, (...) value); template <T> bool select(basic_string<charT> key, T& value); // returns success if retrieved, this can also use boost::optional otherwise bool delete(basic_string<charT> key, bool cascade); // cascade takes effect if key takes a whole tree with it }; template <typename charT, typename Backend, typename Mutex> class property_config : boost::noncopyable { public: property_config(); property_config(basic_string<charT> organizationName, basic_string<charT> applicationName); // Pretty much required for use in the windows registry and in firefox ~property_config(); size_type erase(basic_string<charT> key); void clear(); template<typename T> bool find(basic_string<charT> key, T & value); template<typename T> bool insert(basic_string<charT> key, T value); template<typename T> bool update(basic_string<charT> key, T value); template<typename T> backend::operation_performed replace(basic_string<charT> key, T value); template<typename T> bool select(basic_string<charT> key, T& value); template<typename T> bool delete(basic_string<charT> key, T& value); }; template <typename charT, typename Backend, typename Mutex> template <typename T> backend::operation_performed property_config<charT, Backend, Mutex>::replace(basic_string<charT> key, T val) { scoped_lock(mutex_); backend_.replace(key,val); } } }