source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/src/Namespace.cpp @ 461

Last change on this file since 461 was 461, checked in by dai_9181, 16 years ago

smoothieプロジェクトが不要になったため、破棄。

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