From 1ecd2a4ff85391aff235520e39cd3b47311f24f7 Mon Sep 17 00:00:00 2001 From: Marc Lepage Date: Sat, 15 Jan 2022 01:14:43 -0500 Subject: [PATCH] Remove changes to Decode Keep the other changes, and adjust the documentation. --- src/app/data-model/DecodableList.h | 36 +++++++++--------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/src/app/data-model/DecodableList.h b/src/app/data-model/DecodableList.h index 9da23f9a6eb74f..4ae9728929dd3a 100644 --- a/src/app/data-model/DecodableList.h +++ b/src/app/data-model/DecodableList.h @@ -32,7 +32,6 @@ namespace DataModel { * This class provides an iteratable decoder of list items within TLV payloads * such that no memory has to be provided ahead of time to store the entirety of the decoded * list contents. - * */ template class DecodableList @@ -53,10 +52,7 @@ class DecodableList /* * @brief * - * This call clears a TLV reader this class is to manage, for a list that is null valued. - * - * Specifically, the reader should have a `GetContainerType` that is `kTLVType_NotSpecified` - * (as if `OpenContainer` were never called). + * This call clears the TLV reader managed by this class, so it can be reused. */ void ClearReader() { mReader.Init(nullptr, 0); } @@ -69,7 +65,7 @@ class DecodableList * This reader should be pointing into the list just after * having called `OpenContainer` on the list element, or should * have a `kTLVType_NotSpecified` container type if there is - * no list element. + * no list. */ Iterator(const TLV::TLVReader & reader) { @@ -85,13 +81,12 @@ class DecodableList * If an element does exist and was successfully decoded, this * shall return true. * - * Otherwise, if the end of list is reached, or there was no list - * (null valued list case), this call shall return false. + * Otherwise, if the end of list is reached, or there was no list, + * this call shall return false. * * If an error was encountered at any point during the iteration or decode, * this shall return false as well. The caller is expected to invoke GetStatus() * to retrieve the status of the operation. - * */ bool Next() { @@ -124,7 +119,6 @@ class DecodableList * * Notably, if the end-of-list was encountered in a previous call to Next, * the status returned shall be CHIP_NO_ERROR. - * */ CHIP_ERROR GetStatus() const { @@ -150,8 +144,8 @@ class DecodableList * Compute the size of the list. This can fail if the TLV is malformed. If * this succeeds, that does not guarantee that the individual items can be * successfully decoded; consumers should check Iterator::GetStatus() when - * actually decoding them. If there is no list (null valued list case) then - * the size is considered to be zero. + * actually decoding them. If there is no list then the size is considered + * to be zero. */ CHIP_ERROR ComputeSize(size_t * size) const { @@ -173,19 +167,11 @@ class DecodableList template CHIP_ERROR Decode(TLV::TLVReader & reader, DecodableList & x) { - if (reader.GetType() == TLV::kTLVType_Null) - { - x.ClearReader(); - } - else - { - VerifyOrReturnError(reader.GetType() == TLV::kTLVType_Array, CHIP_ERROR_SCHEMA_MISMATCH); - TLV::TLVType type; - ReturnErrorOnFailure(reader.EnterContainer(type)); - x.SetReader(reader); - ReturnErrorOnFailure(reader.ExitContainer(type)); - } - + VerifyOrReturnError(reader.GetType() == TLV::kTLVType_Array, CHIP_ERROR_SCHEMA_MISMATCH); + TLV::TLVType type; + ReturnErrorOnFailure(reader.EnterContainer(type)); + x.SetReader(reader); + ReturnErrorOnFailure(reader.ExitContainer(type)); return CHIP_NO_ERROR; }