Update ooo320-m1
[ooovba.git] / autodoc / source / ary / cpp / c_namesp.cxx
blobecc41a818ab8957320d87821dfe517e29809a12a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: c_namesp.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <precomp.h>
32 #include <ary/cpp/c_namesp.hxx>
35 // NOT FULLY DECLARED SERVICES
36 #include <algorithm>
37 #include <cosv/tpl/tpltools.hxx>
38 #include <ary/cpp/c_funct.hxx>
39 #include <ary/cpp/c_gate.hxx>
40 #include <ary/getncast.hxx>
41 #include <slots.hxx>
42 #include "c_slots.hxx"
45 namespace ary
47 namespace cpp
50 typedef std::multimap<String, Ce_id>::const_iterator operations_citer;
52 Namespace::Namespace()
53 : aEssentials(),
54 aAssignedNode(),
55 // aLocalNamespaces,
56 // aLocalClasses,
57 // aLocalEnums,
58 // aLocalTypedefs,
59 // aLocalOperations,
60 // aLocalVariables,
61 // aLocalConstants,
62 pParent(0),
63 nDepth(0)
65 aAssignedNode.Assign_Entity(*this);
68 Namespace::Namespace( const String & i_sLocalName,
69 Namespace & i_rParent )
70 : aEssentials( i_sLocalName,
71 i_rParent.CeId(),
72 Lid(0) ),
73 aAssignedNode(),
74 // aLocalNamespaces,
75 // aLocalClasses,
76 // aLocalEnums,
77 // aLocalTypedefs,
78 // aLocalOperations,
79 // aLocalVariables,
80 // aLocalConstants,
81 pParent(&i_rParent),
82 nDepth(i_rParent.Depth()+1)
84 aAssignedNode.Assign_Entity(*this);
87 Namespace::~Namespace()
91 void
92 Namespace::Add_LocalNamespace( DYN Namespace & io_rLocalNamespace )
94 aLocalNamespaces[io_rLocalNamespace.LocalName()] = &io_rLocalNamespace;
97 void
98 Namespace::Add_LocalClass( const String & i_sLocalName,
99 Cid i_nId )
101 aLocalClasses[i_sLocalName] = i_nId;
104 void
105 Namespace::Add_LocalEnum( const String & i_sLocalName,
106 Cid i_nId )
108 aLocalEnums[i_sLocalName] = i_nId;
111 void
112 Namespace::Add_LocalTypedef( const String & i_sLocalName,
113 Cid i_nId )
115 aLocalTypedefs[i_sLocalName] = i_nId;
118 void
119 Namespace::Add_LocalOperation( const String & i_sLocalName,
120 Cid i_nId )
122 aLocalOperations.insert( Map_Operations::value_type(i_sLocalName, i_nId) );
126 void
127 Namespace::Add_LocalVariable( const String & i_sLocalName,
128 Cid i_nId )
130 aLocalVariables[i_sLocalName] = i_nId;
133 void
134 Namespace::Add_LocalConstant( const String & i_sLocalName,
135 Cid i_nId )
137 aLocalConstants[i_sLocalName] = i_nId;
140 uintt
141 Namespace::Depth() const
143 return nDepth;
146 Namespace *
147 Namespace::Parent() const
149 return pParent;
152 Ce_id
153 Namespace::Search_Child(const String & i_key) const
155 Namespace *
156 ret_nsp = Search_LocalNamespace(i_key);
157 if (ret_nsp != 0)
158 return ret_nsp->CeId();
160 Ce_id
161 ret = Search_LocalClass(i_key);
162 if (ret.IsValid())
163 return ret;
165 ret = csv::value_from_map(aLocalEnums, i_key, Ce_id(0));
166 if (ret.IsValid())
167 return ret;
168 ret = csv::value_from_map(aLocalTypedefs, i_key, Ce_id(0));
169 if (ret.IsValid())
170 return ret;
171 ret = csv::value_from_map(aLocalVariables, i_key, Ce_id(0));
172 if (ret.IsValid())
173 return ret;
174 return csv::value_from_map(aLocalConstants, i_key, Ce_id(0));
177 Namespace *
178 Namespace::Search_LocalNamespace( const String & i_sLocalName ) const
180 return csv::value_from_map(aLocalNamespaces, i_sLocalName, (Namespace*)(0));
183 uintt
184 Namespace::Get_SubNamespaces( std::vector< const Namespace* > & o_rResultList ) const
186 for ( Map_NamespacePtr::const_iterator it = aLocalNamespaces.begin();
187 it != aLocalNamespaces.end();
188 ++it )
190 o_rResultList.push_back( (*it).second );
192 return o_rResultList.size();
195 Ce_id
196 Namespace::Search_LocalClass( const String & i_sName ) const
198 return csv::value_from_map(aLocalClasses, i_sName, Ce_id(0));
201 void
202 Namespace::Search_LocalOperations( std::vector<Ce_id> & o_result,
203 const String & i_sName ) const
205 operations_citer
206 itLower = aLocalOperations.lower_bound(i_sName);
207 if (itLower == aLocalOperations.end())
208 return;
209 if ( (*itLower).first != i_sName )
210 return;
212 operations_citer
213 itEnd = aLocalOperations.end();
214 for ( operations_citer it = itLower;
215 it != aLocalOperations.end() ? (*itLower).first == i_sName : false;
216 ++it )
218 o_result.push_back((*it).second);
223 const String &
224 Namespace::inq_LocalName() const
226 return aEssentials.LocalName();
230 Namespace::inq_Owner() const
232 return aEssentials.Owner();
236 Namespace::inq_Location() const
238 return Lid(0);
241 void
242 Namespace::do_Accept(csv::ProcessorIfc & io_processor) const
244 csv::CheckedCall(io_processor,*this);
247 ClassId
248 Namespace::get_AryClass() const
250 return class_id;
254 Namespace::inq_Id_Group() const
256 return static_cast<Gid>(Id());
259 const ary::cpp::CppEntity &
260 Namespace::inq_RE_Group() const
262 return *this;
265 const ary::group::SlotList &
266 Namespace::inq_Slots() const
268 static const SlotAccessId aProjectSlotData[]
269 = { SLOT_SubNamespaces, SLOT_Classes, SLOT_Enums, SLOT_Typedefs, SLOT_Operations,
270 SLOT_Variables, SLOT_Constants };
271 static const std::vector< SlotAccessId >
272 aSlots( &aProjectSlotData[0],
273 &aProjectSlotData[0]
274 + sizeof aProjectSlotData / sizeof (SlotAccessId) );
275 return aSlots;
278 DYN Slot *
279 Namespace::inq_Create_Slot( SlotAccessId i_nSlot ) const
281 switch ( i_nSlot )
283 case SLOT_SubNamespaces: return new Slot_SubNamespaces(aLocalNamespaces);
284 case SLOT_Classes: return new Slot_MapLocalCe(aLocalClasses);
285 case SLOT_Enums: return new Slot_MapLocalCe(aLocalEnums);
286 case SLOT_Typedefs: return new Slot_MapLocalCe(aLocalTypedefs);
287 case SLOT_Operations: return new Slot_MapOperations(aLocalOperations);
288 case SLOT_Variables: return new Slot_MapLocalCe(aLocalVariables);
289 case SLOT_Constants: return new Slot_MapLocalCe(aLocalConstants);
290 default:
291 return new Slot_Null;
292 } // end switch
296 } // namespace cpp
297 } // namespace ary