1/*
2 * Copyright (C) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @addtogroup Bluetooth
18 * @{
19 *
20 * @brief Defines a bluetooth system that provides basic blurtooth connection and profile functions,
21 *        including A2DP, AVRCP, BLE, GATT, HFP, MAP, PBAP, and SPP, etc.
22 *
23 * @since 6
24 */
25
26/**
27 * @file bluetooth_socket_inputstream.h
28 *
29 * @brief Declares spp outputstream framework functions, including basic functions.
30 *
31 * @since 6
32 */
33
34#ifndef BLUETOOTH_INPUTSTREAM_H
35#define BLUETOOTH_INPUTSTREAM_H
36
37#include "bluetooth_def.h"
38#include "bluetooth_types.h"
39
40namespace OHOS {
41namespace Bluetooth {
42/**
43 * @brief Class for spp input stream functions.
44 *
45 * @since 6
46 */
47class BLUETOOTH_API InputStream {
48public:
49    /**
50     * @brief A constructor used to create an inputStream instance.
51     *
52     * @param socketFd Socket fd.
53     * @since 6
54     */
55    explicit InputStream(int socketFd);
56
57    /**
58     * @brief Destroy the inputStream object.
59     *
60     * @since 6
61     */
62    virtual ~InputStream();
63
64    /**
65     * @brief Socket read.
66     *
67     * @param buf Data to be read.
68     * @param length The length of data to be read.
69     * @return Returns the length greater than <b>0</b> as read the actual length.
70     *         Returns <b>0</b> if the socket is closed.
71     *         Returns <b>-1</b> if the operation fails.
72     * @since 6
73     */
74    ssize_t Read(uint8_t *buf, size_t length);
75
76private:
77    int socketFd_;
78    InputStream() = delete;
79};
80} // namespace Bluetooth
81} // namespace OHOS
82#endif  // BLUETOOTH_INPUTSTREAM_H