Skip to content

Commit 1490546

Browse files
bzbarsky-applepull[bot]
authored andcommitted
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.
1 parent cba9bd0 commit 1490546

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

examples/dynamic-bridge-app/linux/include/data-model/DataModel.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ CHIP_ERROR Encode(const ConcreteReadAttributePath & aPath, AttributeValueEncoder
201201
// CONFIG_BUILD_FOR_HOST_UNIT_TEST is true, so we can test how the other side
202202
// responds.
203203
#if !CONFIG_BUILD_FOR_HOST_UNIT_TEST
204-
if (!x.HasValidValue())
204+
if (!x.ExistingValueInEncodableRange())
205205
{
206206
return CHIP_IM_GLOBAL_STATUS(ConstraintError);
207207
}
@@ -313,7 +313,7 @@ CHIP_ERROR Decode(const ConcreteDataAttributePath & aPath, AttributeValueDecoder
313313

314314
// We have a value; decode it.
315315
ReturnErrorOnFailure(Decode(aPath, aDecoder, x.SetNonNull()));
316-
if (!x.HasValidValue())
316+
if (!x.ExistingValueInEncodableRange())
317317
{
318318
return CHIP_IM_GLOBAL_STATUS(ConstraintError);
319319
}

src/app/data-model/Decode.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ CHIP_ERROR Decode(TLV::TLVReader & reader, Nullable<X> & x)
170170

171171
// We have a value; decode it.
172172
ReturnErrorOnFailure(Decode(reader, x.SetNonNull()));
173-
if (!x.HasValidValue())
173+
if (!x.ExistingValueInEncodableRange())
174174
{
175175
return CHIP_IM_GLOBAL_STATUS(ConstraintError);
176176
}

src/app/data-model/Encode.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag, const Nullable<X> & x)
188188
// CONFIG_BUILD_FOR_HOST_UNIT_TEST is true, so we can test how the other side
189189
// responds.
190190
#if !CONFIG_BUILD_FOR_HOST_UNIT_TEST
191-
if (!x.HasValidValue())
191+
if (!x.ExistingValueInEncodableRange())
192192
{
193193
return CHIP_IM_GLOBAL_STATUS(ConstraintError);
194194
}

src/app/data-model/Nullable.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct Nullable : protected Optional<T>
6565
template <
6666
typename U = std::decay_t<T>,
6767
typename std::enable_if_t<(std::is_integral<U>::value && !std::is_same<U, bool>::value) || std::is_enum<U>::value, int> = 0>
68-
constexpr bool HasValidValue() const
68+
constexpr bool ExistingValueInEncodableRange() const
6969
{
7070
return NumericAttributeTraits<T>::CanRepresentValue(/* isNullable = */ true, Value());
7171
}
@@ -74,7 +74,7 @@ struct Nullable : protected Optional<T>
7474
template <typename U = std::decay_t<T>,
7575
typename std::enable_if_t<(!std::is_integral<U>::value || std::is_same<U, bool>::value) && !std::is_enum<U>::value,
7676
int> = 0>
77-
constexpr bool HasValidValue() const
77+
constexpr bool ExistingValueInEncodableRange() const
7878
{
7979
return true;
8080
}

0 commit comments

Comments
 (0)