xref: /aoo42x/main/autodoc/inc/ary/qualiname.hxx (revision 1c78a5d6)
1*1c78a5d6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1c78a5d6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1c78a5d6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1c78a5d6SAndrew Rist  * distributed with this work for additional information
6*1c78a5d6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1c78a5d6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1c78a5d6SAndrew Rist  * "License"); you may not use this file except in compliance
9*1c78a5d6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1c78a5d6SAndrew Rist  *
11*1c78a5d6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1c78a5d6SAndrew Rist  *
13*1c78a5d6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1c78a5d6SAndrew Rist  * software distributed under the License is distributed on an
15*1c78a5d6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1c78a5d6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1c78a5d6SAndrew Rist  * specific language governing permissions and limitations
18*1c78a5d6SAndrew Rist  * under the License.
19*1c78a5d6SAndrew Rist  *
20*1c78a5d6SAndrew Rist  *************************************************************/
21*1c78a5d6SAndrew Rist 
22*1c78a5d6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef ARY_QUALINAME_HXX
25cdf0e10cSrcweir #define ARY_QUALINAME_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir // USED SERVICES
30cdf0e10cSrcweir     // BASE CLASSES
31cdf0e10cSrcweir     // COMPONENTS
32cdf0e10cSrcweir     // PARAMETERS
33cdf0e10cSrcweir #include <cosv/tpl/tpltools.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace ary
37cdf0e10cSrcweir {
38cdf0e10cSrcweir 
39cdf0e10cSrcweir class QualifiedName
40cdf0e10cSrcweir {
41cdf0e10cSrcweir   public:
42cdf0e10cSrcweir     typedef StringVector::const_iterator  namespace_iterator;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir                         QualifiedName(
45cdf0e10cSrcweir                             uintt               i_nSize = 0);
46cdf0e10cSrcweir 
47cdf0e10cSrcweir     /// @see AssignText()
48cdf0e10cSrcweir                         QualifiedName(
49cdf0e10cSrcweir                             const char *        i_sText,
50cdf0e10cSrcweir                             const char *        i_sSeparator );
51cdf0e10cSrcweir                         ~QualifiedName();
52cdf0e10cSrcweir 
operator +=(const String & i_sNamespaceName)53cdf0e10cSrcweir     QualifiedName &     operator+=(
54cdf0e10cSrcweir                             const String &      i_sNamespaceName )
55cdf0e10cSrcweir                                                 { if (i_sNamespaceName.length() > 0)
56cdf0e10cSrcweir                                                         aNamespace.push_back(i_sNamespaceName);
57cdf0e10cSrcweir                                                   return *this; }
58cdf0e10cSrcweir     /// @precond i_nIndex < NamespaceDepth().
operator [](uintt i_nIndex)59cdf0e10cSrcweir     String &            operator[](
60cdf0e10cSrcweir                             uintt               i_nIndex )
61cdf0e10cSrcweir                                                 { csv_assert(i_nIndex < aNamespace.size());
62cdf0e10cSrcweir                                                   return aNamespace[i_nIndex]; }
Init(bool i_bAbsolute)63cdf0e10cSrcweir     void                Init(
64cdf0e10cSrcweir                             bool                i_bAbsolute )
65cdf0e10cSrcweir                                                 { Empty(); bIsAbsolute = i_bAbsolute; }
66cdf0e10cSrcweir     /** Reads a qualified name from a string.
67cdf0e10cSrcweir         If the last two charcters are "()", the inquiry IsFunction() will return
68cdf0e10cSrcweir         true.
69cdf0e10cSrcweir     */
70cdf0e10cSrcweir     void                AssignText(
71cdf0e10cSrcweir                             const char *        i_sText,
72cdf0e10cSrcweir                             const char *        i_sSeparator );
SetLocalName(const String & i_sLocalName)73cdf0e10cSrcweir     void                SetLocalName(
74cdf0e10cSrcweir                             const String &      i_sLocalName )
75cdf0e10cSrcweir                                                 { sLocalName = i_sLocalName; }
Empty()76cdf0e10cSrcweir     void                Empty()                 { csv::erase_container(aNamespace); sLocalName.clear(); bIsAbsolute = false; }
77cdf0e10cSrcweir 
LocalName() const78cdf0e10cSrcweir     const String &      LocalName() const       { return sLocalName; }
first_namespace() const79cdf0e10cSrcweir     namespace_iterator  first_namespace() const { return aNamespace.begin(); }
end_namespace() const80cdf0e10cSrcweir     namespace_iterator  end_namespace() const   { return aNamespace.end(); }
NamespaceDepth() const81cdf0e10cSrcweir     uintt               NamespaceDepth() const  { return aNamespace.size(); }
82cdf0e10cSrcweir 
IsAbsolute() const83cdf0e10cSrcweir     bool                IsAbsolute() const      { return bIsAbsolute; }
IsQualified() const84cdf0e10cSrcweir     bool                IsQualified() const     { return aNamespace.size() > 0; }
IsFunction() const85cdf0e10cSrcweir     bool                IsFunction() const      { return bIsFunction; }
86cdf0e10cSrcweir 
87cdf0e10cSrcweir   private:
88cdf0e10cSrcweir     // DATA
89cdf0e10cSrcweir     StringVector        aNamespace;
90cdf0e10cSrcweir     String              sLocalName;
91cdf0e10cSrcweir     bool                bIsAbsolute;            /// true := beginning with "::".
92cdf0e10cSrcweir     bool                bIsFunction;            /// true := ending with "()"
93cdf0e10cSrcweir };
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 
98cdf0e10cSrcweir }   // namespace ary
99cdf0e10cSrcweir #endif
100