Matter SDK Coverage Report
Current view: top level - app/MessageDef - AttributeReportIB.cpp (source / functions) Coverage Total Hit
Test: SHA:b879ecb8e99e175eea0a293a888bda853da2b19c Lines: 92.5 % 53 49
Test Date: 2025-01-17 19:00:11 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         4364 : CHIP_ERROR AttributeReportIB::Parser::PrettyPrint() const
      33              : {
      34         4364 :     CHIP_ERROR err = CHIP_NO_ERROR;
      35         4364 :     TLV::TLVReader reader;
      36              : 
      37         4364 :     PRETTY_PRINT("AttributeReportIB =");
      38         4364 :     PRETTY_PRINT("{");
      39              : 
      40              :     // make a copy of the reader
      41         4364 :     reader.Init(mReader);
      42              : 
      43         8728 :     while (CHIP_NO_ERROR == (err = reader.Next()))
      44              :     {
      45         4364 :         if (!TLV::IsContextTag(reader.GetTag()))
      46              :         {
      47            0 :             continue;
      48              :         }
      49         4364 :         uint32_t tagNum = TLV::TagNumFromTag(reader.GetTag());
      50         4364 :         switch (tagNum)
      51              :         {
      52          257 :         case to_underlying(Tag::kAttributeStatus): {
      53          257 :             AttributeStatusIB::Parser attributeStatus;
      54          257 :             ReturnErrorOnFailure(attributeStatus.Init(reader));
      55              : 
      56          257 :             PRETTY_PRINT_INCDEPTH();
      57          257 :             ReturnErrorOnFailure(attributeStatus.PrettyPrint());
      58          257 :             PRETTY_PRINT_DECDEPTH();
      59              :         }
      60          257 :         break;
      61         4107 :         case to_underlying(Tag::kAttributeData): {
      62         4107 :             AttributeDataIB::Parser attributeData;
      63         4107 :             ReturnErrorOnFailure(attributeData.Init(reader));
      64              : 
      65         4107 :             PRETTY_PRINT_INCDEPTH();
      66         4107 :             ReturnErrorOnFailure(attributeData.PrettyPrint());
      67         4107 :             PRETTY_PRINT_DECDEPTH();
      68              :         }
      69         4107 :         break;
      70            0 :         default:
      71            0 :             PRETTY_PRINT("Unknown tag num %" PRIu32, tagNum);
      72            0 :             break;
      73              :         }
      74              :     }
      75              : 
      76         4364 :     PRETTY_PRINT("},");
      77         4364 :     PRETTY_PRINT_BLANK_LINE();
      78              : 
      79         4364 :     if (CHIP_END_OF_TLV == err)
      80              :     {
      81         4364 :         err = CHIP_NO_ERROR;
      82              :     }
      83              : 
      84         4364 :     ReturnErrorOnFailure(err);
      85         4364 :     return reader.ExitContainer(mOuterContainerType);
      86              : }
      87              : #endif // CHIP_CONFIG_IM_PRETTY_PRINT
      88              : 
      89         4357 : CHIP_ERROR AttributeReportIB::Parser::GetAttributeStatus(AttributeStatusIB::Parser * const apAttributeStatus) const
      90              : {
      91         4357 :     TLV::TLVReader reader;
      92         4357 :     ReturnErrorOnFailure(mReader.FindElementWithTag(TLV::ContextTag(Tag::kAttributeStatus), reader));
      93          257 :     return apAttributeStatus->Init(reader);
      94              : }
      95              : 
      96         4156 : CHIP_ERROR AttributeReportIB::Parser::GetAttributeData(AttributeDataIB::Parser * const apAttributeData) const
      97              : {
      98         4156 :     TLV::TLVReader reader;
      99         4156 :     ReturnErrorOnFailure(mReader.FindElementWithTag(TLV::ContextTag(Tag::kAttributeData), reader));
     100         4156 :     return apAttributeData->Init(reader);
     101              : }
     102              : 
     103          263 : AttributeStatusIB::Builder & AttributeReportIB::Builder::CreateAttributeStatus()
     104              : {
     105          263 :     if (mError == CHIP_NO_ERROR)
     106              :     {
     107          263 :         mError = mAttributeStatus.Init(mpWriter, to_underlying(Tag::kAttributeStatus));
     108              :     }
     109          263 :     return mAttributeStatus;
     110              : }
     111              : 
     112         4401 : AttributeDataIB::Builder & AttributeReportIB::Builder::CreateAttributeData()
     113              : {
     114         4401 :     if (mError == CHIP_NO_ERROR)
     115              :     {
     116         4401 :         mError = mAttributeData.Init(mpWriter, to_underlying(Tag::kAttributeData));
     117              :     }
     118         4401 :     return mAttributeData;
     119              : }
     120              : 
     121         4515 : CHIP_ERROR AttributeReportIB::Builder::EndOfAttributeReportIB()
     122              : {
     123         4515 :     EndOfContainer();
     124         4515 :     return GetError();
     125              : }
     126              : } // namespace app
     127              : } // namespace chip
        

Generated by: LCOV version 2.0-1