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_CPP_NAMECHAI_HXX
25cdf0e10cSrcweir #define ARY_CPP_NAMECHAI_HXX
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir // USED SERVICES
29cdf0e10cSrcweir // BASE CLASSES
30cdf0e10cSrcweir // OTHER
31cdf0e10cSrcweir
32cdf0e10cSrcweir
33cdf0e10cSrcweir namespace ary
34cdf0e10cSrcweir {
35cdf0e10cSrcweir namespace cpp
36cdf0e10cSrcweir {
37cdf0e10cSrcweir class Gate;
38cdf0e10cSrcweir
39cdf0e10cSrcweir namespace ut
40cdf0e10cSrcweir {
41cdf0e10cSrcweir class List_TplParameter;
42cdf0e10cSrcweir
43cdf0e10cSrcweir class NameSegment
44cdf0e10cSrcweir {
45cdf0e10cSrcweir public:
46cdf0e10cSrcweir NameSegment(
47cdf0e10cSrcweir const char * i_sName );
48cdf0e10cSrcweir /** @precond MPT pTemplate.
49cdf0e10cSrcweir This cannot be used, except of inserting a new element
50cdf0e10cSrcweir in the segment list of ary::cpp::ut::NameChain. In that
51cdf0e10cSrcweir case, the template parameter list doe snot yet exist.
52cdf0e10cSrcweir */
53cdf0e10cSrcweir NameSegment(
54cdf0e10cSrcweir const NameSegment & i_rSeg );
55cdf0e10cSrcweir ~NameSegment();
56cdf0e10cSrcweir
57cdf0e10cSrcweir // OPERATIONS
58cdf0e10cSrcweir List_TplParameter & AddTemplate();
59cdf0e10cSrcweir
60cdf0e10cSrcweir // INQUIRY
61cdf0e10cSrcweir const String & Name() const;
62cdf0e10cSrcweir
63cdf0e10cSrcweir /// @return as strcmp().
64cdf0e10cSrcweir intt Compare(
65cdf0e10cSrcweir const NameSegment & i_rOther ) const;
66cdf0e10cSrcweir void Get_Text_AsScope(
67cdf0e10cSrcweir StreamStr & o_rOut,
68cdf0e10cSrcweir const ary::cpp::Gate &
69cdf0e10cSrcweir i_rGate ) const;
70cdf0e10cSrcweir void Get_Text_AsMainType(
71cdf0e10cSrcweir StreamStr & o_rName,
72cdf0e10cSrcweir StreamStr & o_rPostName,
73cdf0e10cSrcweir const ary::cpp::Gate &
74cdf0e10cSrcweir i_rGate ) const;
75cdf0e10cSrcweir
76cdf0e10cSrcweir NameSegment& operator=(const NameSegment&);
77cdf0e10cSrcweir private:
78cdf0e10cSrcweir String sName;
79cdf0e10cSrcweir Dyn<List_TplParameter>
80cdf0e10cSrcweir pTemplate;
81cdf0e10cSrcweir };
82cdf0e10cSrcweir
83cdf0e10cSrcweir class NameChain
84cdf0e10cSrcweir {
85cdf0e10cSrcweir public:
86cdf0e10cSrcweir typedef std::vector<NameSegment>::const_iterator
87cdf0e10cSrcweir const_iterator;
88cdf0e10cSrcweir
89cdf0e10cSrcweir NameChain();
90cdf0e10cSrcweir ~NameChain();
91cdf0e10cSrcweir
92cdf0e10cSrcweir // OPERATIONS
93cdf0e10cSrcweir void Add_Segment(
94cdf0e10cSrcweir const char * i_sSeg );
95cdf0e10cSrcweir /** @precond aSegments.size() > 0.
96cdf0e10cSrcweir Which means: Add_Segment() has to be called at least once before.
97cdf0e10cSrcweir */
98cdf0e10cSrcweir List_TplParameter & Templatize_LastSegment();
99cdf0e10cSrcweir
100cdf0e10cSrcweir // INQUIRY
begin() const101cdf0e10cSrcweir const_iterator begin() const { return aSegments.begin(); }
end() const102cdf0e10cSrcweir const_iterator end() const { return aSegments.end(); }
103cdf0e10cSrcweir
104cdf0e10cSrcweir /// @return like strcmp.
105cdf0e10cSrcweir intt Compare(
106cdf0e10cSrcweir const NameChain & i_rChain ) const;
107cdf0e10cSrcweir /// @ATTENTION Return value is volatile. Not reentrance enabled.
108cdf0e10cSrcweir const String & LastSegment() const;
109cdf0e10cSrcweir
110cdf0e10cSrcweir void Get_Text(
111cdf0e10cSrcweir StreamStr & o_rPreName,
112cdf0e10cSrcweir StreamStr & o_rName,
113cdf0e10cSrcweir StreamStr & o_rPostName,
114cdf0e10cSrcweir const ary::cpp::Gate &
115cdf0e10cSrcweir i_rGate ) const;
116cdf0e10cSrcweir private:
117cdf0e10cSrcweir std::vector< NameSegment >
118cdf0e10cSrcweir aSegments;
119cdf0e10cSrcweir };
120cdf0e10cSrcweir
121cdf0e10cSrcweir
122cdf0e10cSrcweir
123cdf0e10cSrcweir // IMPLEMENTATION
124cdf0e10cSrcweir inline const String &
Name() const125cdf0e10cSrcweir NameSegment::Name() const
126cdf0e10cSrcweir { return sName; }
127cdf0e10cSrcweir
128cdf0e10cSrcweir
129cdf0e10cSrcweir
130cdf0e10cSrcweir
131cdf0e10cSrcweir
132cdf0e10cSrcweir
133cdf0e10cSrcweir } // namespace ut
134cdf0e10cSrcweir } // namespace cpp
135cdf0e10cSrcweir } // namespace ary
136cdf0e10cSrcweir #endif
137