fix DConfig warnings when PRC_SAVE_DESCRIPTIONS is not defined

This commit is contained in:
David Rose 2004-12-17 17:56:33 +00:00
parent feb4266c44
commit 5ad50c7bcd
3 changed files with 25 additions and 19 deletions

View File

@ -30,6 +30,7 @@
#include "configVariableInt.h" #include "configVariableInt.h"
#include "configVariableDouble.h" #include "configVariableDouble.h"
#include "configVariableList.h" #include "configVariableList.h"
#include "configFlags.h"
#include <vector> #include <vector>
#include <map> #include <map>
@ -157,7 +158,7 @@ ConfigTable::Symbol& Config<GetConfig>::GetAll(const ConfigString sym,
ConfigTable::Symbol& s) ConfigTable::Symbol& s)
{ {
Init(); Init();
ConfigVariableList var(sym, "DConfig"); ConfigVariableList var(sym, "DConfig", ConfigFlags::F_dconfig);
int num_values = var.get_num_values(); int num_values = var.get_num_values();
for (int i = 0; i < num_values; i++) { for (int i = 0; i < num_values; i++) {
@ -172,7 +173,7 @@ template<class GetConfig>
bool Config<GetConfig>::GetBool(const ConfigString sym, bool def) bool Config<GetConfig>::GetBool(const ConfigString sym, bool def)
{ {
Init(); Init();
ConfigVariableBool var(sym, def, "DConfig"); ConfigVariableBool var(sym, def, "DConfig", ConfigFlags::F_dconfig);
return var.get_value(); return var.get_value();
} }
@ -180,7 +181,7 @@ template<class GetConfig>
int Config<GetConfig>::GetInt(const ConfigString sym, int def) int Config<GetConfig>::GetInt(const ConfigString sym, int def)
{ {
Init(); Init();
ConfigVariableInt var(sym, def, "DConfig"); ConfigVariableInt var(sym, def, "DConfig", ConfigFlags::F_dconfig);
return var.get_value(); return var.get_value();
} }
@ -188,7 +189,7 @@ template<class GetConfig>
float Config<GetConfig>::GetFloat(const ConfigString sym, float def) float Config<GetConfig>::GetFloat(const ConfigString sym, float def)
{ {
Init(); Init();
ConfigVariableDouble var(sym, def, "DConfig"); ConfigVariableDouble var(sym, def, "DConfig", ConfigFlags::F_dconfig);
return var.get_value(); return var.get_value();
} }
@ -196,7 +197,7 @@ template<class GetConfig>
double Config<GetConfig>::GetDouble(const ConfigString sym, double def) double Config<GetConfig>::GetDouble(const ConfigString sym, double def)
{ {
Init(); Init();
ConfigVariableDouble var(sym, def, "DConfig"); ConfigVariableDouble var(sym, def, "DConfig", ConfigFlags::F_dconfig);
return var.get_value(); return var.get_value();
} }
@ -205,7 +206,7 @@ ConfigString Config<GetConfig>::GetString(const ConfigString sym,
const ConfigString def) const ConfigString def)
{ {
Init(); Init();
ConfigVariableString var(sym, def, "DConfig"); ConfigVariableString var(sym, def, "DConfig", ConfigFlags::F_dconfig);
return var.get_value(); return var.get_value();
} }

View File

@ -54,6 +54,11 @@ PUBLISHED:
// (possibly from a very large pool) and should not be included in // (possibly from a very large pool) and should not be included in
// the normal list of variable names. // the normal list of variable names.
F_dynamic = 0x00004000, F_dynamic = 0x00004000,
// F_dconfig means that the variable was constructed from the
// legacy DConfig system, rather than directly by the user. You
// shouldn't pass this in directly.
F_dconfig = 0x00008000,
}; };
}; };

View File

@ -95,11 +95,11 @@ ConfigVariableCore::
void ConfigVariableCore:: void ConfigVariableCore::
set_value_type(ConfigVariableCore::ValueType value_type) { set_value_type(ConfigVariableCore::ValueType value_type) {
if (_value_queried && _value_type != value_type) { if (_value_queried && _value_type != value_type) {
if (_description == "DConfig") { if ((_flags & F_dconfig) != 0) {
// As a special exception, if the current description is // As a special exception, if the flags include F_dconfig, we
// "DConfig", we don't report a warning for changing the type, // don't report a warning for changing the type, assuming the
// assuming the variable is being defined through the older // variable is being defined through the older DConfig
// DConfig interface. // interface.
} else { } else {
prc_cat->warning() prc_cat->warning()
@ -147,9 +147,9 @@ set_flags(int flags) {
void ConfigVariableCore:: void ConfigVariableCore::
set_description(const string &description) { set_description(const string &description) {
if (_value_queried && _description != description) { if (_value_queried && _description != description) {
if (description == "DConfig") { if ((_flags & F_dconfig) != 0) {
// As a special exception, if the new description is "DConfig", // As a special exception, if the flags include F_dconfig, we
// we don't change it, since this is presumably coming from the // don't change it, since this is presumably coming from the
// older DConfig interface. // older DConfig interface.
return; return;
} }
@ -179,11 +179,11 @@ set_default_value(const string &default_value) {
// Modifying an existing default value. // Modifying an existing default value.
if (_default_value->get_string_value() != default_value) { if (_default_value->get_string_value() != default_value) {
if (_description == "DConfig") { if ((_flags & F_dconfig) != 0) {
// As a special exception, if the current description is // As a special exception, if the flags include F_dconfig, we
// "DConfig", we don't report a warning for changing the // don't report a warning for changing the default value,
// default value, assuming the variable is being defined // assuming the variable is being defined through the older
// through the older DConfig interface. // DConfig interface.
} else { } else {
prc_cat->warning() prc_cat->warning()