1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: c_namesp.cxx,v $
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 ************************************************************************/
32 #include <ary/cpp/c_namesp.hxx>
35 // NOT FULLY DECLARED SERVICES
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>
42 #include "c_slots.hxx"
50 typedef std::multimap
<String
, Ce_id
>::const_iterator operations_citer
;
52 Namespace::Namespace()
65 aAssignedNode
.Assign_Entity(*this);
68 Namespace::Namespace( const String
& i_sLocalName
,
69 Namespace
& i_rParent
)
70 : aEssentials( i_sLocalName
,
82 nDepth(i_rParent
.Depth()+1)
84 aAssignedNode
.Assign_Entity(*this);
87 Namespace::~Namespace()
92 Namespace::Add_LocalNamespace( DYN Namespace
& io_rLocalNamespace
)
94 aLocalNamespaces
[io_rLocalNamespace
.LocalName()] = &io_rLocalNamespace
;
98 Namespace::Add_LocalClass( const String
& i_sLocalName
,
101 aLocalClasses
[i_sLocalName
] = i_nId
;
105 Namespace::Add_LocalEnum( const String
& i_sLocalName
,
108 aLocalEnums
[i_sLocalName
] = i_nId
;
112 Namespace::Add_LocalTypedef( const String
& i_sLocalName
,
115 aLocalTypedefs
[i_sLocalName
] = i_nId
;
119 Namespace::Add_LocalOperation( const String
& i_sLocalName
,
122 aLocalOperations
.insert( Map_Operations::value_type(i_sLocalName
, i_nId
) );
127 Namespace::Add_LocalVariable( const String
& i_sLocalName
,
130 aLocalVariables
[i_sLocalName
] = i_nId
;
134 Namespace::Add_LocalConstant( const String
& i_sLocalName
,
137 aLocalConstants
[i_sLocalName
] = i_nId
;
141 Namespace::Depth() const
147 Namespace::Parent() const
153 Namespace::Search_Child(const String
& i_key
) const
156 ret_nsp
= Search_LocalNamespace(i_key
);
158 return ret_nsp
->CeId();
161 ret
= Search_LocalClass(i_key
);
165 ret
= csv::value_from_map(aLocalEnums
, i_key
, Ce_id(0));
168 ret
= csv::value_from_map(aLocalTypedefs
, i_key
, Ce_id(0));
171 ret
= csv::value_from_map(aLocalVariables
, i_key
, Ce_id(0));
174 return csv::value_from_map(aLocalConstants
, i_key
, Ce_id(0));
178 Namespace::Search_LocalNamespace( const String
& i_sLocalName
) const
180 return csv::value_from_map(aLocalNamespaces
, i_sLocalName
, (Namespace
*)(0));
184 Namespace::Get_SubNamespaces( std::vector
< const Namespace
* > & o_rResultList
) const
186 for ( Map_NamespacePtr::const_iterator it
= aLocalNamespaces
.begin();
187 it
!= aLocalNamespaces
.end();
190 o_rResultList
.push_back( (*it
).second
);
192 return o_rResultList
.size();
196 Namespace::Search_LocalClass( const String
& i_sName
) const
198 return csv::value_from_map(aLocalClasses
, i_sName
, Ce_id(0));
202 Namespace::Search_LocalOperations( std::vector
<Ce_id
> & o_result
,
203 const String
& i_sName
) const
206 itLower
= aLocalOperations
.lower_bound(i_sName
);
207 if (itLower
== aLocalOperations
.end())
209 if ( (*itLower
).first
!= i_sName
)
213 itEnd
= aLocalOperations
.end();
214 for ( operations_citer it
= itLower
;
215 it
!= aLocalOperations
.end() ? (*itLower
).first
== i_sName
: false;
218 o_result
.push_back((*it
).second
);
224 Namespace::inq_LocalName() const
226 return aEssentials
.LocalName();
230 Namespace::inq_Owner() const
232 return aEssentials
.Owner();
236 Namespace::inq_Location() const
242 Namespace::do_Accept(csv::ProcessorIfc
& io_processor
) const
244 csv::CheckedCall(io_processor
,*this);
248 Namespace::get_AryClass() const
254 Namespace::inq_Id_Group() const
256 return static_cast<Gid
>(Id());
259 const ary::cpp::CppEntity
&
260 Namespace::inq_RE_Group() const
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],
274 + sizeof aProjectSlotData
/ sizeof (SlotAccessId
) );
279 Namespace::inq_Create_Slot( SlotAccessId i_nSlot
) const
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
);
291 return new Slot_Null
;