1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 #include <precomp.h> 23 #include <ary/qualiname.hxx> 24 25 26 // NOT FULLY DECLARED SERVICES 27 28 29 namespace ary 30 { 31 32 33 QualifiedName::QualifiedName( uintt i_nSize ) 34 : aNamespace(), 35 sLocalName(), 36 bIsAbsolute(false), 37 bIsFunction() 38 { 39 if (i_nSize > 0) 40 aNamespace.reserve(i_nSize); 41 } 42 43 QualifiedName::QualifiedName( const char * i_sText, 44 const char * i_sSeparator ) 45 : aNamespace(), 46 sLocalName(), 47 bIsAbsolute(false), 48 bIsFunction() 49 { 50 AssignText(i_sText,i_sSeparator); 51 } 52 53 QualifiedName::~QualifiedName() 54 { 55 } 56 57 void 58 QualifiedName::AssignText( const char * i_sText, 59 const char * i_sSeparator ) 60 { 61 csv_assert(NOT csv::no_str(i_sText) AND NOT csv::no_str(i_sSeparator)); 62 bIsAbsolute = false; 63 bIsFunction = false; 64 csv::erase_container( aNamespace ); 65 66 uintt nSepLen = strlen(i_sSeparator); 67 const char * sNext = i_sText; 68 69 const char * ps = strstr( i_sText, i_sSeparator ); 70 if (ps == i_sText) 71 { 72 bIsAbsolute = true; 73 sNext = ps + nSepLen; 74 } 75 76 for ( ps = strstr(sNext, i_sSeparator); 77 ps != 0; 78 ps = strstr(sNext, i_sSeparator) ) 79 { 80 String sPart(sNext, ps - sNext); 81 aNamespace.push_back(sPart); 82 sNext = ps + nSepLen; 83 } 84 85 uintt sNameLen = strlen(sNext); 86 if ( sNameLen > 2 ) 87 { 88 ps = sNext + sNameLen - 2; 89 if (*ps == '(' AND *(ps+1) == ')') 90 { 91 sNameLen -= 2; 92 bIsFunction = true; 93 } 94 } 95 sLocalName = String(sNext,sNameLen); 96 } 97 98 99 } // namespace ary 100