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

          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 "EventStatusIB.h"
      18             : #include "MessageDefHelper.h"
      19             : #include "StructBuilder.h"
      20             : #include "StructParser.h"
      21             : 
      22             : #include <inttypes.h>
      23             : #include <stdarg.h>
      24             : #include <stdio.h>
      25             : 
      26             : #include <app/AppConfig.h>
      27             : 
      28             : namespace chip {
      29             : namespace app {
      30             : #if CHIP_CONFIG_IM_PRETTY_PRINT
      31           3 : CHIP_ERROR EventStatusIB::Parser::PrettyPrint() const
      32             : {
      33           3 :     CHIP_ERROR err = CHIP_NO_ERROR;
      34             :     TLV::TLVReader reader;
      35             : 
      36           3 :     PRETTY_PRINT("EventStatusIB =");
      37           3 :     PRETTY_PRINT("{");
      38             : 
      39             :     // make a copy of the reader
      40           3 :     reader.Init(mReader);
      41             : 
      42           9 :     while (CHIP_NO_ERROR == (err = reader.Next()))
      43             :     {
      44           6 :         if (!TLV::IsContextTag(reader.GetTag()))
      45             :         {
      46           0 :             continue;
      47             :         }
      48           6 :         uint32_t tagNum = TLV::TagNumFromTag(reader.GetTag());
      49           6 :         switch (tagNum)
      50             :         {
      51           3 :         case to_underlying(Tag::kPath): {
      52           3 :             EventPathIB::Parser path;
      53           3 :             ReturnErrorOnFailure(path.Init(reader));
      54             : 
      55           3 :             PRETTY_PRINT_INCDEPTH();
      56           3 :             ReturnErrorOnFailure(path.PrettyPrint());
      57           3 :             PRETTY_PRINT_DECDEPTH();
      58             :         }
      59           3 :         break;
      60           3 :         case to_underlying(Tag::kErrorStatus): {
      61           3 :             StatusIB::Parser errorStatus;
      62           3 :             ReturnErrorOnFailure(errorStatus.Init(reader));
      63             : 
      64           3 :             PRETTY_PRINT_INCDEPTH();
      65           3 :             ReturnErrorOnFailure(errorStatus.PrettyPrint());
      66           3 :             PRETTY_PRINT_DECDEPTH();
      67             :         }
      68           3 :         break;
      69           0 :         default:
      70           0 :             PRETTY_PRINT("Unknown tag num %" PRIu32, tagNum);
      71           0 :             break;
      72             :         }
      73             :     }
      74             : 
      75           3 :     PRETTY_PRINT("},");
      76           3 :     PRETTY_PRINT_BLANK_LINE();
      77             : 
      78           3 :     if (CHIP_END_OF_TLV == err)
      79             :     {
      80           3 :         err = CHIP_NO_ERROR;
      81             :     }
      82             : 
      83           3 :     ReturnErrorOnFailure(err);
      84           3 :     return reader.ExitContainer(mOuterContainerType);
      85             : }
      86             : #endif // CHIP_CONFIG_IM_PRETTY_PRINT
      87             : 
      88           3 : CHIP_ERROR EventStatusIB::Parser::GetPath(EventPathIB::Parser * const apPath) const
      89             : {
      90             :     TLV::TLVReader reader;
      91           3 :     ReturnErrorOnFailure(mReader.FindElementWithTag(TLV::ContextTag(Tag::kPath), reader));
      92           3 :     return apPath->Init(reader);
      93             : }
      94             : 
      95           3 : CHIP_ERROR EventStatusIB::Parser::GetErrorStatus(StatusIB::Parser * const apErrorStatus) const
      96             : {
      97             :     TLV::TLVReader reader;
      98           3 :     ReturnErrorOnFailure(mReader.FindElementWithTag(TLV::ContextTag(Tag::kErrorStatus), reader));
      99           3 :     return apErrorStatus->Init(reader);
     100             : }
     101             : 
     102           3 : EventPathIB::Builder & EventStatusIB::Builder::CreatePath()
     103             : {
     104           3 :     if (mError == CHIP_NO_ERROR)
     105             :     {
     106           3 :         mError = mPath.Init(mpWriter, to_underlying(Tag::kPath));
     107             :     }
     108           3 :     return mPath;
     109             : }
     110             : 
     111           3 : StatusIB::Builder & EventStatusIB::Builder::CreateErrorStatus()
     112             : {
     113           3 :     if (mError == CHIP_NO_ERROR)
     114             :     {
     115           3 :         mError = mErrorStatus.Init(mpWriter, to_underlying(Tag::kErrorStatus));
     116             :     }
     117           3 :     return mErrorStatus;
     118             : }
     119             : 
     120           3 : CHIP_ERROR EventStatusIB::Builder::EndOfEventStatusIB()
     121             : {
     122           3 :     EndOfContainer();
     123           3 :     return GetError();
     124             : }
     125             : } // namespace app
     126             : } // namespace chip

Generated by: LCOV version 1.14