1 /*
2 * Copyright (c) 2022 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 "metadata/capability_meta_data.h"
17
18 #include "utils/constant.h"
19 namespace OHOS::DistributedData {
20 constexpr int32_t CapMetaData::CURRENT_VERSION;
21 constexpr int32_t CapMetaData::INVALID_VERSION;
22 constexpr const char *CapMetaRow::KEY_PREFIX;
Marshal(json & node) const23 bool CapMetaData::Marshal(json &node) const
24 {
25 bool ret = true;
26 ret = SetValue(node[GET_NAME(version)], version) && ret;
27 return ret;
28 }
29
Unmarshal(const json & node)30 bool CapMetaData::Unmarshal(const json &node)
31 {
32 bool ret = true;
33 ret = GetValue(node, GET_NAME(version), version) && ret;
34 return ret;
35 }
36
GetKeyFor(const std::string & key)37 std::vector<uint8_t> CapMetaRow::GetKeyFor(const std::string &key)
38 {
39 std::string str = Constant::Concatenate({ KEY_PREFIX, Constant::KEY_SEPARATOR, key });
40 return { str.begin(), str.end() };
41 }
42 } // namespace OHOS::DistributedData
43