1 /*
2 * Copyright (C) 2024 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 #include <cJSON.h>
16
17 #include "cJsonMock.h"
18
cJSON_CreateArray(void)19 CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void)
20 {
21 return OHOS::FileManagement::Backup::CJson::cJsonPtr->cJSON_CreateArray();
22 }
23
cJSON_CreateObject(void)24 CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void)
25 {
26 return OHOS::FileManagement::Backup::CJson::cJsonPtr->cJSON_CreateObject();
27 }
28
cJSON_Print(const cJSON * item)29 CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item)
30 {
31 return OHOS::FileManagement::Backup::CJson::cJsonPtr->cJSON_Print(item);
32 }
33
CJSONParse(const char * value)34 CJSON_PUBLIC(cJSON *) CJSONParse(const char *value)
35 {
36 return OHOS::FileManagement::Backup::CJson::cJsonPtr->cJSON_Parse(value);
37 }
38
CJSONGetObjectItem(const cJSON * const object,const char * const string)39 CJSON_PUBLIC(cJSON *) CJSONGetObjectItem(const cJSON *const object, const char *const string)
40 {
41 return OHOS::FileManagement::Backup::CJson::cJsonPtr->cJSON_GetObjectItem(object, string);
42 }
43
CJSONDelete(cJSON * item)44 CJSON_PUBLIC(void) CJSONDelete(cJSON *item)
45 {
46 return OHOS::FileManagement::Backup::CJson::cJsonPtr->cJSON_Delete(item);
47 }
48
cJSON_AddItemToObject(cJSON * object,const char * string,cJSON * item)49 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
50 {
51 return OHOS::FileManagement::Backup::CJson::cJsonPtr->cJSON_AddItemToObject(object, string, item);
52 }
53
cJSON_GetArraySize(const cJSON * array)54 CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array)
55 {
56 return OHOS::FileManagement::Backup::CJson::cJsonPtr->cJSON_GetArraySize(array);
57 }
58
cJSON_AddItemToArray(cJSON * array,cJSON * item)59 CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item)
60 {
61 return OHOS::FileManagement::Backup::CJson::cJsonPtr->cJSON_AddItemToArray(array, item);
62 }
63
cJSON_AddStringToObject(cJSON * const object,const char * const name,const char * const string)64 CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string)
65 {
66 return OHOS::FileManagement::Backup::CJson::cJsonPtr->cJSON_AddStringToObject(object, name, string);
67 }
68
CJSONIsArray(const cJSON * const item)69 CJSON_PUBLIC(cJSON_bool) CJSONIsArray(const cJSON * const item)
70 {
71 return OHOS::FileManagement::Backup::CJson::cJsonPtr->cJSON_IsArray(item);
72 }
73
CJSONFree(void * object)74 CJSON_PUBLIC(void) CJSONFree(void *object)
75 {
76 return OHOS::FileManagement::Backup::CJson::cJsonPtr->cJSON_free(object);
77 }