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

Generated by: LCOV version 1.14