• 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 OHOS_WIFI_CONFIG_FILE_SPEC_H
17 #define OHOS_WIFI_CONFIG_FILE_SPEC_H
18 #include <fstream>
19 #include <sstream>
20 #include <string>
21 #include <vector>
22 #include "wifi_internal_msg.h"
23 #include "wifi_p2p_msg.h"
24 namespace OHOS {
25 namespace Wifi {
26 /* ----------------- template function begin ----------------------- */
27 /**
28  * @Description Clear and init item
29  *
30  * @tparam T - typename
31  * @param item - item
32  */
33 template <typename T>
ClearTClass(T & item)34 void ClearTClass(T &item)
35 {
36     /* fixed compile warning, -Werror,-Wunused-parameter */
37     item;
38     return;
39 }
40 
41 /**
42  * @Description Set item's data, input key is the item's member and input value is the
43  *              member's value
44  *
45  * @tparam T - typename
46  * @param item - T &item
47  * @param key - Item key
48  * @param value - Item value
49  */
50 template <typename T>
SetTClassKeyValue(T & item,const std::string & key,const std::string & value)51 void SetTClassKeyValue(T &item, const std::string &key, const std::string &value)
52 {
53     /* fixed compile warning, -Werror,-Wunused-parameter */
54     item;
55     std::ostringstream ss;
56     ss << key << value << std::endl;
57     return;
58 }
59 
60 /**
61  * @Description Output the item's head
62  *
63  * @tparam T - typename
64  * @param item - item
65  * @return std::string - the item's type name
66  */
67 template <typename T>
GetTClassName()68 std::string GetTClassName()
69 {
70     return "";
71 }
72 
73 /**
74  * @Description Output the item, format: item's member = the member value
75  *
76  * @tparam T - typename
77  * @param item - item
78  * @return std::string - output item's total member=value string
79  */
80 template <typename T>
OutTClassString(T & item)81 std::string OutTClassString(T &item)
82 {
83     /* fixed compile warning, -Werror,-Wunused-parameter */
84     item;
85     std::string s;
86     return s;
87 }
88 
89 /* ----------------- template function end --------------------------------- */
90 
91 /* ------------template function specialization declare begin-------------- */
92 /**
93  * @Description Clear and init WifiDeviceConfig
94  *
95  * @tparam
96  * @param item - WifiDeviceConfig item
97  */
98 template <>
99 void ClearTClass<WifiDeviceConfig>(WifiDeviceConfig &item);
100 
101 /**
102  * @Description Set WifiDeviceConfig item data
103  *
104  * @tparam
105  * @param item - WifiDeviceConfig &item
106  * @param key - WifiDeviceConfig struct member name
107  * @param value - the WifiDeviceConfig item member value
108  */
109 template <>
110 void SetTClassKeyValue<WifiDeviceConfig>(WifiDeviceConfig &item, const std::string &key, const std::string &value);
111 
112 /**
113  * @Description Output WifiDeviceConfig class name
114  *
115  * @tparam
116  * @param item - WifiDeviceConfig &item
117  * @return std::string - Class name
118  */
119 template <>
120 std::string GetTClassName<WifiDeviceConfig>();
121 
122 /**
123  * @Description Output the WifiDeviceConfig item, format: item's member = the member value
124  *
125  * @tparam
126  * @param item - WifiDeviceConfig &item
127  * @return std::string - output total member=value string about the WifiDeviceConfig item
128  */
129 template <>
130 std::string OutTClassString<WifiDeviceConfig>(WifiDeviceConfig &item);
131 
132 /**
133  * @Description Clear and init HotspotConfig
134  *
135  * @tparam
136  * @param item - HotspotConfig item
137  */
138 template <>
139 void ClearTClass<HotspotConfig>(HotspotConfig &item);
140 
141 /**
142  * @Description Set HotspotConfig item data
143  *
144  * @tparam
145  * @param item - HotspotConfig &item
146  * @param key - HotspotConfig struct member name
147  * @param value - the HotspotConfig item member value
148  */
149 template <>
150 void SetTClassKeyValue<HotspotConfig>(HotspotConfig &item, const std::string &key, const std::string &value);
151 
152 /**
153  * @Description Output HotspotConfig class name
154  *
155  * @tparam
156  * @param item - HotspotConfig &item
157  * @return std::string - Class name
158  */
159 template <>
160 std::string GetTClassName<HotspotConfig>();
161 
162 /**
163  * @Description Output the HotspotConfig item, format: item's member = the member value
164  *
165  * @tparam
166  * @param item - HotspotConfig &item
167  * @return std::string - output total member=value string about the HotspotConfig item
168  */
169 template <>
170 std::string OutTClassString<HotspotConfig>(HotspotConfig &item);
171 
172 /**
173  * @Description Clear and init P2pVendorConfig
174  *
175  * @tparam
176  * @param item - P2pVendorConfig &item
177  */
178 template<>
179 void ClearTClass<P2pVendorConfig>(P2pVendorConfig &item);
180 
181 /**
182  * @Description Set P2pVendorConfig item data
183  *
184  * @tparam
185  * @param item - P2pVendorConfig &item
186  * @param key - P2pVendorConfig struct member name
187  * @param value - the P2pVendorConfig item member value
188  */
189 template<>
190 void SetTClassKeyValue<P2pVendorConfig>(P2pVendorConfig &item, const std::string &key, const std::string &value);
191 
192 /**
193  * @Description Output P2pVendorConfig class name
194  *
195  * @tparam
196  * @param item - P2pVendorConfig &item
197  * @return std::string - Class name
198  */
199 template<>
200 std::string GetTClassName<P2pVendorConfig>();
201 
202 /**
203  * @Description Output the P2pVendorConfig item, format: item's member = the member value
204  *
205  * @tparam
206  * @param item - P2pVendorConfig &item
207  * @return std::string - output total member=value string about the P2pVendorConfig item
208  */
209 template<>
210 std::string OutTClassString<P2pVendorConfig>(P2pVendorConfig &item);
211 
212 /**
213  * @Description Clear and init StationInfo
214  *
215  * @tparam
216  * @param item - StationInfo &item
217  */
218 template <>
219 void ClearTClass<StationInfo>(StationInfo &item);
220 
221 /**
222  * @Description Set StationInfo item data
223  *
224  * @tparam
225  * @param item - StationInfo &item
226  * @param key - StationInfo struct member name
227  * @param value - the StationInfo item member value
228  */
229 template <>
230 void SetTClassKeyValue<StationInfo>(StationInfo &item, const std::string &key, const std::string &value);
231 
232 /**
233  * @Description Output StationInfo class name
234  *
235  * @tparam
236  * @param item - StationInfo &item
237  * @return std::string - Class name
238  */
239 template <>
240 std::string GetTClassName<StationInfo>();
241 
242 /**
243  * @Description Output the StationInfo item, format: item's member = the member value
244  *
245  * @tparam
246  * @param item - StationInfo &item
247  * @return std::string - output total member=value string about the StationInfo item
248  */
249 template <>
250 std::string OutTClassString<StationInfo>(StationInfo &item);
251 
252 /**
253  * @Description Clear and init WifiConfig
254  *
255  * @tparam
256  * @param item - WifiConfig &item
257  */
258 template <>
259 void ClearTClass<WifiConfig>(WifiConfig &item);
260 
261 /**
262  * @Description Set WifiConfig item data
263  *
264  * @tparam
265  * @param item - WifiConfig &item
266  * @param key - WifiConfig struct member name
267  * @param value - the WifiConfig item member value
268  */
269 template <>
270 void SetTClassKeyValue<WifiConfig>(WifiConfig &item, const std::string &key, const std::string &value);
271 
272 /**
273  * @Description Output WifiConfig class name
274  *
275  * @tparam
276  * @param item - WifiConfig &item
277  * @return std::string - Class name
278  */
279 template <>
280 std::string GetTClassName<WifiConfig>();
281 
282 /**
283  * @Description Output the WifiConfig item, format: item's member = the member value
284  *
285  * @tparam
286  * @param item - WifiConfig &item
287  * @return std::string - output total member=value string about the WifiConfig item
288  */
289 template <>
290 std::string OutTClassString<WifiConfig>(WifiConfig &item);
291 
292 /**
293  * @Description Clear and init WifiP2pGroupInfo
294  *
295  * @tparam
296  * @param item - WifiP2pGroupInfo item
297  */
298 template<>
299 void ClearTClass<WifiP2pGroupInfo>(WifiP2pGroupInfo &item);
300 
301 /**
302  * @Description Set WifiP2pGroupInfo item data
303  *
304  * @tparam
305  * @param item - WifiP2pGroupInfo &item
306  * @param key - WifiP2pGroupInfo struct member name
307  * @param value - the WifiP2pGroupInfo item member value
308  */
309 template<>
310 void SetTClassKeyValue<WifiP2pGroupInfo>(WifiP2pGroupInfo &item, const std::string &key, const std::string &value);
311 
312 /**
313  * @Description Output WifiP2pGroupInfo class name
314  *
315  * @tparam
316  * @param item - WifiP2pGroupInfo &item
317  * @return std::string - Class name
318  */
319 template<>
320 std::string GetTClassName<WifiP2pGroupInfo>();
321 
322 /**
323  * @Description Output the WifiP2pGroupInfo item, format: item's member = the member value
324  *
325  * @tparam
326  * @param item - WifiP2pGroupInfo &item
327  * @return std::string - output total member=value string about the WifiP2pGroupInfo item
328  */
329 template<>
330 std::string OutTClassString<WifiP2pGroupInfo>(WifiP2pGroupInfo &item);
331 
332 /**
333  * @Description Clear and init TrustListPolicy
334  *
335  * @tparam
336  * @param item - TrustListPolicy &item
337  */
338 template <>
339 void ClearTClass<TrustListPolicy>(TrustListPolicy &item);
340 
341 /**
342  * @Description Set TrustListPolicy item data
343  *
344  * @tparam
345  * @param item - TrustListPolicy &item
346  * @param key - TrustListPolicy struct member name
347  * @param value - the TrustListPolicy item member value
348  */
349 template <>
350 void SetTClassKeyValue<TrustListPolicy>(TrustListPolicy &item, const std::string &key, const std::string &value);
351 
352 /**
353  * @Description Output TrustListPolicy class name
354  *
355  * @tparam
356  * @param item - TrustListPolicy &item
357  * @return std::string - Class name
358  */
359 template <>
360 std::string GetTClassName<TrustListPolicy>();
361 
362 /**
363  * @Description Output the TrustListPolicy item, format: item's member = the member value
364  *
365  * @tparam
366  * @param item - TrustListPolicy &item
367  * @return std::string - output total member=value string about the TrustListPolicy item
368  */
369 template <>
370 std::string OutTClassString<TrustListPolicy>(TrustListPolicy &item);
371 
372 /**
373  * @Description Clear and init MovingFreezePolicy
374  *
375  * @tparam
376  * @param item - MovingFreezePolicy &item
377  */
378 template <>
379 void ClearTClass<MovingFreezePolicy>(MovingFreezePolicy &item);
380 
381 /**
382  * @Description Set MovingFreezePolicy item data
383  *
384  * @tparam
385  * @param item - MovingFreezePolicy &item
386  * @param key - MovingFreezePolicy struct member name
387  * @param value - the MovingFreezePolicy item member value
388  */
389 template <>
390 void SetTClassKeyValue<MovingFreezePolicy>(MovingFreezePolicy &item, const std::string &key, const std::string &value);
391 
392 /**
393  * @Description Output MovingFreezePolicy class name
394  *
395  * @tparam
396  * @param item - MovingFreezePolicy &item
397  * @return std::string - Class name
398  */
399 template <>
400 std::string GetTClassName<MovingFreezePolicy>();
401 
402 /**
403  * @Description Output the MovingFreezePolicy item, format: item's member = the member value
404  *
405  * @tparam
406  * @param item - MovingFreezePolicy &item
407  * @return std::string - output total member=value string about the MovingFreezePolicy item
408  */
409 template <>
410 std::string OutTClassString<MovingFreezePolicy>(MovingFreezePolicy &item);
411 
412 /**
413  * @Description Clear and init WifiStoreRandomMac
414  *
415  * @tparam
416  * @param item - WifiStoreRandomMac &item
417  */
418 template <>
419 void ClearTClass<WifiStoreRandomMac>(WifiStoreRandomMac &item);
420 
421 /**
422  * @Description Set WifiStoreRandomMac item data
423  *
424  * @tparam
425  * @param item - WifiStoreRandomMac &item
426  * @param key - WifiStoreRandomMac struct member name
427  * @param value - the WifiStoreRandomMac item member value
428  */
429 template <>
430 void SetTClassKeyValue<WifiStoreRandomMac>(WifiStoreRandomMac &item, const std::string &key, const std::string &value);
431 
432 /**
433  * @Description Output WifiStoreRandomMac class name
434  *
435  * @tparam
436  * @param item - WifiStoreRandomMac &item
437  * @return std::string - Class name
438  */
439 template <>
440 std::string GetTClassName<WifiStoreRandomMac>();
441 
442 /**
443  * @Description Output the WifiStoreRandomMac item, format: item's member = the member value
444  *
445  * @tparam
446  * @param item - WifiStoreRandomMac &item
447  * @return std::string - output total member=value string about the WifiStoreRandomMac item
448  */
449 template <>
450 std::string OutTClassString<WifiStoreRandomMac>(WifiStoreRandomMac &item);
451 /* ----------template function specialization declare end----------- */
452 }  // namespace Wifi
453 }  // namespace OHOS
454 #endif