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

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

Symbol周りを高速化

File size: 1.6 KB
Line 
1#include "stdafx.h"
2#include <algorithm>
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;
31 result.reserve( this->size() + namespaceScopes.size() );
32 result = *this;
33 result.append( namespaceScopes );
34 return result;
35}
36
37bool NamespaceScopes::IsEqual( const NamespaceScopes &namespaceScopes ) const
38{
39 if( this->size() != namespaceScopes.size() )
40 {
41 return false;
42 }
43 return std::equal(begin(), end(), namespaceScopes.begin() );
44}
45
46void NamespaceScopesCollection::SplitNamespace( const char *fullName, char *namespaceStr, char *simpleName ) const
47{
48 NamespaceScopes namespaceScopes( fullName );
49 bool hasSimpleName = false;
50 while( namespaceScopes.size() > 0 ){
51 if( IsExist( namespaceScopes ) ){
52 break;
53 }
54 namespaceScopes.pop_back();
55
56 hasSimpleName = true;
57 }
58
59 strcpy( namespaceStr, namespaceScopes.ToString().c_str() );
60
61 bool hasNamespace = false;
62 if( namespaceStr[0] ){
63 hasNamespace = true;
64 }
65
66 int dotLength = 0;
67 if( hasSimpleName && hasNamespace ){
68 dotLength = 1;
69 }
70
71 strcpy( simpleName, fullName + strlen( namespaceStr ) + dotLength );
72}
73
Note: See TracBrowser for help on using the repository browser.