source: dev/trunk/abdev/BasicCompiler_Common/src/Namespace.cpp@ 324

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