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

3
libraries/AP_Param/AP_Param.h

@ -252,10 +252,11 @@ public: @@ -252,10 +252,11 @@ public:
/// 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 flags If non-null will be filled with parameter flags
/// @return A pointer to the variable, or nullptr if
/// 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
///

Loading…
Cancel
Save