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