Provide set/get_boolean conveience functions

This commit is contained in:
Rob Giseburt
2020-07-26 15:38:50 -05:00
parent cc7c56edb2
commit ccf2e51e24
2 changed files with 16 additions and 0 deletions
+3
View File
@@ -452,6 +452,9 @@ stat_t get_float(nvObj_t *nv, const float value); // boilerplate for retrievin
stat_t set_float(nvObj_t *nv, float &value); // boilerplate for setting a floating point value w/conversion
stat_t set_float_range(nvObj_t *nv, float &value, float low, float high);
stat_t get_boolean(nvObj_t *nv, const bool value); // boilerplate for retrieving 1 bit integer value
stat_t set_boolean(nvObj_t *nv, bool &value); // boilerplate for retrieving 1 bit integer value
stat_t get_integer(nvObj_t *nv, const int32_t value); // boilerplate for retrieving 8 bit integer value
stat_t set_integer(nvObj_t *nv, uint8_t &value, uint8_t low, uint8_t high);
stat_t set_int32(nvObj_t *nv, int32_t &value, int32_t low, int32_t high);
+13
View File
@@ -2041,6 +2041,19 @@ static stat_t _set_int_tests(nvObj_t *nv, int32_t low, int32_t high)
return (STAT_OK);
}
stat_t get_boolean(nvObj_t *nv, const bool value)
{
nv->value_int = value;
nv->valuetype = TYPE_BOOLEAN;
return STAT_OK;
}
stat_t set_boolean(nvObj_t *nv, bool &value)
{
value = !!nv->value_int;
nv->valuetype = TYPE_BOOLEAN;
return STAT_OK;
}
stat_t get_integer(nvObj_t *nv, const int32_t value)
{
nv->value_int = value;