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 
16 #ifndef FRAMEWORKS_BRIDGE_CJ_FRONTEND_CJ_PERSISTENT_H
17 #define FRAMEWORKS_BRIDGE_CJ_FRONTEND_CJ_PERSISTENT_H
18 
19 #include <string>
20 #include "base/memory/referenced.h"
21 #include "ffi_remote_data.h"
22 #include "bridge/cj_frontend/interfaces/cj_ffi/cj_common_ffi.h"
23 #include "bridge/cj_frontend/interfaces/cj_ffi/cj_macro.h"
24 
25 using NotifyCallbackString = void (*)(const char* key, const char* value);
26 using NotifyCallbackInt64 = void (*)(const char* key, int64_t value);
27 using NotifyCallbackFloat64 = void (*)(const char* key, double value);
28 using NotifyCallbackBool = void (*)(const char* key, bool value);
29 
30 extern "C" {
31 CJ_EXPORT NativeOptionCString FfiOHOSAceFrameworkPersistentGetString(const char* key);
32 CJ_EXPORT NativeOptionInt64 FfiOHOSAceFrameworkPersistentGetInt64(const char* key);
33 CJ_EXPORT NativeOptionFloat64 FfiOHOSAceFrameworkPersistentGetFloat64(const char* key);
34 CJ_EXPORT NativeOptionBool FfiOHOSAceFrameworkPersistentGetBool(const char* key);
35 
36 CJ_EXPORT void FfiOHOSAceFrameworkPersistentSetString(
37     const char* key, const char* value, NotifyCallbackString callback);
38 CJ_EXPORT void FfiOHOSAceFrameworkPersistentSetInt64(const char* key, int64_t value, NotifyCallbackInt64 callback);
39 CJ_EXPORT void FfiOHOSAceFrameworkPersistentSetFloat64(const char* key, double value, NotifyCallbackFloat64 callback);
40 CJ_EXPORT void FfiOHOSAceFrameworkPersistentSetBool(const char* key, bool value, NotifyCallbackBool callback);
41 
42 CJ_EXPORT void FfiOHOSAceFrameworkPersistentDelete(const char* key);
43 CJ_EXPORT void FfiOHOSAceFrameworkPersistentClear();
44 }
45 #endif // FRAMEWORKS_BRIDGE_CJ_FRONTEND_CJ_PERSISTENT_H