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

Last change on this file since 514 was 505, checked in by dai_9181, 17 years ago

NamespaceScopes、NamespaceScopesCollectionクラスをab_commonプロジェクトに移動した。

File size: 1.1 KB
Line 
1#include "stdafx.h"
2
3#include <Namespace.h>
4
5
6using namespace ActiveBasic::Common::Lexical;
7
8
9NamespaceScopes::NamespaceScopes( const std::string &namespaceStr ){
10 if( namespaceStr.size() == 0 ){
11 return;
12 }
13
14 std::string::size_type i = 0;
15 while( true ){
16 std::string::size_type i2 = namespaceStr.find( '.', i );
17
18 std::string tempName = namespaceStr.substr( i, i2-i );
19
20 push_back( tempName );
21
22 if( i2 == std::string::npos ){
23 break;
24 }
25
26 i = i2 + 1;
27 }
28}
29
30void NamespaceScopesCollection::SplitNamespace( const char *fullName, char *namespaceStr, char *simpleName ) const
31{
32 NamespaceScopes namespaceScopes( fullName );
33 bool hasSimpleName = false;
34 while( namespaceScopes.size() > 0 ){
35 if( IsExist( namespaceScopes ) ){
36 break;
37 }
38 namespaceScopes.pop_back();
39
40 hasSimpleName = true;
41 }
42
43 lstrcpy( namespaceStr, namespaceScopes.ToString().c_str() );
44
45 bool hasNamespace = false;
46 if( namespaceStr[0] ){
47 hasNamespace = true;
48 }
49
50 int dotLength = 0;
51 if( hasSimpleName && hasNamespace ){
52 dotLength = 1;
53 }
54
55 lstrcpy( simpleName, fullName + lstrlen( namespaceStr ) + dotLength );
56}
57
Note: See TracBrowser for help on using the repository browser.