From 260e5e7fa5540fa0bfd10cc79b13d46df6a10655 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 15 May 2023 21:45:45 -0400 Subject: [PATCH] Rename Nullable::HasValidValue so people won't try to use it. (#26535) This function is a pretty specific thing, and people are confusing it with IsNull(). Rename to something that will make it less likely. --- .../dynamic-bridge-app/linux/include/data-model/DataModel.h | 4 ++-- src/app/data-model/Decode.h | 2 +- src/app/data-model/Encode.h | 2 +- src/app/data-model/Nullable.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/dynamic-bridge-app/linux/include/data-model/DataModel.h b/examples/dynamic-bridge-app/linux/include/data-model/DataModel.h index cba8d3c9907129..053cd785aac472 100644 --- a/examples/dynamic-bridge-app/linux/include/data-model/DataModel.h +++ b/examples/dynamic-bridge-app/linux/include/data-model/DataModel.h @@ -201,7 +201,7 @@ CHIP_ERROR Encode(const ConcreteReadAttributePath & aPath, AttributeValueEncoder // CONFIG_BUILD_FOR_HOST_UNIT_TEST is true, so we can test how the other side // responds. #if !CONFIG_BUILD_FOR_HOST_UNIT_TEST - if (!x.HasValidValue()) + if (!x.ExistingValueInEncodableRange()) { return CHIP_IM_GLOBAL_STATUS(ConstraintError); } @@ -313,7 +313,7 @@ CHIP_ERROR Decode(const ConcreteDataAttributePath & aPath, AttributeValueDecoder // We have a value; decode it. ReturnErrorOnFailure(Decode(aPath, aDecoder, x.SetNonNull())); - if (!x.HasValidValue()) + if (!x.ExistingValueInEncodableRange()) { return CHIP_IM_GLOBAL_STATUS(ConstraintError); } diff --git a/src/app/data-model/Decode.h b/src/app/data-model/Decode.h index 5124fa44337a52..4acc96f138c50e 100644 --- a/src/app/data-model/Decode.h +++ b/src/app/data-model/Decode.h @@ -170,7 +170,7 @@ CHIP_ERROR Decode(TLV::TLVReader & reader, Nullable & x) // We have a value; decode it. ReturnErrorOnFailure(Decode(reader, x.SetNonNull())); - if (!x.HasValidValue()) + if (!x.ExistingValueInEncodableRange()) { return CHIP_IM_GLOBAL_STATUS(ConstraintError); } diff --git a/src/app/data-model/Encode.h b/src/app/data-model/Encode.h index 0546098a74184d..84a32cf745983c 100644 --- a/src/app/data-model/Encode.h +++ b/src/app/data-model/Encode.h @@ -188,7 +188,7 @@ CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag, const Nullable & x) // CONFIG_BUILD_FOR_HOST_UNIT_TEST is true, so we can test how the other side // responds. #if !CONFIG_BUILD_FOR_HOST_UNIT_TEST - if (!x.HasValidValue()) + if (!x.ExistingValueInEncodableRange()) { return CHIP_IM_GLOBAL_STATUS(ConstraintError); } diff --git a/src/app/data-model/Nullable.h b/src/app/data-model/Nullable.h index 844a7c1b385ae9..ad6bdaf9e2c172 100644 --- a/src/app/data-model/Nullable.h +++ b/src/app/data-model/Nullable.h @@ -65,7 +65,7 @@ struct Nullable : protected Optional template < typename U = std::decay_t, typename std::enable_if_t<(std::is_integral::value && !std::is_same::value) || std::is_enum::value, int> = 0> - constexpr bool HasValidValue() const + constexpr bool ExistingValueInEncodableRange() const { return NumericAttributeTraits::CanRepresentValue(/* isNullable = */ true, Value()); } @@ -74,7 +74,7 @@ struct Nullable : protected Optional template , typename std::enable_if_t<(!std::is_integral::value || std::is_same::value) && !std::is_enum::value, int> = 0> - constexpr bool HasValidValue() const + constexpr bool ExistingValueInEncodableRange() const { return true; }