• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef DATA_HANDLER_H
16 #define DATA_HANDLER_H
17 
18 #include "error_code.h"
19 #include "unified_data.h"
20 #include "types_export.h"
21 
22 namespace OHOS::UDMF {
23 using namespace DistributedDB;
24 
25 class DataHandler {
26 public:
27     static Status MarshalToEntries(const UnifiedData &unifiedData, std::vector<Entry> &entries);
28     static Status UnmarshalEntries(const std::string &key, const std::vector<Entry> &entries,
29         UnifiedData &unifiedData);
30 
31 private:
32     static Status BuildEntries(const std::vector<std::shared_ptr<UnifiedRecord>> &records,
33         const std::string &unifiedKey, std::vector<Entry> &entries);
34     static Status UnmarshalEntryItem(UnifiedData &unifiedData, const std::vector<Entry> &entries,
35         const std::string &key, std::map<std::string, std::shared_ptr<UnifiedRecord>> &records,
36         std::map<std::string, std::map<std::string, ValueType>> &innerEntries);
37 };
38 } // namespace UDMF::OHOS
39 #endif // DATA_HANDLER_H