Wrapping Boost ptree to keep a map of loaded xml tag
{ Reformatted; please limit your lines to 70 characters -mod }
As mentioned in title:
struct AXmlConfigurator : private boost::noncopyable {
protected:
std::string configuration_file_;
std::map<std::string, std::string> parameters_;
ptree ptree_;
public:
AXmlConfigurator(const std::string &argConfigurationFile) :
configuration_file_(argConfigurationFile) {
read_xml(configuration_file_, ptree_);
}
~AXmlConfigurator() {}
template<typename Type> inline
Type get(const std::string & argPath, Type argDefault) const {
Type value = ptree_.get<Type>(argPath, argDefault);
parameters_.insert(std::make_pair(argPath, value));
return value;
}
template<class Type , class Translator> inline
typename boost::enable_if<detail::is_translator<Translator>, Type>::type
get(const std::string &argPath, const Type &argDefault, Translator tr)
const {
Type value = ptree_.get(argPath, argDefault);
parameters_.insert(std::make_pair(argPath, value));
return value;
}
void logConfiguration() {
for(std::map<std::string, std::string>::const_iterator it =
parameters_.begin() ; it != parameters_.end() ; ++it) {
std::cout << (*it).first << " => " << (*it).second << std::endl;
}
}
};
I want to wrap boost::property_tree::ptree to store the
parameters/values as strings into a map and display them afterward
through logConfiguration.
The probleme is that map's insert does not accept value as a string
because value type is unspecified...
I'm out of ideas, so any help is appreciated!
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]