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 OHOS_IDL_ASTPARAMETER_H
17 #define OHOS_IDL_ASTPARAMETER_H
18 
19 #include "ast/ast_attribute.h"
20 #include "ast/ast_node.h"
21 #include "ast/ast_type.h"
22 #include "util/autoptr.h"
23 
24 namespace OHOS {
25 namespace Idl {
26 class ASTParameter : public ASTNode {
27 public:
ASTParameter(const std::string & name,ASTParamAttr::ParamAttr attribute,const AutoPtr<ASTType> & type)28     ASTParameter(const std::string &name, ASTParamAttr::ParamAttr attribute, const AutoPtr<ASTType> &type)
29         : ASTNode(), name_(name), attr_(new ASTParamAttr(attribute)), type_(type)
30     {
31     }
32 
ASTParameter(const std::string & name,const AutoPtr<ASTParamAttr> & attribute,const AutoPtr<ASTType> & type)33     ASTParameter(const std::string &name, const AutoPtr<ASTParamAttr> &attribute, const AutoPtr<ASTType> &type)
34         : ASTNode(), name_(name), attr_(attribute), type_(type)
35     {
36     }
37 
GetName()38     inline std::string GetName()
39     {
40         return name_;
41     }
42 
GetType()43     inline AutoPtr<ASTType> GetType()
44     {
45         return type_;
46     }
47 
GetAttribute()48     inline ASTParamAttr::ParamAttr GetAttribute()
49     {
50         return attr_->value_;
51     }
52 
53     std::string Dump(const std::string &prefix) override;
54 
55 private:
56     std::string name_;
57     AutoPtr<ASTParamAttr> attr_;
58     AutoPtr<ASTType> type_;
59 };
60 } // namespace Idl
61 } // namespace OHOS
62 
63 #endif // OHOS_IDL_ASTPARAMETER_H