xref: /aoo41x/main/autodoc/source/ary/cpp/c_namesp.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include <precomp.h>
29*cdf0e10cSrcweir #include <ary/cpp/c_namesp.hxx>
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
33*cdf0e10cSrcweir #include <algorithm>
34*cdf0e10cSrcweir #include <cosv/tpl/tpltools.hxx>
35*cdf0e10cSrcweir #include <ary/cpp/c_funct.hxx>
36*cdf0e10cSrcweir #include <ary/cpp/c_gate.hxx>
37*cdf0e10cSrcweir #include <ary/getncast.hxx>
38*cdf0e10cSrcweir #include <slots.hxx>
39*cdf0e10cSrcweir #include "c_slots.hxx"
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir namespace ary
43*cdf0e10cSrcweir {
44*cdf0e10cSrcweir namespace cpp
45*cdf0e10cSrcweir {
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir typedef std::multimap<String, Ce_id>::const_iterator      operations_citer;
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir Namespace::Namespace()
50*cdf0e10cSrcweir 	:   aEssentials(),
51*cdf0e10cSrcweir         aAssignedNode(),
52*cdf0e10cSrcweir 		// aLocalNamespaces,
53*cdf0e10cSrcweir 		// aLocalClasses,
54*cdf0e10cSrcweir 		// aLocalEnums,
55*cdf0e10cSrcweir 		// aLocalTypedefs,
56*cdf0e10cSrcweir 		// aLocalOperations,
57*cdf0e10cSrcweir 		// aLocalVariables,
58*cdf0e10cSrcweir 		// aLocalConstants,
59*cdf0e10cSrcweir 		pParent(0),
60*cdf0e10cSrcweir 		nDepth(0)
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir     aAssignedNode.Assign_Entity(*this);
63*cdf0e10cSrcweir }
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir Namespace::Namespace( const String  &     i_sLocalName,
66*cdf0e10cSrcweir 					  Namespace &         i_rParent )
67*cdf0e10cSrcweir 	:   aEssentials( i_sLocalName,
68*cdf0e10cSrcweir 					 i_rParent.CeId(),
69*cdf0e10cSrcweir 					 Lid(0) ),
70*cdf0e10cSrcweir         aAssignedNode(),
71*cdf0e10cSrcweir 		// aLocalNamespaces,
72*cdf0e10cSrcweir 		// aLocalClasses,
73*cdf0e10cSrcweir 		// aLocalEnums,
74*cdf0e10cSrcweir 		// aLocalTypedefs,
75*cdf0e10cSrcweir 		// aLocalOperations,
76*cdf0e10cSrcweir 		// aLocalVariables,
77*cdf0e10cSrcweir 		// aLocalConstants,
78*cdf0e10cSrcweir 		pParent(&i_rParent),
79*cdf0e10cSrcweir 		nDepth(i_rParent.Depth()+1)
80*cdf0e10cSrcweir {
81*cdf0e10cSrcweir     aAssignedNode.Assign_Entity(*this);
82*cdf0e10cSrcweir }
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir Namespace::~Namespace()
85*cdf0e10cSrcweir {
86*cdf0e10cSrcweir }
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir void
89*cdf0e10cSrcweir Namespace::Add_LocalNamespace( DYN Namespace & io_rLocalNamespace )
90*cdf0e10cSrcweir {
91*cdf0e10cSrcweir 	aLocalNamespaces[io_rLocalNamespace.LocalName()] = &io_rLocalNamespace;
92*cdf0e10cSrcweir }
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir void
95*cdf0e10cSrcweir Namespace::Add_LocalClass( const String  &     i_sLocalName,
96*cdf0e10cSrcweir 						   Cid                 i_nId )
97*cdf0e10cSrcweir {
98*cdf0e10cSrcweir 	aLocalClasses[i_sLocalName] = i_nId;
99*cdf0e10cSrcweir }
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir void
102*cdf0e10cSrcweir Namespace::Add_LocalEnum( const String  &     i_sLocalName,
103*cdf0e10cSrcweir 						  Cid                 i_nId )
104*cdf0e10cSrcweir {
105*cdf0e10cSrcweir 	aLocalEnums[i_sLocalName] = i_nId;
106*cdf0e10cSrcweir }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir void
109*cdf0e10cSrcweir Namespace::Add_LocalTypedef( const String  &     i_sLocalName,
110*cdf0e10cSrcweir 							 Cid                 i_nId )
111*cdf0e10cSrcweir {
112*cdf0e10cSrcweir 	aLocalTypedefs[i_sLocalName] = i_nId;
113*cdf0e10cSrcweir }
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir void
116*cdf0e10cSrcweir Namespace::Add_LocalOperation( const String  &     i_sLocalName,
117*cdf0e10cSrcweir 							   Cid                 i_nId )
118*cdf0e10cSrcweir {
119*cdf0e10cSrcweir     aLocalOperations.insert( Map_Operations::value_type(i_sLocalName, i_nId) );
120*cdf0e10cSrcweir }
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir void
124*cdf0e10cSrcweir Namespace::Add_LocalVariable( const String  &     i_sLocalName,
125*cdf0e10cSrcweir 							  Cid                 i_nId )
126*cdf0e10cSrcweir {
127*cdf0e10cSrcweir 	aLocalVariables[i_sLocalName] = i_nId;
128*cdf0e10cSrcweir }
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir void
131*cdf0e10cSrcweir Namespace::Add_LocalConstant( const String  &     i_sLocalName,
132*cdf0e10cSrcweir 							  Cid                 i_nId )
133*cdf0e10cSrcweir {
134*cdf0e10cSrcweir 	aLocalConstants[i_sLocalName] = i_nId;
135*cdf0e10cSrcweir }
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir uintt
138*cdf0e10cSrcweir Namespace::Depth() const
139*cdf0e10cSrcweir {
140*cdf0e10cSrcweir 	return nDepth;
141*cdf0e10cSrcweir }
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir Namespace *
144*cdf0e10cSrcweir Namespace::Parent() const
145*cdf0e10cSrcweir {
146*cdf0e10cSrcweir 	return pParent;
147*cdf0e10cSrcweir }
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir Ce_id
150*cdf0e10cSrcweir Namespace::Search_Child(const String & i_key) const
151*cdf0e10cSrcweir {
152*cdf0e10cSrcweir     Namespace *
153*cdf0e10cSrcweir         ret_nsp = Search_LocalNamespace(i_key);
154*cdf0e10cSrcweir     if (ret_nsp != 0)
155*cdf0e10cSrcweir         return ret_nsp->CeId();
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir     Ce_id
158*cdf0e10cSrcweir         ret = Search_LocalClass(i_key);
159*cdf0e10cSrcweir     if (ret.IsValid())
160*cdf0e10cSrcweir         return ret;
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir     ret = csv::value_from_map(aLocalEnums, i_key, Ce_id(0));
163*cdf0e10cSrcweir     if (ret.IsValid())
164*cdf0e10cSrcweir         return ret;
165*cdf0e10cSrcweir     ret = csv::value_from_map(aLocalTypedefs, i_key, Ce_id(0));
166*cdf0e10cSrcweir     if (ret.IsValid())
167*cdf0e10cSrcweir         return ret;
168*cdf0e10cSrcweir     ret = csv::value_from_map(aLocalVariables, i_key, Ce_id(0));
169*cdf0e10cSrcweir     if (ret.IsValid())
170*cdf0e10cSrcweir         return ret;
171*cdf0e10cSrcweir     return csv::value_from_map(aLocalConstants, i_key, Ce_id(0));
172*cdf0e10cSrcweir }
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir Namespace *
175*cdf0e10cSrcweir Namespace::Search_LocalNamespace( const String  & i_sLocalName ) const
176*cdf0e10cSrcweir {
177*cdf0e10cSrcweir 	return csv::value_from_map(aLocalNamespaces, i_sLocalName, (Namespace*)(0));
178*cdf0e10cSrcweir }
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir uintt
181*cdf0e10cSrcweir Namespace::Get_SubNamespaces( std::vector< const Namespace* > & o_rResultList ) const
182*cdf0e10cSrcweir {
183*cdf0e10cSrcweir 	for ( Map_NamespacePtr::const_iterator it = aLocalNamespaces.begin();
184*cdf0e10cSrcweir 		  it != aLocalNamespaces.end();
185*cdf0e10cSrcweir 		  ++it )
186*cdf0e10cSrcweir 	{
187*cdf0e10cSrcweir 		o_rResultList.push_back( (*it).second );
188*cdf0e10cSrcweir 	}
189*cdf0e10cSrcweir 	return o_rResultList.size();
190*cdf0e10cSrcweir }
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir Ce_id
193*cdf0e10cSrcweir Namespace::Search_LocalClass( const String  & i_sName ) const
194*cdf0e10cSrcweir {
195*cdf0e10cSrcweir 	return csv::value_from_map(aLocalClasses, i_sName, Ce_id(0));
196*cdf0e10cSrcweir }
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir void
199*cdf0e10cSrcweir Namespace::Search_LocalOperations( std::vector<Ce_id> & o_result,
200*cdf0e10cSrcweir                                    const String &       i_sName ) const
201*cdf0e10cSrcweir {
202*cdf0e10cSrcweir     operations_citer
203*cdf0e10cSrcweir         itLower = aLocalOperations.lower_bound(i_sName);
204*cdf0e10cSrcweir     if (itLower == aLocalOperations.end())
205*cdf0e10cSrcweir         return;
206*cdf0e10cSrcweir     if ( (*itLower).first != i_sName )
207*cdf0e10cSrcweir         return;
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir     operations_citer
210*cdf0e10cSrcweir         itEnd = aLocalOperations.end();
211*cdf0e10cSrcweir     for ( operations_citer it = itLower;
212*cdf0e10cSrcweir           it != aLocalOperations.end() ? (*itLower).first == i_sName : false;
213*cdf0e10cSrcweir           ++it )
214*cdf0e10cSrcweir     {
215*cdf0e10cSrcweir         o_result.push_back((*it).second);
216*cdf0e10cSrcweir     }
217*cdf0e10cSrcweir }
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir const String  &
221*cdf0e10cSrcweir Namespace::inq_LocalName() const
222*cdf0e10cSrcweir {
223*cdf0e10cSrcweir 	return aEssentials.LocalName();
224*cdf0e10cSrcweir }
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir Cid
227*cdf0e10cSrcweir Namespace::inq_Owner() const
228*cdf0e10cSrcweir {
229*cdf0e10cSrcweir 	return aEssentials.Owner();
230*cdf0e10cSrcweir }
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir Lid
233*cdf0e10cSrcweir Namespace::inq_Location() const
234*cdf0e10cSrcweir {
235*cdf0e10cSrcweir 	return Lid(0);
236*cdf0e10cSrcweir }
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir void
239*cdf0e10cSrcweir Namespace::do_Accept(csv::ProcessorIfc & io_processor) const
240*cdf0e10cSrcweir {
241*cdf0e10cSrcweir     csv::CheckedCall(io_processor,*this);
242*cdf0e10cSrcweir }
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir ClassId
245*cdf0e10cSrcweir Namespace::get_AryClass() const
246*cdf0e10cSrcweir {
247*cdf0e10cSrcweir 	return class_id;
248*cdf0e10cSrcweir }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir Gid
251*cdf0e10cSrcweir Namespace::inq_Id_Group() const
252*cdf0e10cSrcweir {
253*cdf0e10cSrcweir 	return static_cast<Gid>(Id());
254*cdf0e10cSrcweir }
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir const ary::cpp::CppEntity &
257*cdf0e10cSrcweir Namespace::inq_RE_Group() const
258*cdf0e10cSrcweir {
259*cdf0e10cSrcweir 	return *this;
260*cdf0e10cSrcweir }
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir const ary::group::SlotList &
263*cdf0e10cSrcweir Namespace::inq_Slots() const
264*cdf0e10cSrcweir {
265*cdf0e10cSrcweir 	static const SlotAccessId aProjectSlotData[]
266*cdf0e10cSrcweir 			= { SLOT_SubNamespaces, SLOT_Classes, SLOT_Enums, SLOT_Typedefs, SLOT_Operations,
267*cdf0e10cSrcweir 				SLOT_Variables, SLOT_Constants };
268*cdf0e10cSrcweir 	static const std::vector< SlotAccessId >
269*cdf0e10cSrcweir 			aSlots( &aProjectSlotData[0],
270*cdf0e10cSrcweir 					  &aProjectSlotData[0]
271*cdf0e10cSrcweir 						+ sizeof aProjectSlotData / sizeof (SlotAccessId) );
272*cdf0e10cSrcweir 	return aSlots;
273*cdf0e10cSrcweir }
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir DYN Slot *
276*cdf0e10cSrcweir Namespace::inq_Create_Slot( SlotAccessId i_nSlot ) const
277*cdf0e10cSrcweir {
278*cdf0e10cSrcweir 	switch ( i_nSlot )
279*cdf0e10cSrcweir 	{
280*cdf0e10cSrcweir 		case SLOT_SubNamespaces:    return new Slot_SubNamespaces(aLocalNamespaces);
281*cdf0e10cSrcweir 		case SLOT_Classes:          return new Slot_MapLocalCe(aLocalClasses);
282*cdf0e10cSrcweir 		case SLOT_Enums:            return new Slot_MapLocalCe(aLocalEnums);
283*cdf0e10cSrcweir 		case SLOT_Typedefs:         return new Slot_MapLocalCe(aLocalTypedefs);
284*cdf0e10cSrcweir 		case SLOT_Operations:       return new Slot_MapOperations(aLocalOperations);
285*cdf0e10cSrcweir 		case SLOT_Variables:        return new Slot_MapLocalCe(aLocalVariables);
286*cdf0e10cSrcweir 		case SLOT_Constants:        return new Slot_MapLocalCe(aLocalConstants);
287*cdf0e10cSrcweir 		default:
288*cdf0e10cSrcweir 									return new Slot_Null;
289*cdf0e10cSrcweir 	}   // end switch
290*cdf0e10cSrcweir }
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir }   // namespace cpp
294*cdf0e10cSrcweir }   // namespace ary
295