LCOV - code coverage report
Current view: top level - app/MessageDef - AttributeDataIBs.cpp (source / functions) Hit Total Coverage
Test: lcov_final.info Lines: 32 32 100.0 %
Date: 2024-02-15 08:20:41 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /**
       2             :  *
       3             :  *    Copyright (c) 2020 Project CHIP Authors
       4             :  *    Copyright (c) 2018 Google LLC.
       5             :  *    Copyright (c) 2016-2017 Nest Labs, Inc.
       6             :  *    Licensed under the Apache License, Version 2.0 (the "License");
       7             :  *    you may not use this file except in compliance with the License.
       8             :  *    You may obtain a copy of the License at
       9             :  *
      10             :  *        http://www.apache.org/licenses/LICENSE-2.0
      11             :  *
      12             :  *    Unless required by applicable law or agreed to in writing, software
      13             :  *    distributed under the License is distributed on an "AS IS" BASIS,
      14             :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      15             :  *    See the License for the specific language governing permissions and
      16             :  *    limitations under the License.
      17             :  */
      18             : /**
      19             :  *    @file
      20             :  *      This file defines AttributeDataIBs parser and builder in CHIP interaction model
      21             :  *
      22             :  */
      23             : 
      24             : #include "AttributeDataIBs.h"
      25             : 
      26             : #include "MessageDefHelper.h"
      27             : 
      28             : #include <inttypes.h>
      29             : #include <stdarg.h>
      30             : #include <stdio.h>
      31             : 
      32             : #include <app/AppConfig.h>
      33             : 
      34             : using namespace chip;
      35             : using namespace chip::TLV;
      36             : 
      37             : namespace chip {
      38             : namespace app {
      39             : #if CHIP_CONFIG_IM_PRETTY_PRINT
      40        1738 : CHIP_ERROR AttributeDataIBs::Parser::PrettyPrint() const
      41             : {
      42        1738 :     CHIP_ERROR err        = CHIP_NO_ERROR;
      43        1738 :     size_t numDataElement = 0;
      44             :     chip::TLV::TLVReader reader;
      45             : 
      46        1738 :     PRETTY_PRINT("AttributeDataIBs =");
      47        1738 :     PRETTY_PRINT("[");
      48             : 
      49             :     // make a copy of the reader
      50        1738 :     reader.Init(mReader);
      51             : 
      52        4231 :     while (CHIP_NO_ERROR == (err = reader.Next()))
      53             :     {
      54        2493 :         VerifyOrReturnError(TLV::AnonymousTag() == reader.GetTag(), CHIP_ERROR_INVALID_TLV_TAG);
      55        2493 :         VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE);
      56             : 
      57             :         {
      58        2493 :             AttributeDataIB::Parser data;
      59        2493 :             ReturnErrorOnFailure(data.Init(reader));
      60             : 
      61        2493 :             PRETTY_PRINT_INCDEPTH();
      62        2493 :             ReturnErrorOnFailure(data.PrettyPrint());
      63        2493 :             PRETTY_PRINT_DECDEPTH();
      64             :         }
      65             : 
      66        2493 :         ++numDataElement;
      67             :     }
      68             : 
      69        1738 :     PRETTY_PRINT("],");
      70        1738 :     PRETTY_PRINT_BLANK_LINE();
      71             : 
      72             :     // if we have exhausted this container
      73        1738 :     if (CHIP_END_OF_TLV == err)
      74             :     {
      75             :         // if we have at least one data element
      76        1738 :         if (numDataElement > 0)
      77             :         {
      78        1738 :             err = CHIP_NO_ERROR;
      79             :         }
      80             :     }
      81        1738 :     ReturnErrorOnFailure(err);
      82        1738 :     return reader.ExitContainer(mOuterContainerType);
      83             : }
      84             : #endif // CHIP_CONFIG_IM_PRETTY_PRINT
      85             : 
      86        3971 : AttributeDataIB::Builder & AttributeDataIBs::Builder::CreateAttributeDataIBBuilder()
      87             : {
      88             :     // skip if error has already been set
      89        3971 :     VerifyOrExit(CHIP_NO_ERROR == mError, mAttributeDataIBBuilder.ResetError(mError));
      90             : 
      91        3971 :     mError = mAttributeDataIBBuilder.Init(mpWriter);
      92             : 
      93        3971 : exit:
      94             : 
      95             :     // on error, mAttributeDataIBBuilder would be un-/partial initialized and cannot be used to write anything
      96        3971 :     return mAttributeDataIBBuilder;
      97             : }
      98             : 
      99        6323 : AttributeDataIB::Builder & AttributeDataIBs::Builder::GetAttributeDataIBBuilder()
     100             : {
     101        6323 :     return mAttributeDataIBBuilder;
     102             : }
     103             : 
     104        1795 : CHIP_ERROR AttributeDataIBs::Builder::EndOfAttributeDataIBs()
     105             : {
     106        1795 :     EndOfContainer();
     107             : 
     108        1795 :     return GetError();
     109             : }
     110             : 
     111             : }; // namespace app
     112             : }; // namespace chip

Generated by: LCOV version 1.14