Expose static PrintConfig objects to Perl and test apply()

This commit is contained in:
Alessandro Ranellucci 2013-12-21 16:32:11 +01:00
parent 56d4da2ac7
commit e0c0a42a8b
5 changed files with 35 additions and 6 deletions

View file

@ -11,8 +11,13 @@ ConfigBase::apply(ConfigBase &other, bool ignore_nonexistent) {
// loop through options and apply them
for (t_config_option_keys::const_iterator it = opt_keys.begin(); it != opt_keys.end(); ++it) {
ConfigOption* my_opt = this->option(*it);
if (my_opt == NULL && ignore_nonexistent == false) throw "Attempt to apply non-existent option";
*my_opt = *(other.option(*it));
if (my_opt == NULL) {
if (ignore_nonexistent == false) throw "Attempt to apply non-existent option";
continue;
}
// not the most efficient way, but easier than casting pointers to subclasses
my_opt->deserialize( other.option(*it)->serialize() );
}
}