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