source: dev/trunk/abdev/BasicCompiler_Common/include/NamespaceSupporter.h@ 355

Last change on this file since 355 was 355, checked in by dai_9181, 17 years ago

静的領域に初期オブジェクトを配置可能にした

File size: 2.6 KB
Line 
1#pragma once
2
3#include <Namespace.h>
4
5class NamespaceSupporter
6{
7 // Importsされた名前空間
8 NamespaceScopesCollection importedNamespaces;
9
10 // 現在の名前空間
11 NamespaceScopes livingNamespaceScopes;
12
13public:
14 NamespaceScopesCollection &GetImportedNamespaces()
15 {
16 return importedNamespaces;
17 }
18 void SetImportedNamespaces( const NamespaceScopesCollection &namespaces )
19 {
20 this->importedNamespaces = namespaces;
21 }
22 bool ImportsNamespace( const std::string &namespaceStr );
23
24 NamespaceScopes &GetLivingNamespaceScopes()
25 {
26 return livingNamespaceScopes;
27 }
28 void SetLivingNamespaceScopes( const NamespaceScopes &namespaceScopes )
29 {
30 this->livingNamespaceScopes = namespaceScopes;
31 }
32 bool IsLiving( const NamespaceScopes &namespaceScopes ) const
33 {
34 return NamespaceScopes::IsBelong( namespaceScopes, livingNamespaceScopes );
35 }
36
37
38 // 包括しているかをチェック
39 // 例:
40 // this = "Discoversoft.ActiveBasic"
41 // living = "Discoversoft.ActiveBasic"
42 // entryName = "ActiveBasic"
43 // この場合、living は entryName を包括している。
44 bool IsCoverd( const NamespaceScopes &namespaceScopes, const string &entryName ) const
45 {
46 if( namespaceScopes.IsEqual( entryName ) ){
47 return true;
48 }
49
50 string thisStr = namespaceScopes.ToString();
51
52 NamespaceScopes tempLivingNamespaceScopes = livingNamespaceScopes;
53
54 while( tempLivingNamespaceScopes.size() ){
55 string tempStr = tempLivingNamespaceScopes.ToString() + "." + entryName;
56 if( thisStr == tempStr ){
57 return true;
58 }
59
60 tempLivingNamespaceScopes.pop_back();
61 }
62 return false;
63 }
64 bool IsCoverd( const NamespaceScopes &baseNamespaceScopes, const NamespaceScopes &entryNamespaceScopes ) const
65 {
66 return IsCoverd( baseNamespaceScopes, entryNamespaceScopes.ToString() );
67 }
68
69
70 // 指定された名前空間が同一エリアと見なされるかどうかをチェック
71 bool IsSameAreaNamespace( const NamespaceScopes &baseNamespaceScopes, const NamespaceScopes &entryNamespaceScopes ){
72 if( entryNamespaceScopes.size() ){
73 if( IsCoverd( baseNamespaceScopes, entryNamespaceScopes ) ){
74 // 包括しているときは同一と見なす
75 return true;
76 }
77 }
78 else{
79 if( baseNamespaceScopes.size() ){
80 // 名前空間の判断が必要なとき
81 if( this->importedNamespaces.IsImported( baseNamespaceScopes )
82 || IsLiving( baseNamespaceScopes ) ){
83 // Using指定があるとき
84 // または
85 // 指定された名前空間が現在の名前空間スコープと同一のとき
86 return true;
87 }
88 }
89 else{
90 return true;
91 }
92 }
93
94 return false;
95 }
96
97 static bool CollectNamespaces( const char *source, NamespaceScopesCollection &namespaceScopesCollection );
98};
Note: See TracBrowser for help on using the repository browser.