• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #define LOG_TAG "CloudLastSyncInfo"
16 #include "cloud/cloud_last_sync_info.h"
17 
18 #include "utils/constant.h"
19 namespace OHOS::DistributedData {
Marshal(Serializable::json & node) const20 bool CloudLastSyncInfo::Marshal(Serializable::json &node) const
21 {
22     SetValue(node[GET_NAME(id)], id);
23     SetValue(node[GET_NAME(storeId)], storeId);
24     SetValue(node[GET_NAME(startTime)], startTime);
25     SetValue(node[GET_NAME(finishTime)], finishTime);
26     SetValue(node[GET_NAME(code)], code);
27     SetValue(node[GET_NAME(syncStatus)], syncStatus);
28     SetValue(node[GET_NAME(instanceId)], instanceId);
29     return true;
30 }
31 
Unmarshal(const Serializable::json & node)32 bool CloudLastSyncInfo::Unmarshal(const Serializable::json &node)
33 {
34     GetValue(node, GET_NAME(id), id);
35     GetValue(node, GET_NAME(storeId), storeId);
36     GetValue(node, GET_NAME(startTime), startTime);
37     GetValue(node, GET_NAME(finishTime), finishTime);
38     GetValue(node, GET_NAME(code), code);
39     GetValue(node, GET_NAME(syncStatus), syncStatus);
40     GetValue(node, GET_NAME(instanceId), instanceId);
41     return true;
42 }
43 
GetKey(const int32_t user,const std::string & bundleName,const std::string & storeId,int32_t instanceId)44 std::string CloudLastSyncInfo::GetKey(const int32_t user, const std::string &bundleName,
45                                       const std::string &storeId, int32_t instanceId)
46 {
47     return GetKey(INFO_PREFIX, { std::to_string(user), bundleName, std::to_string(instanceId), storeId });
48 }
49 
GetKey(const std::string & prefix,const std::initializer_list<std::string> & fields)50 std::string CloudLastSyncInfo::GetKey(const std::string &prefix, const std::initializer_list<std::string> &fields)
51 {
52     return Constant::Join(prefix, Constant::KEY_SEPARATOR, fields);
53 }
54 } // namespace OHOS::DistributedData