Matter SDK Coverage Report
Current view: top level - app/MessageDef - AttributeReportIB.cpp (source / functions) Coverage Total Hit
Test: SHA:f84fe08d06f240e801b5d923f8a938a9938ca110 Lines: 92.5 % 53 49
Test Date: 2025-02-22 08:08:07 Functions: 100.0 % 6 6

            Line data    Source code
       1              : /**
       2              :  *
       3              :  *    Copyright (c) 2021 Project CHIP Authors
       4              :  *    Licensed under the Apache License, Version 2.0 (the "License");
       5              :  *    you may not use this file except in compliance with the License.
       6              :  *    You may obtain a copy of the License at
       7              :  *
       8              :  *        http://www.apache.org/licenses/LICENSE-2.0
       9              :  *
      10              :  *    Unless required by applicable law or agreed to in writing, software
      11              :  *    distributed under the License is distributed on an "AS IS" BASIS,
      12              :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13              :  *    See the License for the specific language governing permissions and
      14              :  *    limitations under the License.
      15              :  */
      16              : 
      17              : #include "AttributeReportIB.h"
      18              : #include "AttributeDataIB.h"
      19              : #include "MessageDefHelper.h"
      20              : #include "StructBuilder.h"
      21              : #include "StructParser.h"
      22              : 
      23              : #include <inttypes.h>
      24              : #include <stdarg.h>
      25              : #include <stdio.h>
      26              : 
      27              : #include <app/AppConfig.h>
      28              : 
      29              : namespace chip {
      30              : namespace app {
      31              : #if CHIP_CONFIG_IM_PRETTY_PRINT
      32         4433 : CHIP_ERROR AttributeReportIB::Parser::PrettyPrint() const
      33              : {
      34         4433 :     CHIP_ERROR err = CHIP_NO_ERROR;
      35         4433 :     TLV::TLVReader reader;
      36              : 
      37         4433 :     PRETTY_PRINT("AttributeReportIB =");
      38         4433 :     PRETTY_PRINT("{");
      39              : 
      40              :     // make a copy of the reader
      41         4433 :     reader.Init(mReader);
      42              : 
      43         8866 :     while (CHIP_NO_ERROR == (err = reader.Next()))
      44              :     {
      45         4433 :         if (!TLV::IsContextTag(reader.GetTag()))
      46              :         {
      47            0 :             continue;
      48              :         }
      49         4433 :         uint32_t tagNum = TLV::TagNumFromTag(reader.GetTag());
      50         4433 :         switch (tagNum)
      51              :         {
      52            8 :         case to_underlying(Tag::kAttributeStatus): {
      53            8 :             AttributeStatusIB::Parser attributeStatus;
      54            8 :             ReturnErrorOnFailure(attributeStatus.Init(reader));
      55              : 
      56            8 :             PRETTY_PRINT_INCDEPTH();
      57            8 :             ReturnErrorOnFailure(attributeStatus.PrettyPrint());
      58            8 :             PRETTY_PRINT_DECDEPTH();
      59              :         }
      60            8 :         break;
      61         4425 :         case to_underlying(Tag::kAttributeData): {
      62         4425 :             AttributeDataIB::Parser attributeData;
      63         4425 :             ReturnErrorOnFailure(attributeData.Init(reader));
      64              : 
      65         4425 :             PRETTY_PRINT_INCDEPTH();
      66         4425 :             ReturnErrorOnFailure(attributeData.PrettyPrint());
      67         4425 :             PRETTY_PRINT_DECDEPTH();
      68              :         }
      69         4425 :         break;
      70            0 :         default:
      71            0 :             PRETTY_PRINT("Unknown tag num %" PRIu32, tagNum);
      72            0 :             break;
      73              :         }
      74              :     }
      75              : 
      76         4433 :     PRETTY_PRINT("},");
      77         4433 :     PRETTY_PRINT_BLANK_LINE();
      78              : 
      79         4433 :     if (CHIP_END_OF_TLV == err)
      80              :     {
      81         4433 :         err = CHIP_NO_ERROR;
      82              :     }
      83              : 
      84         4433 :     ReturnErrorOnFailure(err);
      85         4433 :     return reader.ExitContainer(mOuterContainerType);
      86              : }
      87              : #endif // CHIP_CONFIG_IM_PRETTY_PRINT
      88              : 
      89         4426 : CHIP_ERROR AttributeReportIB::Parser::GetAttributeStatus(AttributeStatusIB::Parser * const apAttributeStatus) const
      90              : {
      91         4426 :     TLV::TLVReader reader;
      92         4426 :     ReturnErrorOnFailure(mReader.FindElementWithTag(TLV::ContextTag(Tag::kAttributeStatus), reader));
      93            8 :     return apAttributeStatus->Init(reader);
      94              : }
      95              : 
      96         4473 : CHIP_ERROR AttributeReportIB::Parser::GetAttributeData(AttributeDataIB::Parser * const apAttributeData) const
      97              : {
      98         4473 :     TLV::TLVReader reader;
      99         4473 :     ReturnErrorOnFailure(mReader.FindElementWithTag(TLV::ContextTag(Tag::kAttributeData), reader));
     100         4473 :     return apAttributeData->Init(reader);
     101              : }
     102              : 
     103            8 : AttributeStatusIB::Builder & AttributeReportIB::Builder::CreateAttributeStatus()
     104              : {
     105            8 :     if (mError == CHIP_NO_ERROR)
     106              :     {
     107            8 :         mError = mAttributeStatus.Init(mpWriter, to_underlying(Tag::kAttributeStatus));
     108              :     }
     109            8 :     return mAttributeStatus;
     110              : }
     111              : 
     112         4725 : AttributeDataIB::Builder & AttributeReportIB::Builder::CreateAttributeData()
     113              : {
     114         4725 :     if (mError == CHIP_NO_ERROR)
     115              :     {
     116         4725 :         mError = mAttributeData.Init(mpWriter, to_underlying(Tag::kAttributeData));
     117              :     }
     118         4725 :     return mAttributeData;
     119              : }
     120              : 
     121         4582 : CHIP_ERROR AttributeReportIB::Builder::EndOfAttributeReportIB()
     122              : {
     123         4582 :     EndOfContainer();
     124         4582 :     return GetError();
     125              : }
     126              : } // namespace app
     127              : } // namespace chip
        

Generated by: LCOV version 2.0-1