• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef OHOS_HDI_ASTMAPTYPE_H
10 #define OHOS_HDI_ASTMAPTYPE_H
11 
12 #include "ast/ast_type.h"
13 #include "util/autoptr.h"
14 
15 namespace OHOS {
16 namespace HDI {
17 class ASTMapType : public ASTType {
18 public:
SetKeyType(const AutoPtr<ASTType> & keyType)19     inline void SetKeyType(const AutoPtr<ASTType>& keyType)
20     {
21         keyType_ = keyType;
22     }
23 
GetKeyType()24     inline AutoPtr<ASTType> GetKeyType()
25     {
26         return keyType_;
27     }
28 
SetValueType(const AutoPtr<ASTType> & valueType)29     inline void SetValueType(const AutoPtr<ASTType>& valueType)
30     {
31         valueType_ = valueType;
32     }
33 
GetValueType()34     inline AutoPtr<ASTType> GetValueType()
35     {
36         return valueType_;
37     }
38 
39     bool IsMapType() override;
40 
41     String ToString() override;
42 
43     TypeKind GetTypeKind() override;
44 
45     String EmitCType(TypeMode mode = TypeMode::NO_MODE) const override;
46 
47     String EmitCppType(TypeMode mode = TypeMode::NO_MODE) const override;
48 
49     String EmitJavaType(TypeMode mode, bool isInnerType = false) const override;
50 
51     void EmitCppWriteVar(const String& parcelName, const String& name, StringBuilder& sb,
52         const String& prefix, unsigned int innerLevel = 0) const override;
53 
54     void EmitCppReadVar(const String& parcelName, const String& name, StringBuilder& sb,
55         const String& prefix, bool initVariable, unsigned int innerLevel = 0) const override;
56 
57     void EmitCppMarshalling(const String& parcelName, const String& name, StringBuilder& sb,
58         const String& prefix, unsigned int innerLevel = 0) const override;
59 
60     void EmitCppUnMarshalling(const String& parcelName, const String& name, StringBuilder& sb,
61         const String& prefix, bool emitType, unsigned int innerLevel = 0) const override;
62 
63     void EmitJavaWriteVar(const String& parcelName, const String& name, StringBuilder& sb,
64         const String& prefix) const override;
65 
66     void EmitJavaReadVar(const String& parcelName, const String& name, StringBuilder& sb,
67         const String& prefix) const override;
68 
69     void EmitJavaReadInnerVar(const String& parcelName, const String& name, bool isInner, StringBuilder& sb,
70         const String& prefix) const override;
71 private:
72     AutoPtr<ASTType> keyType_;
73     AutoPtr<ASTType> valueType_;
74 };
75 } // namespace HDI
76 } // namespace OHOS
77 
78 #endif // OHOS_HDI_ASTMAPTYPE_H