source: dev/trunk/ab5.0/abdev/ab_common/src/Lexical/Namespace.cpp@ 720

Last change on this file since 720 was 700, checked in by イグトランス (egtra), 16 years ago

CRequireFilesの管理をhash_setベースへ。保存時にFileIndexの記録を行っていなかった問題を修正。rev.669でコミットし忘れのcompiler_x86/NumOpe.cppを追加。

File size: 1.7 KB
Line 
1#include "stdafx.h"
2
3
4using namespace ActiveBasic::Common::Lexical;
5
6
7NamespaceScopes::NamespaceScopes( const std::string &namespaceStr ){
8 if( namespaceStr.size() == 0 ){
9 return;
10 }
11
12 std::string::size_type i = 0;
13 while( true ){
14 std::string::size_type i2 = namespaceStr.find( '.', i );
15
16 std::string tempName = namespaceStr.substr( i, i2-i );
17
18 push_back( tempName );
19
20 if( i2 == std::string::npos ){
21 break;
22 }
23
24 i = i2 + 1;
25 }
26}
27
28NamespaceScopes NamespaceScopes::operator+ ( const NamespaceScopes &namespaceScopes ) const
29{
30 NamespaceScopes result = *this;
31 BOOST_FOREACH( const std::string &name, namespaceScopes )
32 {
33 result.push_back( name );
34 }
35 return result;
36}
37
38bool NamespaceScopes::IsEqual( const NamespaceScopes &namespaceScopes ) const
39{
40 if( this->size() != namespaceScopes.size() )
41 {
42 return false;
43 }
44
45 for( int i=static_cast<int>(this->size()-1); i>=0; i-- )
46 {
47 if( (*this)[i] != namespaceScopes[i] )
48 {
49 return false;
50 }
51 }
52
53 return true;
54}
55
56void NamespaceScopesCollection::SplitNamespace( const char *fullName, char *namespaceStr, char *simpleName ) const
57{
58 NamespaceScopes namespaceScopes( fullName );
59 bool hasSimpleName = false;
60 while( namespaceScopes.size() > 0 ){
61 if( IsExist( namespaceScopes ) ){
62 break;
63 }
64 namespaceScopes.pop_back();
65
66 hasSimpleName = true;
67 }
68
69 strcpy( namespaceStr, namespaceScopes.ToString().c_str() );
70
71 bool hasNamespace = false;
72 if( namespaceStr[0] ){
73 hasNamespace = true;
74 }
75
76 int dotLength = 0;
77 if( hasSimpleName && hasNamespace ){
78 dotLength = 1;
79 }
80
81 strcpy( simpleName, fullName + strlen( namespaceStr ) + dotLength );
82}
83
Note: See TracBrowser for help on using the repository browser.