• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef HDF_SBU_IMPL_H
10 #define HDF_SBU_IMPL_H
11 
12 #include "hdf_base.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif /* __cplusplus */
17 
18 struct HdfSbufConstructor {
19     struct HdfSBufImpl *(*obtain)(size_t capacity);
20     struct HdfSBufImpl *(*bind)(uintptr_t base, size_t size);
21 };
22 
23 struct HdfRemoteService;
24 
25 struct HdfSBufImpl {
26     bool (*writeBuffer)(struct HdfSBufImpl *sbuf, const uint8_t *data, uint32_t writeSize);
27     bool (*writeUnpadBuffer)(struct HdfSBufImpl *sbuf, const uint8_t *data, uint32_t writeSize);
28     bool (*writeUint64)(struct HdfSBufImpl *sbuf, uint64_t value);
29     bool (*writeUint32)(struct HdfSBufImpl *sbuf, uint32_t value);
30     bool (*writeUint16)(struct HdfSBufImpl *sbuf, uint16_t value);
31     bool (*writeUint8)(struct HdfSBufImpl *sbuf, uint8_t value);
32     bool (*writeInt64)(struct HdfSBufImpl *sbuf, int64_t value);
33     bool (*writeInt32)(struct HdfSBufImpl *sbuf, int32_t value);
34     bool (*writeInt16)(struct HdfSBufImpl *sbuf, int16_t value);
35     bool (*writeInt8)(struct HdfSBufImpl *sbuf, int8_t value);
36     bool (*writeString)(struct HdfSBufImpl *sbuf, const char *value);
37     bool (*writeFileDescriptor)(struct HdfSBufImpl *sbuf, int fd);
38     bool (*writeFloat)(struct HdfSBufImpl *sbuf, float value);
39     bool (*writeDouble)(struct HdfSBufImpl *sbuf, double value);
40     bool (*readDouble)(struct HdfSBufImpl *sbuf, double *value);
41     bool (*readFloat)(struct HdfSBufImpl *sbuf, float *value);
42     int (*readFileDescriptor)(struct HdfSBufImpl *sbuf);
43     bool (*writeString16)(struct HdfSBufImpl *sbuf, const char16_t *value, uint32_t size);
44     bool (*readBuffer)(struct HdfSBufImpl *sbuf, const uint8_t **data, uint32_t *readSize);
45     const uint8_t *(*readUnpadBuffer)(struct HdfSBufImpl *sbuf, size_t length);
46     bool (*readUint64)(struct HdfSBufImpl *sbuf, uint64_t *value);
47     bool (*readUint32)(struct HdfSBufImpl *sbuf, uint32_t *value);
48     bool (*readUint16)(struct HdfSBufImpl *sbuf, uint16_t *value);
49     bool (*readUint8)(struct HdfSBufImpl *sbuf, uint8_t *value);
50     bool (*readInt64)(struct HdfSBufImpl *sbuf, int64_t *value);
51     bool (*readInt32)(struct HdfSBufImpl *sbuf, int32_t *value);
52     bool (*readInt16)(struct HdfSBufImpl *sbuf, int16_t *value);
53     bool (*readInt8)(struct HdfSBufImpl *sbuf, int8_t *value);
54     const char *(*readString)(struct HdfSBufImpl *sbuf);
55     const char16_t *(*readString16)(struct HdfSBufImpl *sbuf);
56     int32_t (*writeRemoteService)(struct HdfSBufImpl *sbuf, const struct HdfRemoteService *service);
57     struct HdfRemoteService *(*readRemoteService)(struct HdfSBufImpl *sbuf);
58     const uint8_t *(*getData)(const struct HdfSBufImpl *sbuf);
59     void (*flush)(struct HdfSBufImpl *sbuf);
60     size_t (*getCapacity)(const struct HdfSBufImpl *sbuf);
61     size_t (*getDataSize)(const struct HdfSBufImpl *sbuf);
62     void (*setDataSize)(struct HdfSBufImpl *sbuf, size_t size);
63     void (*recycle)(struct HdfSBufImpl *sbuf);
64     struct HdfSBufImpl *(*move)(struct HdfSBufImpl *sbuf);
65     struct HdfSBufImpl *(*copy)(const struct HdfSBufImpl *sbuf);
66     void (*transDataOwnership)(struct HdfSBufImpl *sbuf);
67 };
68 
69 #ifdef __cplusplus
70 }
71 #endif /* __cplusplus */
72 
73 #endif /* HDF_SBUF_H */
74 /** @} */
75