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

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

ab_commonプロジェクト内にLexicalディレクトリを作成。

File size: 1.1 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
28void NamespaceScopesCollection::SplitNamespace( const char *fullName, char *namespaceStr, char *simpleName ) const
29{
30 NamespaceScopes namespaceScopes( fullName );
31 bool hasSimpleName = false;
32 while( namespaceScopes.size() > 0 ){
33 if( IsExist( namespaceScopes ) ){
34 break;
35 }
36 namespaceScopes.pop_back();
37
38 hasSimpleName = true;
39 }
40
41 lstrcpy( namespaceStr, namespaceScopes.ToString().c_str() );
42
43 bool hasNamespace = false;
44 if( namespaceStr[0] ){
45 hasNamespace = true;
46 }
47
48 int dotLength = 0;
49 if( hasSimpleName && hasNamespace ){
50 dotLength = 1;
51 }
52
53 lstrcpy( simpleName, fullName + lstrlen( namespaceStr ) + dotLength );
54}
55
Note: See TracBrowser for help on using the repository browser.