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 PASTE_BOARD_CONVERT_UTILS_H
17 #define PASTE_BOARD_CONVERT_UTILS_H
18 
19 #include "paste_data.h"
20 #include "unified_data.h"
21 namespace OHOS {
22 namespace MiscServices {
23 class API_EXPORT ConvertUtils {
24 public:
25     using UnifiedRecord = UDMF::UnifiedRecord;
26     using UnifiedData = UDMF::UnifiedData;
27     using UnifiedDataProperties = UDMF::UnifiedDataProperties;
28     using UDType = UDMF::UDType;
29     using ShareOptions = UDMF::ShareOptions;
30 
31     static std::shared_ptr<PasteData> Convert(const UnifiedData& unifiedData);
32     static std::shared_ptr<UnifiedData> Convert(const PasteData& pasteData);
33 
34     static std::vector<std::shared_ptr<PasteDataRecord>> Convert(
35         const std::vector<std::shared_ptr<UnifiedRecord>>& records);
36     static std::vector<std::shared_ptr<UnifiedRecord>> Convert(
37         const std::vector<std::shared_ptr<PasteDataRecord>>& records);
38 
39     static std::shared_ptr<PasteDataRecord> Convert(std::shared_ptr<UnifiedRecord> record);
40     static std::shared_ptr<UnifiedRecord> Convert(std::shared_ptr<PasteDataRecord> record);
41 
42     static PasteDataProperty ConvertProperty(const std::shared_ptr<UnifiedDataProperties>& properties,
43         const UnifiedData& unifiedData);
44     static std::shared_ptr<UnifiedDataProperties> ConvertProperty(const PasteDataProperty& properties);
45 
46     static std::vector<std::shared_ptr<PasteDataEntry>> Convert(
47         const std::shared_ptr<std::map<std::string, UDMF::ValueType>>& entries);
48     static std::shared_ptr<std::vector<std::pair<std::string, UDMF::ValueType>>> Convert(
49         const std::vector<std::shared_ptr<PasteDataEntry>>& entries, const std::shared_ptr<PasteDataRecord> &record);
50 
51     static UDMF::ValueType Convert(const std::shared_ptr<PasteDataEntry>& entry,
52         const std::shared_ptr<PasteDataRecord> &record);
53 
54     static std::vector<std::string> Convert(const std::vector<std::string>& utdIds);
55 
56 private:
57     static constexpr const char *CHANNEL_NAME = "pasteboard";
58     static ShareOption UdmfOptions2PbOption(ShareOptions udmfOptions);
59     static ShareOptions PbOption2UdmfOptions(ShareOption pbOption);
60 };
61 } // namespace MiscServices
62 } // namespace OHOS
63 #endif // PASTE_BOARD_CONVERT_UTILS_H