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 #ifndef ARY_QUALINAME_HXX 29 #define ARY_QUALINAME_HXX 30 31 32 33 // USED SERVICES 34 // BASE CLASSES 35 // COMPONENTS 36 // PARAMETERS 37 #include <cosv/tpl/tpltools.hxx> 38 39 40 namespace ary 41 { 42 43 class QualifiedName 44 { 45 public: 46 typedef StringVector::const_iterator namespace_iterator; 47 48 QualifiedName( 49 uintt i_nSize = 0); 50 51 /// @see AssignText() 52 QualifiedName( 53 const char * i_sText, 54 const char * i_sSeparator ); 55 ~QualifiedName(); 56 57 QualifiedName & operator+=( 58 const String & i_sNamespaceName ) 59 { if (i_sNamespaceName.length() > 0) 60 aNamespace.push_back(i_sNamespaceName); 61 return *this; } 62 /// @precond i_nIndex < NamespaceDepth(). 63 String & operator[]( 64 uintt i_nIndex ) 65 { csv_assert(i_nIndex < aNamespace.size()); 66 return aNamespace[i_nIndex]; } 67 void Init( 68 bool i_bAbsolute ) 69 { Empty(); bIsAbsolute = i_bAbsolute; } 70 /** Reads a qualified name from a string. 71 If the last two charcters are "()", the inquiry IsFunction() will return 72 true. 73 */ 74 void AssignText( 75 const char * i_sText, 76 const char * i_sSeparator ); 77 void SetLocalName( 78 const String & i_sLocalName ) 79 { sLocalName = i_sLocalName; } 80 void Empty() { csv::erase_container(aNamespace); sLocalName.clear(); bIsAbsolute = false; } 81 82 const String & LocalName() const { return sLocalName; } 83 namespace_iterator first_namespace() const { return aNamespace.begin(); } 84 namespace_iterator end_namespace() const { return aNamespace.end(); } 85 uintt NamespaceDepth() const { return aNamespace.size(); } 86 87 bool IsAbsolute() const { return bIsAbsolute; } 88 bool IsQualified() const { return aNamespace.size() > 0; } 89 bool IsFunction() const { return bIsFunction; } 90 91 private: 92 // DATA 93 StringVector aNamespace; 94 String sLocalName; 95 bool bIsAbsolute; /// true := beginning with "::". 96 bool bIsFunction; /// true := ending with "()" 97 }; 98 99 100 101 102 } // namespace ary 103 #endif 104