Coverage Report

Created: 2026-01-22 06:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/connectedhomeip/src/app/MessageDef/AttributeDataIB.h
Line
Count
Source
1
/**
2
 *
3
 *    Copyright (c) 2020-2021 Project CHIP Authors
4
 *    Copyright (c) 2016-2017 Nest Labs, Inc.
5
 *
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
#pragma once
20
21
#include "AttributePathIB.h"
22
#include "StructBuilder.h"
23
#include "StructParser.h"
24
25
#include <app/AppConfig.h>
26
#include <app/util/basic-types.h>
27
#include <lib/core/CHIPCore.h>
28
#include <lib/core/TLV.h>
29
#include <lib/support/CodeUtils.h>
30
#include <lib/support/logging/CHIPLogging.h>
31
32
namespace chip {
33
namespace app {
34
namespace AttributeDataIB {
35
enum class Tag : uint8_t
36
{
37
    kDataVersion = 0,
38
    kPath        = 1,
39
    kData        = 2,
40
};
41
42
class Parser : public StructParser
43
{
44
public:
45
#if CHIP_CONFIG_IM_PRETTY_PRINT
46
    CHIP_ERROR PrettyPrint() const;
47
#endif // CHIP_CONFIG_IM_PRETTY_PRINT
48
    /**
49
     *  @brief Get the DataVersion.
50
     *
51
     *  @param [in] apVersion    A pointer to apVersion
52
     *
53
     *  @return #CHIP_NO_ERROR on success
54
     *          #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
55
     *          #CHIP_END_OF_TLV if there is no such element
56
     */
57
    CHIP_ERROR GetDataVersion(chip::DataVersion * const apVersion) const;
58
59
    /**
60
     *  @brief Get a TLVReader for the AttributePathIB. Next() must be called before accessing them.
61
     *
62
     *  @param [in] apAttributePath    A pointer to apAttributePath
63
     *
64
     *  @return #CHIP_NO_ERROR on success
65
     *          #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not a Path
66
     *          #CHIP_END_OF_TLV if there is no such element
67
     */
68
    CHIP_ERROR GetPath(AttributePathIB::Parser * const apAttributePath) const;
69
70
    /**
71
     *  @brief Get a TLVReader for the Data. Next() must be called before accessing them.
72
     *
73
     *  @param [in] apReader    A pointer to apReader
74
     *
75
     *  @return #CHIP_NO_ERROR on success
76
     *          #CHIP_END_OF_TLV if there is no such element
77
     */
78
    CHIP_ERROR GetData(TLV::TLVReader * const apReader) const;
79
};
80
81
class Builder : public StructBuilder
82
{
83
public:
84
    /**
85
     *  @brief Inject DataVersion into the TLV stream to indicate the numerical data version associated with
86
     *  the cluster that is referenced by the path.
87
     *
88
     *  @param [in] aDataVersion The boolean variable to indicate if AttributeDataIB has version
89
     *
90
     *  @return A reference to *this
91
     */
92
    AttributeDataIB::Builder & DataVersion(const chip::DataVersion aDataVersion);
93
94
    /**
95
     *  @brief Initialize a AttributePathIB::Builder for writing into the TLV stream
96
     *
97
     *  @return A reference to AttributePathIB::Builder
98
     */
99
    AttributePathIB::Builder & CreatePath();
100
101
    /**
102
     *  @brief Mark the end of this AttributeDataIB
103
     *
104
     *  @return Our The builder's final status.
105
     */
106
    CHIP_ERROR EndOfAttributeDataIB();
107
108
    /**
109
     *  @brief Get number of bytes required in the buffer to allow EndOfAttributeDataIB() to succeed.
110
     *
111
     *  @return Expected number of bytes required in the buffer to successfully execute EndOfAttributeDataIB()
112
     */
113
    static constexpr uint16_t GetSizeToEndAttributeDataIB()
114
0
    {
115
0
        uint16_t kEndOfAttributeDataIBSize = 1;
116
0
        return kEndOfAttributeDataIBSize;
117
0
    };
118
119
private:
120
    AttributePathIB::Builder mPath;
121
};
122
} // namespace AttributeDataIB
123
} // namespace app
124
} // namespace chip