Changeset 737 in dev for trunk/ab5.0
- Timestamp:
- Aug 27, 2008, 2:34:41 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/ab_common/include/Lexical/Namespace.h
r669 r737 1 1 #pragma once 2 2 #include <algorithm> 3 3 4 4 namespace ActiveBasic{ namespace Common{ namespace Lexical{ … … 19 19 NamespaceScopes(){} 20 20 NamespaceScopes( const std::string &namespaceStr ); 21 NamespaceScopes( NamespaceScopes::const_iterator first, NamespaceScopes::const_iterator last ) 22 : std::vector<std::string>( first, last ) 23 { 24 } 21 25 ~NamespaceScopes(){} 22 26 23 27 NamespaceScopes operator+ ( const NamespaceScopes &namespaceScopes ) const; 28 29 void append( const NamespaceScopes &namespaceScopes ) 30 { 31 insert( end(), namespaceScopes.begin(), namespaceScopes.end() ); 32 } 24 33 25 34 std::string ToString() const … … 34 43 } 35 44 else{ 36 namespaceStr += ".";45 namespaceStr += '.'; 37 46 } 38 47 … … 64 73 return false; 65 74 } 66 67 for( int i=0; i<(int)baseNamespaceScopes.size(); i++ ){ 68 if( baseNamespaceScopes[i] != entryNamespaceScopes[i] ){ 69 return false; 70 } 71 } 72 return true; 75 return std::equal( baseNamespaceScopes.begin(), baseNamespaceScopes.end(), entryNamespaceScopes.begin() ); 73 76 } 74 77 }; 78 79 inline bool operator ==( const NamespaceScopes &lhs, const NamespaceScopes &rhs ) 80 { 81 return lhs.IsEqual( rhs ); 82 } 75 83 76 84 class NamespaceScopesCollection : public std::vector<NamespaceScopes> … … 87 95 bool IsExist( const NamespaceScopes &namespaceScopes ) const 88 96 { 89 const NamespaceScopesCollection &namespaceScopesCollection = *this; 90 BOOST_FOREACH( const NamespaceScopes &tempNamespaceScopes, namespaceScopesCollection ){ 91 if( tempNamespaceScopes.IsEqual( namespaceScopes ) ){ 92 return true; 93 } 94 } 95 return false; 97 return std::find( this->begin(), this->end(), namespaceScopes ) != this->end(); 96 98 } 97 99 bool IsExist( const std::string &namespaceStr ) const … … 102 104 bool IsImported( const NamespaceScopes &namespaceScopes ) const 103 105 { 104 const NamespaceScopesCollection &namespaceScopesCollection = *this; 105 BOOST_FOREACH( const NamespaceScopes &tempNamespaceScopes, namespaceScopesCollection ) 106 { 107 if( namespaceScopes.IsEqual( tempNamespaceScopes ) ) 108 { 109 return true; 110 } 111 } 112 return false; 106 return IsExist( namespaceScopes ); 113 107 } 114 108
Note:
See TracChangeset
for help on using the changeset viewer.