[829] | 1 | #include "stdafx.h"
|
---|
| 2 | #include <jenga/include/jenga.h>
|
---|
| 3 | #include <abdev/ab_common/include/ab_common.h>
|
---|
| 4 | #include <algorithm>
|
---|
| 5 |
|
---|
| 6 | using namespace ActiveBasic::Common::Lexical;
|
---|
| 7 |
|
---|
| 8 |
|
---|
| 9 | NamespaceScopes::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(std::move(tempName));
|
---|
| 21 |
|
---|
| 22 | if( i2 == std::string::npos ){
|
---|
| 23 | break;
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | i = i2 + 1;
|
---|
| 27 | }
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | NamespaceScopes ActiveBasic::Common::Lexical::operator +(const NamespaceScopes &lhs, const NamespaceScopes &rhs)
|
---|
| 31 | {
|
---|
| 32 | return NamespaceScopes(lhs) += rhs;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | bool NamespaceScopes::IsEqual( const NamespaceScopes &namespaceScopes ) const
|
---|
| 36 | {
|
---|
| 37 | if( this->size() != namespaceScopes.size() )
|
---|
| 38 | {
|
---|
| 39 | return false;
|
---|
| 40 | }
|
---|
| 41 | return std::equal(begin(), end(), namespaceScopes.begin() );
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | void NamespaceScopesCollection::SplitNamespace( const char *fullName, char *namespaceStr, char *simpleName ) const
|
---|
| 45 | {
|
---|
| 46 | NamespaceScopes namespaceScopes( fullName );
|
---|
| 47 | bool hasSimpleName = false;
|
---|
| 48 | while( namespaceScopes.size() > 0 ){
|
---|
| 49 | if( IsExist( namespaceScopes ) ){
|
---|
| 50 | break;
|
---|
| 51 | }
|
---|
| 52 | namespaceScopes.pop_back();
|
---|
| 53 |
|
---|
| 54 | hasSimpleName = true;
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | strcpy( namespaceStr, namespaceScopes.ToString().c_str() );
|
---|
| 58 |
|
---|
| 59 | bool hasNamespace = false;
|
---|
| 60 | if( namespaceStr[0] ){
|
---|
| 61 | hasNamespace = true;
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | int dotLength = 0;
|
---|
| 65 | if( hasSimpleName && hasNamespace ){
|
---|
| 66 | dotLength = 1;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | strcpy( simpleName, fullName + strlen( namespaceStr ) + dotLength );
|
---|
| 70 | }
|
---|
| 71 |
|
---|