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

          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 EventReportIBs parser and builder in CHIP interaction model
      21             :  *
      22             :  */
      23             : 
      24             : #include "EventReportIBs.h"
      25             : #include "MessageDefHelper.h"
      26             : 
      27             : #include <inttypes.h>
      28             : #include <stdarg.h>
      29             : #include <stdio.h>
      30             : 
      31             : #include <app/AppConfig.h>
      32             : 
      33             : namespace chip {
      34             : namespace app {
      35             : #if CHIP_CONFIG_IM_PRETTY_PRINT
      36         643 : CHIP_ERROR EventReportIBs::Parser::PrettyPrint() const
      37             : {
      38         643 :     CHIP_ERROR err = CHIP_NO_ERROR;
      39             :     TLV::TLVReader reader;
      40             : 
      41         643 :     PRETTY_PRINT("EventReportIBs =");
      42         643 :     PRETTY_PRINT("[");
      43             : 
      44             :     // make a copy of the reader
      45         643 :     reader.Init(mReader);
      46             : 
      47        2222 :     while (CHIP_NO_ERROR == (err = reader.Next()))
      48             :     {
      49        1579 :         VerifyOrReturnError(TLV::AnonymousTag() == reader.GetTag(), CHIP_ERROR_INVALID_TLV_TAG);
      50             :         {
      51        1579 :             EventReportIB::Parser eventReport;
      52        1579 :             ReturnErrorOnFailure(eventReport.Init(reader));
      53        1579 :             PRETTY_PRINT_INCDEPTH();
      54        1579 :             ReturnErrorOnFailure(eventReport.PrettyPrint());
      55        1579 :             PRETTY_PRINT_DECDEPTH();
      56             :         }
      57             :     }
      58             : 
      59         643 :     PRETTY_PRINT("],");
      60         643 :     PRETTY_PRINT_BLANK_LINE();
      61             : 
      62             :     // if we have exhausted this container
      63         643 :     if (CHIP_END_OF_TLV == err)
      64             :     {
      65         643 :         err = CHIP_NO_ERROR;
      66             :     }
      67         643 :     ReturnErrorOnFailure(err);
      68         643 :     return reader.ExitContainer(mOuterContainerType);
      69             : }
      70             : #endif // CHIP_CONFIG_IM_PRETTY_PRINT
      71             : 
      72           2 : EventReportIB::Builder & EventReportIBs::Builder::CreateEventReport()
      73             : {
      74           2 :     if (mError == CHIP_NO_ERROR)
      75             :     {
      76           2 :         mError = mEventReport.Init(mpWriter);
      77             :     }
      78           2 :     return mEventReport;
      79             : }
      80             : 
      81         866 : CHIP_ERROR EventReportIBs::Builder::EndOfEventReports()
      82             : {
      83         866 :     EndOfContainer();
      84         866 :     return GetError();
      85             : }
      86             : } // namespace app
      87             : } // namespace chip

Generated by: LCOV version 1.14