• 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_ASTNAMESPACE_H
10 #define OHOS_HDI_ASTNAMESPACE_H
11 
12 #include <vector>
13 
14 #include "ast/ast_node.h"
15 #include "util/autoptr.h"
16 
17 namespace OHOS {
18 namespace HDI {
19 class ASTInterfaceType;
20 class ASTSequenceableType;
21 
22 class ASTNamespace : public ASTNode {
23 public:
24     explicit ASTNamespace(const std::string &nspaceStr);
25 
26     ~ASTNamespace() override = default;
27 
GetName()28     inline std::string GetName()
29     {
30         return name_;
31     }
32 
33     void AddNamespace(const AutoPtr<ASTNamespace> &innerNspace);
34 
35     AutoPtr<ASTNamespace> FindNamespace(const std::string &nspaceStr);
36 
37     AutoPtr<ASTNamespace> GetNamespace(size_t index);
38 
GetNamespaceNumber()39     inline size_t GetNamespaceNumber()
40     {
41         return innerNamespaces_.size();
42     }
43 
44     void AddInterface(const AutoPtr<ASTInterfaceType> &interface);
45 
46     AutoPtr<ASTInterfaceType> GetInterface(size_t index);
47 
GetInterfaceNumber()48     inline size_t GetInterfaceNumber()
49     {
50         return interfaces_.size();
51     }
52 
53     void AddSequenceable(const AutoPtr<ASTSequenceableType> &sequenceable);
54 
55     AutoPtr<ASTSequenceableType> GetSequenceable(size_t index);
56 
GetSequenceableNumber()57     inline size_t GetSequenceableNumber()
58     {
59         return sequenceables_.size();
60     }
61 
ToShortString()62     inline std::string ToShortString()
63     {
64         return name_;
65     }
66 
67     std::string ToString() const override;
68 
69 private:
70     std::string name_;
71     ASTNamespace *outerNamespace_;
72     std::vector<AutoPtr<ASTNamespace>> innerNamespaces_;
73     std::vector<AutoPtr<ASTSequenceableType>> sequenceables_;
74     std::vector<AutoPtr<ASTInterfaceType>> interfaces_;
75 };
76 } // namespace HDI
77 } // namespace OHOS
78 
79 #endif // OHOS_HDI_ASTNAMESPACE_H