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 : #include "EventPathIBs.h"
20 :
21 : #include "MessageDefHelper.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 342 : CHIP_ERROR EventPathIBs::Parser::PrettyPrint() const
33 : {
34 342 : CHIP_ERROR err = CHIP_NO_ERROR;
35 342 : TLV::TLVReader reader;
36 :
37 342 : PRETTY_PRINT("EventPathIBs =");
38 342 : PRETTY_PRINT("[");
39 :
40 : // make a copy of the EventPathIBs reader
41 342 : reader.Init(mReader);
42 :
43 848 : while (CHIP_NO_ERROR == (err = reader.Next()))
44 : {
45 506 : VerifyOrReturnError(TLV::AnonymousTag() == reader.GetTag(), CHIP_ERROR_INVALID_TLV_TAG);
46 506 : VerifyOrReturnError(TLV::kTLVType_List == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE);
47 :
48 : {
49 506 : EventPathIB::Parser path;
50 506 : ReturnErrorOnFailure(path.Init(reader));
51 :
52 506 : PRETTY_PRINT_INCDEPTH();
53 506 : ReturnErrorOnFailure(path.PrettyPrint());
54 506 : PRETTY_PRINT_DECDEPTH();
55 : }
56 : }
57 :
58 342 : PRETTY_PRINT("],");
59 342 : PRETTY_PRINT_BLANK_LINE();
60 :
61 : // if we have exhausted this container
62 342 : if (CHIP_END_OF_TLV == err)
63 : {
64 342 : err = CHIP_NO_ERROR;
65 : }
66 342 : ReturnErrorOnFailure(err);
67 342 : return reader.ExitContainer(mOuterContainerType);
68 : }
69 : #endif // CHIP_CONFIG_IM_PRETTY_PRINT
70 :
71 514 : EventPathIB::Builder & EventPathIBs::Builder::CreatePath()
72 : {
73 514 : if (mError == CHIP_NO_ERROR)
74 : {
75 514 : mError = mEventPath.Init(mpWriter);
76 : }
77 514 : return mEventPath;
78 : }
79 :
80 346 : CHIP_ERROR EventPathIBs::Builder::EndOfEventPaths()
81 : {
82 346 : EndOfContainer();
83 346 : return GetError();
84 : }
85 : }; // namespace app
86 : }; // namespace chip
|