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