Browse Source

AP_Param: optionally return parameter flags in AP_Param::find(...)

master
Peter Barker 6 years ago committed by Peter Barker
parent
commit
2049e86dda
  1. 5
      libraries/AP_Param/AP_Param.cpp
  2. 3
      libraries/AP_Param/AP_Param.h

5
libraries/AP_Param/AP_Param.cpp

@ -825,7 +825,7 @@ AP_Param::find_group(const char *name, uint16_t vindex, ptrdiff_t group_offset,
// Find a variable by name. // Find a variable by name.
// //
AP_Param * AP_Param *
AP_Param::find(const char *name, enum ap_var_type *ptype) AP_Param::find(const char *name, enum ap_var_type *ptype, uint16_t *flags)
{ {
for (uint16_t i=0; i<_num_vars; i++) { for (uint16_t i=0; i<_num_vars; i++) {
uint8_t type = _var_info[i].type; uint8_t type = _var_info[i].type;
@ -840,6 +840,9 @@ AP_Param::find(const char *name, enum ap_var_type *ptype)
} }
AP_Param *ap = find_group(name + len, i, 0, group_info, ptype); AP_Param *ap = find_group(name + len, i, 0, group_info, ptype);
if (ap != nullptr) { if (ap != nullptr) {
if (flags != nullptr) {
*flags = group_info->flags;
}
return ap; return ap;
} }
// we continue looking as we want to allow top level // we continue looking as we want to allow top level

3
libraries/AP_Param/AP_Param.h

@ -252,10 +252,11 @@ public:
/// If the variable has no name, it cannot be found by this interface. /// If the variable has no name, it cannot be found by this interface.
/// ///
/// @param name The full name of the variable to be found. /// @param name The full name of the variable to be found.
/// @param flags If non-null will be filled with parameter flags
/// @return A pointer to the variable, or nullptr if /// @return A pointer to the variable, or nullptr if
/// it does not exist. /// it does not exist.
/// ///
static AP_Param * find(const char *name, enum ap_var_type *ptype); static AP_Param * find(const char *name, enum ap_var_type *ptype, uint16_t *flags = nullptr);
/// set a default value by name /// set a default value by name
/// ///

Loading…
Cancel
Save