• 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 
16 #ifndef UDMF_UNIFIED_RECORD_IMPL_H
17 #define UDMF_UNIFIED_RECORD_IMPL_H
18 
19 #include "cj_common_ffi.h"
20 #include "ffi_remote_data.h"
21 #include "unified_record.h"
22 
23 namespace OHOS {
24 namespace UDMF {
25 struct CRecord {
26     CArrString keys;
27     CArrString values;
28 };
29 
30 struct CJValueType {
31     int32_t integer32;
32     int64_t integer64;
33     double dou;
34     bool boolean;
35     char *string;
36     CArrUI8 byteArray;
37     int64_t pixelMapId;
38     uint8_t tag;
39 };
40 
41 enum TypeSymbol {
42     INTEGER32 = 0,
43     INTEGER64 = 1,
44     DOUBLE = 2,
45     BOOLEAN = 3,
46     STRING = 4,
47     BYTEARRAY = 5,
48     PIXELMAP = 6,
49     NULLTAG = 7,
50     UNDEFINED = 8
51 };
52 
53 class CUnifiedRecord : public OHOS::FFI::FFIData {
54     DECL_TYPE(CUnifiedRecord, OHOS::FFI::FFIData)
55 public:
56     CUnifiedRecord();
57     CUnifiedRecord(const char *type);
58     CUnifiedRecord(const char *type, CJValueType value);
59     CJValueType ValueType2CJValueType(ValueType value);
60     ValueType CJValueType2ValueType(CJValueType value);
61     char *GetType();
62     CJValueType GetValue();
63 
64     const std::shared_ptr<UDMF::UnifiedRecord> &GetUnifiedRecord() const;
65 
66     char *GetFileUri();
67     void SetFileUri(const char *uri);
68     CRecord GetFileDetails();
69     void SetFileDetails(const std::map<std::string, std::string> &details);
70 
71     char *GetImageUri();
72     void SetImageUri(const char *uri);
73 
74     char *GetVideoUri();
75     void SetVideoUri(const char *uri);
76 
77     CRecord GetTextDetails();
78     void SetTextDetails(const std::map<std::string, std::string> &details);
79 
80     char *GetHyperLinkUrl();
81     void SetHyperLinkUrl(const char *url);
82 
83     char *GetHyperLinkDescription();
84     void SetHyperLinkDescription(const char *description);
85 
86     char *GetPlainTextContent();
87     void SetPlainTextContent(const char *text);
88 
89     char *GetPlainTextAbstract();
90     void SetPlainTextAbstract(const char *abstr);
91 private:
92     std::shared_ptr<UDMF::UnifiedRecord> unifiedRecord_;
93     int64_t pixelMapId_ = 0;
94 };
95 
96 char *CreateCStringFromString(const std::string &source);
97 } // namespace UDMF
98 } // namespace OHOS
99 
100 #endif