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
16 #include "cloud/cloud_mark.h"
17
18 namespace OHOS::DistributedData {
19
20 static constexpr const char *KEY_PREFIX = "CloudMark";
21 static constexpr const char *KEY_SEPARATOR = "###";
Marshal(Serializable::json & node) const22 bool CloudMark::Marshal(Serializable::json &node) const
23 {
24 SetValue(node[GET_NAME(isClearWaterMark)], isClearWaterMark);
25 return true;
26 }
27
Unmarshal(const Serializable::json & node)28 bool CloudMark::Unmarshal(const Serializable::json &node)
29 {
30 GetValue(node, GET_NAME(isClearWaterMark), isClearWaterMark);
31 return true;
32 }
33
GetKey()34 std::string CloudMark::GetKey()
35 {
36 return GetKey({ deviceId, std::to_string(userId), "default", bundleName, storeId, std::to_string(index) });
37 }
38
GetKey(const std::initializer_list<std::string> & fields)39 std::string CloudMark::GetKey(const std::initializer_list<std::string> &fields)
40 {
41 std::string prefix = KEY_PREFIX;
42 for (const auto &field : fields) {
43 prefix.append(KEY_SEPARATOR).append(field);
44 }
45 return prefix;
46 }
47 } // namespace OHOS::DistributedData