/* * Should be a great addition to boost. But what about the uglyness of the print_T macro? * Is there any way to solve this problem without suckage? * Templating or function wrapping the type() and typeid() is not really feasible is it? * I don't really wanna implement the merge function without actually knwoing what to do about the "dynamic typing" of the boost::any * The most important flaw is, that it only works for the types that are hard-coded. * Sort of defeats the point of "dynamic typing". */ #include #include #include "boost/config.hpp" #define BOOST_PROGRAM_OPTIONS_SOURCE #include "boost/program_options.hpp" #include "boost/program_options/config.hpp" #include "boost/program_options/parsers.hpp" #include "boost/filesystem/operations.hpp" namespace boost { namespace program_options { using namespace std; // writes contents of m that is defined in desc into os template void persist_to_config_file(std::basic_ostream& os, const options_description& desc, const variables_map& m) { typedef map > gmap; gmap groups; const vector >& options = desc.options(); // build the group map and add the respective options for (unsigned i = 0; i < options.size(); ++i) { const option_description& d = *options[i]; const string ln = d.long_name(); if(ln.empty()) continue; size_t j = ln.find_last_of('.'); string group_key = jsecond.push_back(&d); } // write out the map for(gmap::const_iterator ci = groups.begin(); ci != groups.end(); ++ci) { if(ci->first.size())os<<"\n["<first<<"]"<second); for(int i = 0; i