1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include <precomp.h> 29 #include <ary/qualiname.hxx> 30 31 32 // NOT FULLY DECLARED SERVICES 33 34 35 namespace ary 36 { 37 38 39 QualifiedName::QualifiedName( uintt i_nSize ) 40 : aNamespace(), 41 sLocalName(), 42 bIsAbsolute(false), 43 bIsFunction() 44 { 45 if (i_nSize > 0) 46 aNamespace.reserve(i_nSize); 47 } 48 49 QualifiedName::QualifiedName( const char * i_sText, 50 const char * i_sSeparator ) 51 : aNamespace(), 52 sLocalName(), 53 bIsAbsolute(false), 54 bIsFunction() 55 { 56 AssignText(i_sText,i_sSeparator); 57 } 58 59 QualifiedName::~QualifiedName() 60 { 61 } 62 63 void 64 QualifiedName::AssignText( const char * i_sText, 65 const char * i_sSeparator ) 66 { 67 csv_assert(NOT csv::no_str(i_sText) AND NOT csv::no_str(i_sSeparator)); 68 bIsAbsolute = false; 69 bIsFunction = false; 70 csv::erase_container( aNamespace ); 71 72 uintt nSepLen = strlen(i_sSeparator); 73 const char * sNext = i_sText; 74 75 const char * ps = strstr( i_sText, i_sSeparator ); 76 if (ps == i_sText) 77 { 78 bIsAbsolute = true; 79 sNext = ps + nSepLen; 80 } 81 82 for ( ps = strstr(sNext, i_sSeparator); 83 ps != 0; 84 ps = strstr(sNext, i_sSeparator) ) 85 { 86 String sPart(sNext, ps - sNext); 87 aNamespace.push_back(sPart); 88 sNext = ps + nSepLen; 89 } 90 91 uintt sNameLen = strlen(sNext); 92 if ( sNameLen > 2 ) 93 { 94 ps = sNext + sNameLen - 2; 95 if (*ps == '(' AND *(ps+1) == ')') 96 { 97 sNameLen -= 2; 98 bIsFunction = true; 99 } 100 } 101 sLocalName = String(sNext,sNameLen); 102 } 103 104 105 } // namespace ary 106