Matter SDK Coverage Report
Current view: top level - app/MessageDef - AttributeDataIBs.cpp (source / functions) Coverage Total Hit
Test: SHA:b879ecb8e99e175eea0a293a888bda853da2b19c Lines: 100.0 % 33 33
Test Date: 2025-01-17 19:00:11 Functions: 100.0 % 4 4

            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         1740 : CHIP_ERROR AttributeDataIBs::Parser::PrettyPrint() const
      41              : {
      42         1740 :     CHIP_ERROR err        = CHIP_NO_ERROR;
      43         1740 :     size_t numDataElement = 0;
      44         1740 :     chip::TLV::TLVReader reader;
      45              : 
      46         1740 :     PRETTY_PRINT("AttributeDataIBs =");
      47         1740 :     PRETTY_PRINT("[");
      48              : 
      49              :     // make a copy of the reader
      50         1740 :     reader.Init(mReader);
      51              : 
      52         4235 :     while (CHIP_NO_ERROR == (err = reader.Next()))
      53              :     {
      54         2495 :         VerifyOrReturnError(TLV::AnonymousTag() == reader.GetTag(), CHIP_ERROR_INVALID_TLV_TAG);
      55         2495 :         VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE);
      56              : 
      57              :         {
      58         2495 :             AttributeDataIB::Parser data;
      59         2495 :             ReturnErrorOnFailure(data.Init(reader));
      60              : 
      61         2495 :             PRETTY_PRINT_INCDEPTH();
      62         2495 :             ReturnErrorOnFailure(data.PrettyPrint());
      63         2495 :             PRETTY_PRINT_DECDEPTH();
      64              :         }
      65              : 
      66         2495 :         ++numDataElement;
      67              :     }
      68              : 
      69         1740 :     PRETTY_PRINT("],");
      70         1740 :     PRETTY_PRINT_BLANK_LINE();
      71              : 
      72              :     // if we have exhausted this container
      73         1740 :     if (CHIP_END_OF_TLV == err)
      74              :     {
      75              :         // if we have at least one data element
      76         1740 :         if (numDataElement > 0)
      77              :         {
      78         1740 :             err = CHIP_NO_ERROR;
      79              :         }
      80              :     }
      81         1740 :     ReturnErrorOnFailure(err);
      82         1740 :     return reader.ExitContainer(mOuterContainerType);
      83              : }
      84              : #endif // CHIP_CONFIG_IM_PRETTY_PRINT
      85              : 
      86         3973 : AttributeDataIB::Builder & AttributeDataIBs::Builder::CreateAttributeDataIBBuilder()
      87              : {
      88              :     // skip if error has already been set
      89         3973 :     VerifyOrExit(CHIP_NO_ERROR == mError, mAttributeDataIBBuilder.ResetError(mError));
      90              : 
      91         3973 :     mError = mAttributeDataIBBuilder.Init(mpWriter);
      92              : 
      93         3973 : exit:
      94              : 
      95              :     // on error, mAttributeDataIBBuilder would be un-/partial initialized and cannot be used to write anything
      96         3973 :     return mAttributeDataIBBuilder;
      97              : }
      98              : 
      99         6327 : AttributeDataIB::Builder & AttributeDataIBs::Builder::GetAttributeDataIBBuilder()
     100              : {
     101         6327 :     return mAttributeDataIBBuilder;
     102              : }
     103              : 
     104         1797 : CHIP_ERROR AttributeDataIBs::Builder::EndOfAttributeDataIBs()
     105              : {
     106         1797 :     EndOfContainer();
     107              : 
     108         1797 :     return GetError();
     109              : }
     110              : 
     111              : }; // namespace app
     112              : }; // namespace chip
        

Generated by: LCOV version 2.0-1