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