Line | |
---|
1 | #pragma once
|
---|
2 |
|
---|
3 | #include <vector>
|
---|
4 | #include <string>
|
---|
5 | #include <boost/foreach.hpp>
|
---|
6 |
|
---|
7 | using namespace std;
|
---|
8 |
|
---|
9 | class NamespaceScopes : public vector<string>
|
---|
10 | {
|
---|
11 | public:
|
---|
12 | NamespaceScopes(){}
|
---|
13 | NamespaceScopes( const char *name );
|
---|
14 | ~NamespaceScopes(){}
|
---|
15 |
|
---|
16 | string ToString() const
|
---|
17 | {
|
---|
18 | string namespaceStr;
|
---|
19 | const vector<string> &me = *this;
|
---|
20 |
|
---|
21 | bool isFirst = true;
|
---|
22 | BOOST_FOREACH( const string &itemStr, me ){
|
---|
23 | if( isFirst ){
|
---|
24 | isFirst = false;
|
---|
25 | }
|
---|
26 | else{
|
---|
27 | namespaceStr += ".";
|
---|
28 | }
|
---|
29 |
|
---|
30 | namespaceStr += itemStr;
|
---|
31 | }
|
---|
32 | return namespaceStr;
|
---|
33 | }
|
---|
34 |
|
---|
35 | // 等しいかをチェック
|
---|
36 | bool IsEqual( const string &name ) const
|
---|
37 | {
|
---|
38 | if( ToString() == name ){
|
---|
39 | return true;
|
---|
40 | }
|
---|
41 | return false;
|
---|
42 | }
|
---|
43 |
|
---|
44 | // 等しいかをチェック
|
---|
45 | bool IsEqual( const NamespaceScopes &namespaceScopes ) const
|
---|
46 | {
|
---|
47 | if( ToString() == namespaceScopes.ToString() ){
|
---|
48 | return true;
|
---|
49 | }
|
---|
50 | return false;
|
---|
51 | }
|
---|
52 |
|
---|
53 | // 所属しているかをチェック
|
---|
54 | // 例:
|
---|
55 | // baseNamespaceScopes = "Discoversoft"
|
---|
56 | // entryNamespaceScopes = "Discoversoft.ActiveBasic"
|
---|
57 | // この場合、entryNamespaceScopes は baseNamespaceScopes に所属している。
|
---|
58 | static bool IsBelong( const NamespaceScopes &baseNamespaceScopes, const NamespaceScopes &entryNamespaceScopes )
|
---|
59 | {
|
---|
60 | if( baseNamespaceScopes.size() > entryNamespaceScopes.size() ){
|
---|
61 | return false;
|
---|
62 | }
|
---|
63 |
|
---|
64 | for( int i=0; i<(int)baseNamespaceScopes.size(); i++ ){
|
---|
65 | if( baseNamespaceScopes[i] != entryNamespaceScopes[i] ){
|
---|
66 | return false;
|
---|
67 | }
|
---|
68 | }
|
---|
69 | return true;
|
---|
70 | }
|
---|
71 |
|
---|
72 | bool IsUsing() const
|
---|
73 | {
|
---|
74 | // TODO: 実装
|
---|
75 | return false;
|
---|
76 | }
|
---|
77 |
|
---|
78 | bool IsLiving() const;
|
---|
79 |
|
---|
80 | // 包括しているかをチェック
|
---|
81 | // 例:
|
---|
82 | // this = "Discoversoft.ActiveBasic"
|
---|
83 | // living = "Discoversoft.ActiveBasic"
|
---|
84 | // name = "ActiveBasic"
|
---|
85 | // この場合、living は name を包括している。
|
---|
86 | bool IsCoverd( const string &name ) const;
|
---|
87 | bool IsCoverd( const NamespaceScopes &namespaceScopes ) const;
|
---|
88 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.