static int __config_setting_get_float(const config_setting_t *setting, double *value) { switch(setting->type) { case CONFIG_TYPE_FLOAT: *value = setting->value.fval; return(CONFIG_TRUE); case CONFIG_TYPE_INT: if(config_get_auto_convert(setting->config)) { *value = (double)(setting->value.ival); return(CONFIG_TRUE); } else return(CONFIG_FALSE); case CONFIG_TYPE_INT64: if(config_get_auto_convert(setting->config)) { *value = (double)(setting->value.llval); return(CONFIG_TRUE); } else { /* fall through */ } default: return(CONFIG_FALSE); } }
int config_setting_set_int64(config_setting_t *setting, long long value) { switch(setting->type) { case CONFIG_TYPE_NONE: setting->type = CONFIG_TYPE_INT64; /* fall through */ case CONFIG_TYPE_INT64: setting->value.llval = value; return(CONFIG_TRUE); case CONFIG_TYPE_INT: if((value > INT32_MAX) || (value < INT32_MIN)) setting->value.ival = 0; else setting->value.ival = (int)value; return(CONFIG_TRUE); case CONFIG_TYPE_FLOAT: if(config_get_auto_convert(setting->config)) { setting->value.fval = (float)value; return(CONFIG_TRUE); } else return(CONFIG_FALSE); default: return(CONFIG_FALSE); } }
int config_setting_set_int(config_setting_t *setting, int value) { switch(setting->type) { case CONFIG_TYPE_NONE: setting->type = CONFIG_TYPE_INT; /* fall through */ case CONFIG_TYPE_INT: setting->value.ival = value; return(CONFIG_TRUE); case CONFIG_TYPE_FLOAT: if(config_get_auto_convert(setting->config)) { setting->value.fval = (float)value; return(CONFIG_TRUE); } else return(CONFIG_FALSE); default: return(CONFIG_FALSE); } }
double config_setting_get_float(const config_setting_t *setting) { switch(setting->type) { case CONFIG_TYPE_FLOAT: return(setting->value.fval); case CONFIG_TYPE_INT: if(config_get_auto_convert(setting->config)) return((double)(setting->value.ival)); else return(0.0); case CONFIG_TYPE_INT64: if(config_get_auto_convert(setting->config)) return((double)(setting->value.llval)); else return(0.0); default: return(0.0); } }