source: dev/branches/egtra/ab5.0/abdev/ab_common/src/Lexical/Namespace.cpp@ 810

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

ムーブコンストラクタ・ムーブ代入演算子の導入

File size: 1.5 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(std::move(tempName));
19
20 if( i2 == std::string::npos ){
21 break;
22 }
23
24 i = i2 + 1;
25 }
26}
27
28NamespaceScopes ActiveBasic::Common::Lexical::operator +(const NamespaceScopes &lhs, const NamespaceScopes &rhs)
29{
30 return NamespaceScopes(lhs) += rhs;
31}
32
33bool NamespaceScopes::IsEqual( const NamespaceScopes &namespaceScopes ) const
34{
35 if( this->size() != namespaceScopes.size() )
36 {
37 return false;
38 }
39 return std::equal(begin(), end(), namespaceScopes.begin() );
40}
41
42void NamespaceScopesCollection::SplitNamespace( const char *fullName, char *namespaceStr, char *simpleName ) const
43{
44 NamespaceScopes namespaceScopes( fullName );
45 bool hasSimpleName = false;
46 while( namespaceScopes.size() > 0 ){
47 if( IsExist( namespaceScopes ) ){
48 break;
49 }
50 namespaceScopes.pop_back();
51
52 hasSimpleName = true;
53 }
54
55 strcpy( namespaceStr, namespaceScopes.ToString().c_str() );
56
57 bool hasNamespace = false;
58 if( namespaceStr[0] ){
59 hasNamespace = true;
60 }
61
62 int dotLength = 0;
63 if( hasSimpleName && hasNamespace ){
64 dotLength = 1;
65 }
66
67 strcpy( simpleName, fullName + strlen( namespaceStr ) + dotLength );
68}
69
Note: See TracBrowser for help on using the repository browser.