Matter SDK Coverage Report
Current view: top level - app/MessageDef - InvokeResponseIB.cpp (source / functions) Coverage Total Hit
Test: SHA:e98a48c2e59f85a25417956e1d105721433aa5d1 Lines: 92.5 % 53 49
Test Date: 2026-01-09 16:53:50 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 <inttypes.h>
      18              : #include <stdarg.h>
      19              : #include <stdio.h>
      20              : 
      21              : #include "InvokeResponseIB.h"
      22              : #include "MessageDefHelper.h"
      23              : 
      24              : #include <app/AppConfig.h>
      25              : 
      26              : namespace chip {
      27              : namespace app {
      28              : #if CHIP_CONFIG_IM_PRETTY_PRINT
      29           66 : CHIP_ERROR InvokeResponseIB::Parser::PrettyPrint() const
      30              : {
      31           66 :     CHIP_ERROR err = CHIP_NO_ERROR;
      32           66 :     TLV::TLVReader reader;
      33              : 
      34           66 :     PRETTY_PRINT("InvokeResponseIB =");
      35           66 :     PRETTY_PRINT("{");
      36              : 
      37              :     // make a copy of the reader
      38           66 :     reader.Init(mReader);
      39              : 
      40          264 :     while (CHIP_NO_ERROR == (err = reader.Next()))
      41              :     {
      42           66 :         if (!TLV::IsContextTag(reader.GetTag()))
      43              :         {
      44            0 :             continue;
      45              :         }
      46           66 :         uint32_t tagNum = TLV::TagNumFromTag(reader.GetTag());
      47           66 :         switch (tagNum)
      48              :         {
      49           23 :         case to_underlying(Tag::kCommand): {
      50           23 :             CommandDataIB::Parser command;
      51           23 :             ReturnErrorOnFailure(command.Init(reader));
      52              : 
      53           23 :             PRETTY_PRINT_INCDEPTH();
      54           23 :             ReturnErrorOnFailure(command.PrettyPrint());
      55           23 :             PRETTY_PRINT_DECDEPTH();
      56              :         }
      57           23 :         break;
      58           43 :         case to_underlying(Tag::kStatus): {
      59           43 :             CommandStatusIB::Parser status;
      60           43 :             ReturnErrorOnFailure(status.Init(reader));
      61              : 
      62           43 :             PRETTY_PRINT_INCDEPTH();
      63           43 :             ReturnErrorOnFailure(status.PrettyPrint());
      64           43 :             PRETTY_PRINT_DECDEPTH();
      65              :         }
      66           43 :         break;
      67            0 :         default:
      68            0 :             PRETTY_PRINT("Unknown tag num %" PRIu32, tagNum);
      69            0 :             break;
      70              :         }
      71              :     }
      72              : 
      73           66 :     PRETTY_PRINT("},");
      74           66 :     PRETTY_PRINT_BLANK_LINE();
      75              : 
      76              :     // if we have exhausted this container
      77          132 :     if (CHIP_END_OF_TLV == err)
      78              :     {
      79           66 :         err = CHIP_NO_ERROR;
      80              :     }
      81           66 :     ReturnErrorOnFailure(err);
      82           66 :     return reader.ExitContainer(mOuterContainerType);
      83              : }
      84              : #endif // CHIP_CONFIG_IM_PRETTY_PRINT
      85              : 
      86           21 : CHIP_ERROR InvokeResponseIB::Parser::GetCommand(CommandDataIB::Parser * const apCommand) const
      87              : {
      88           21 :     TLV::TLVReader reader;
      89           21 :     ReturnErrorOnFailure(mReader.FindElementWithTag(TLV::ContextTag(Tag::kCommand), reader));
      90           21 :     return apCommand->Init(reader);
      91              : }
      92              : 
      93           63 : CHIP_ERROR InvokeResponseIB::Parser::GetStatus(CommandStatusIB::Parser * const apStatus) const
      94              : {
      95           63 :     TLV::TLVReader reader;
      96           63 :     ReturnErrorOnFailure(mReader.FindElementWithTag(TLV::ContextTag(Tag::kStatus), reader));
      97           43 :     return apStatus->Init(reader);
      98              : }
      99              : 
     100           39 : CommandDataIB::Builder & InvokeResponseIB::Builder::CreateCommand()
     101              : {
     102           78 :     if (mError == CHIP_NO_ERROR)
     103              :     {
     104           39 :         mError = mCommand.Init(mpWriter, to_underlying(Tag::kCommand));
     105              :     }
     106           39 :     return mCommand;
     107              : }
     108              : 
     109           56 : CommandStatusIB::Builder & InvokeResponseIB::Builder::CreateStatus()
     110              : {
     111          112 :     if (mError == CHIP_NO_ERROR)
     112              :     {
     113           56 :         mError = mStatus.Init(mpWriter, to_underlying(Tag::kStatus));
     114              :     }
     115           56 :     return mStatus;
     116              : }
     117              : 
     118           91 : CHIP_ERROR InvokeResponseIB::Builder::EndOfInvokeResponseIB()
     119              : {
     120           91 :     EndOfContainer();
     121           91 :     return GetError();
     122              : }
     123              : } // namespace app
     124              : } // namespace chip
        

Generated by: LCOV version 2.0-1