• 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 "unified_record.h"
20 #include "cj_common_ffi.h"
21 
22 namespace OHOS {
23 namespace UDMF {
24     using namespace OHOS::UDMF;
25 
26     struct CJValueType {
27         int32_t integer32;
28         int64_t integer64;
29         double dou;
30         bool boolean;
31         char *string;
32         CArrUI8 byteArray;
33         int64_t pixelMapId;
34 
35         uint8_t tag;
36     };
37 
38     enum TypeSymbol {
39         INTEGER32 = 0,
40         INTEGER64 = 1,
41         DOUBLE = 2,
42         BOOLEAN = 3,
43         STRING = 4,
44         BYTEARRAY = 5,
45         PIXELMAP = 6,
46         NULLTAG = 7,
47         UNDEFINED = 8
48     };
49 
50     class CUnifiedRecord : public OHOS::FFI::FFIData {
51         DECL_TYPE(CUnifiedRecord, OHOS::FFI::FFIData)
52         public:
53             CUnifiedRecord();
54             CUnifiedRecord(const char *type, CJValueType value);
55             CJValueType ValueType2CJValueType(ValueType value);
56             ValueType CJValueType2ValueType(CJValueType value);
57             char *GetType();
58             CJValueType GetValue();
59 
60             const std::shared_ptr<UDMF::UnifiedRecord> &GetUnifiedRecord() const;
61 
62         private:
63             std::shared_ptr<UDMF::UnifiedRecord> unifiedRecord_;
64             int64_t pixelMapId_;
65     };
66 
67 }
68 } // namespace OHOS::UDMF
69 
70 #endif