修改默认值条件判断变量
This commit is contained in:
parent
9fd6746a15
commit
826fb7fe6b
|
@ -989,7 +989,7 @@ void device_option::init_depends(gb_json* opt)
|
|||
opt->get_value("type", dpnd);
|
||||
if (range)
|
||||
{
|
||||
range_value* rv = new range_value();
|
||||
condition_value* rv = new condition_value();
|
||||
if (rv->set_value(range, dpnd.c_str(), this))
|
||||
init_value_[opt->key()] = rv;
|
||||
else
|
||||
|
@ -1027,25 +1027,18 @@ gb_json* device_option::copy_opt(gb_json* from)
|
|||
// 3: default value ...
|
||||
if (init_value_.count(to->key()))
|
||||
{
|
||||
std::string val(init_value_[to->key()]->first_value(&device_option::calc_simple_logic_expression, this));
|
||||
for (int i = 0; i < init_value_[to->key()]->count(); ++i)
|
||||
{
|
||||
if (!val.empty())
|
||||
{
|
||||
std::string type("");
|
||||
to->get_value("type", type);
|
||||
if (type == JSON_SANE_TYPE_BOOL)
|
||||
to->set_value("default", *(bool*)val.c_str());
|
||||
else if(type == JSON_SANE_TYPE_INT)
|
||||
to->set_value("default", *(int*)val.c_str());
|
||||
else if(type == JSON_SANE_TYPE_FIXED)
|
||||
to->set_value("default", *(double*)val.c_str());
|
||||
else if(type == JSON_SANE_TYPE_STRING)
|
||||
to->set_value("default", (const wchar_t*)val.c_str());
|
||||
break;
|
||||
}
|
||||
val = init_value_[to->key()]->next_value(&device_option::calc_simple_logic_expression, this);
|
||||
}
|
||||
std::string val(init_value_[to->key()]->value(&device_option::calc_simple_logic_expression, this));
|
||||
std::string type("");
|
||||
to->get_value("type", type);
|
||||
|
||||
if (type == JSON_SANE_TYPE_BOOL)
|
||||
to->set_value("default", *(bool*)val.c_str());
|
||||
else if(type == JSON_SANE_TYPE_INT)
|
||||
to->set_value("default", *(int*)val.c_str());
|
||||
else if(type == JSON_SANE_TYPE_FIXED)
|
||||
to->set_value("default", *(double*)val.c_str());
|
||||
else if(type == JSON_SANE_TYPE_STRING)
|
||||
to->set_value("default", (const wchar_t*)val.c_str());
|
||||
}
|
||||
|
||||
// 4: range value ...
|
||||
|
|
|
@ -127,7 +127,7 @@ class device_option
|
|||
}
|
||||
};
|
||||
std::map<std::string, range_value*> range_value_;
|
||||
std::map<std::string, range_value*> init_value_;
|
||||
std::map<std::string, condition_value*> init_value_;
|
||||
|
||||
static bool is_equal_b(gb_json* opt, void* val, void* v1, void* v2);
|
||||
static bool is_equal_i(gb_json* opt, void* val, void* v1, void* v2);
|
||||
|
|
Loading…
Reference in New Issue