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 parser in CHIP interaction model
21 : *
22 : */
23 :
24 : #include "Parser.h"
25 :
26 : #include <inttypes.h>
27 : #include <stdarg.h>
28 : #include <stdio.h>
29 :
30 : namespace chip {
31 : namespace app {
32 :
33 116794 : Parser::Parser() : mOuterContainerType(chip::TLV::kTLVType_NotSpecified) {}
34 :
35 0 : void Parser::Init(const chip::TLV::TLVReader & aReader, chip::TLV::TLVType aOuterContainerType)
36 : {
37 0 : mReader.Init(aReader);
38 0 : mOuterContainerType = aOuterContainerType;
39 0 : }
40 :
41 0 : CHIP_ERROR Parser::GetReaderOnTag(const TLV::Tag aTagToFind, chip::TLV::TLVReader * const apReader) const
42 : {
43 0 : return mReader.FindElementWithTag(aTagToFind, *apReader);
44 : }
45 :
46 8335 : void Parser::GetReader(chip::TLV::TLVReader * const apReader)
47 : {
48 8335 : apReader->Init(mReader);
49 8335 : }
50 :
51 2 : CHIP_ERROR Parser::Next()
52 : {
53 2 : CHIP_ERROR err = mReader.Next();
54 2 : ChipLogIfFalse((CHIP_NO_ERROR == err) || (CHIP_END_OF_TLV == err));
55 2 : return err;
56 : }
57 : } // namespace app
58 : } // namespace chip
|