• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef HIAPPEVENT_C_H
17 #define HIAPPEVENT_C_H
18 
19 #include <stdbool.h>
20 
21 #include "hiappevent/hiappevent.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /**
28  * @brief Event Param types.
29  *
30  * @since 8
31  * @version 1.0
32  */
33 enum ParamType {
34     /* param type of the bool */
35     BOOL_PARAM = 0,
36 
37     /* param type of the bool array */
38     BOOL_ARR_PARAM = 1,
39 
40     /* param type of the int8_t */
41     INT8_PARAM = 2,
42 
43     /* param type of the int8_t array */
44     INT8_ARR_PARAM = 3,
45 
46     /* param type of the int16_t */
47     INT16_PARAM = 4,
48 
49     /* param type of the int16_t array */
50     INT16_ARR_PARAM = 5,
51 
52     /* param type of the int32_t */
53     INT32_PARAM = 6,
54 
55     /* param type of the int32_t array */
56     INT32_ARR_PARAM = 7,
57 
58     /* param type of the int64_t */
59     INT64_PARAM = 8,
60 
61     /* param type of the int64_t array */
62     INT64_ARR_PARAM = 9,
63 
64     /* param type of the float */
65     FLOAT_PARAM = 10,
66 
67     /* param type of the float array */
68     FLOAT_ARR_PARAM = 11,
69 
70     /* param type of the double */
71     DOUBLE_PARAM = 12,
72 
73     /* param type of the double array */
74     DOUBLE_ARR_PARAM = 13,
75 
76     /* param type of the string */
77     STRING_PARAM = 14,
78 
79     /* param type of the string array */
80     STRING_ARR_PARAM = 15
81 };
82 
83 /**
84  * @brief Event param value.
85  *
86  * @since 8
87  * @version 1.0
88  */
89 typedef struct ParamValue {
90     /* param type */
91     enum ParamType type;
92 
93     /* param value */
94     union Value {
95         /* param value of the bool type */
96         bool bool_v;
97 
98         /* param value of the bool array type */
99         const bool* bool_arr_v;
100 
101         /* param value of the int8_t type */
102         int8_t int8_v;
103 
104         /* param value of the int8_t array type */
105         const int8_t* int8_arr_v;
106 
107         /* param value of the int16_t type */
108         int16_t int16_v;
109 
110         /* param value of the int16_t array type */
111         const int16_t* int16_arr_v;
112 
113         /* param value of the int32_t type */
114         int32_t int32_v;
115 
116         /* param value of the int32_t array type */
117         const int32_t* int32_arr_v;
118 
119         /* param value of the int64_t type */
120         int64_t int64_v;
121 
122         /* param value of the int64_t array type */
123         const int64_t* int64_arr_v;
124 
125         /* param value of the float type */
126         float float_v;
127 
128         /* param value of the float array type */
129         const float* float_arr_v;
130 
131         /* param value of the double type */
132         double double_v;
133 
134         /* param value of the double array type */
135         const double* double_arr_v;
136 
137         /* param value of the string type */
138         const char* str_v;
139 
140         /* param value of the string array type */
141         const char * const *str_arr_v;
142     } value;
143 
144     /* If the param type is array, the array size must be passed in. */
145     int arrSize;
146 } ParamValue;
147 
148 /**
149  * @brief Event param entry.
150  *
151  * @since 8
152  * @version 1.0
153  */
154 typedef struct ParamEntry {
155     /* the name of param */
156     const char* name;
157 
158     /* the value of param */
159     ParamValue* value;
160 } ParamEntry;
161 
162 /**
163  * @brief Event param list node.
164  *
165  * @since 8
166  * @version 1.0
167  */
168 typedef struct ParamListNode {
169     /* param entry */
170     ParamEntry* entry;
171 
172     /* next param node */
173     struct ParamListNode* next;
174 } ParamListNode, *ParamList;
175 
176 bool HiAppEventInnerConfigure(const char* name, const char* value);
177 
178 int HiAppEventInnerWrite(const char* domain, const char* name, enum EventType type, const ParamList list);
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 #endif // HIAPPEVENT_C_H
184