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_class.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_class.hxx>
35 // NOT FULLY DECLARED SERVICES
37 #include "c_slots.hxx"
46 Class::Class( const String
& i_sLocalName
,
48 E_Protection i_eProtection
,
50 E_ClassKey i_eClassKey
)
51 : aEssentials( i_sLocalName
,
56 aTemplateParameterTypes(),
67 eClassKey(i_eClassKey
),
68 eProtection(i_eProtection
),
69 eVirtuality(VIRTUAL_none
)
71 aAssignedNode
.Assign_Entity(*this);
79 Class::Add_BaseClass( const S_Classes_Base
& i_rBaseClass
)
81 aBaseClasses
.push_back(i_rBaseClass
);
85 Class::Add_TemplateParameterType( const String
& i_sLocalName
,
88 aTemplateParameterTypes
.push_back(
89 List_TplParam::value_type(i_sLocalName
,i_nIdAsType
) );
93 Class::Add_LocalClass( const String
& i_sLocalName
,
96 aClasses
.push_back( S_LocalCe(i_sLocalName
, i_nId
) );
100 Class::Add_LocalEnum( const String
& i_sLocalName
,
103 aEnums
.push_back( S_LocalCe(i_sLocalName
, i_nId
) );
107 Class::Add_LocalTypedef( const String
& i_sLocalName
,
110 aTypedefs
.push_back( S_LocalCe(i_sLocalName
, i_nId
) );
114 Class::Add_LocalOperation( const String
& i_sLocalName
,
117 aOperations
.push_back( S_LocalCe(i_sLocalName
, i_nId
) );
121 Class::Add_LocalStaticOperation( const String
& i_sLocalName
,
124 aStaticOperations
.push_back( S_LocalCe(i_sLocalName
, i_nId
) );
128 Class::Add_LocalData( const String
& i_sLocalName
,
131 aData
.push_back( S_LocalCe(i_sLocalName
, i_nId
) );
135 Class::Add_LocalStaticData( const String
& i_sLocalName
,
138 aStaticData
.push_back( S_LocalCe(i_sLocalName
, i_nId
) );
145 const String
& i_name
)
149 const S_LocalCe
& i_lce
) const
150 { return i_lce
.sLocalName
== sName
; }
156 Class::Search_Child(const String
& i_key
) const
159 ret
= Ce_id(Search_LocalClass(i_key
));
164 itret
= std::find_if(aEnums
.begin(), aEnums
.end(), find_name(i_key
));
165 if (itret
!= aEnums
.end())
167 itret
= std::find_if(aTypedefs
.begin(), aTypedefs
.end(), find_name(i_key
));
168 if (itret
!= aTypedefs
.end())
170 itret
= std::find_if(aData
.begin(), aData
.end(), find_name(i_key
));
171 if (itret
!= aData
.end())
173 itret
= std::find_if(aStaticData
.begin(), aStaticData
.end(), find_name(i_key
));
174 if (itret
!= aStaticData
.end())
180 Class::Search_LocalClass( const String
& i_sName
) const
182 CIterator_Locals itFound
= PosOfName(aClasses
, i_sName
);
183 if (itFound
!= aClasses
.end())
184 return (*itFound
).nId
.Value();
189 Class::inq_LocalName() const
191 return aEssentials
.LocalName();
195 Class::inq_Owner() const
197 return aEssentials
.Owner();
201 Class::inq_Location() const
203 return aEssentials
.Location();
207 Class::do_Accept(csv::ProcessorIfc
& io_processor
) const
209 csv::CheckedCall(io_processor
,*this);
213 Class::get_AryClass() const
219 Class::inq_Id_Group() const
221 return static_cast<Gid
>(Id());
224 const ary::cpp::CppEntity
&
225 Class::inq_RE_Group() const
230 const group::SlotList
&
231 Class::inq_Slots() const
233 static const SlotAccessId aProjectSlotData
[]
239 SLOT_StaticOperations
,
243 SLOT_FriendOperations
};
244 static const std::vector
< SlotAccessId
>
245 aSlots( &aProjectSlotData
[0],
247 + sizeof aProjectSlotData
/ sizeof (SlotAccessId
) );
253 Class::inq_Create_Slot( SlotAccessId i_nSlot
) const
257 case SLOT_Bases
: return new Slot_BaseClass(aBaseClasses
);
258 case SLOT_NestedClasses
: return new Slot_ListLocalCe(aClasses
);
259 case SLOT_Enums
: return new Slot_ListLocalCe(aEnums
);
260 case SLOT_Typedefs
: return new Slot_ListLocalCe(aTypedefs
);
261 case SLOT_Operations
: return new Slot_ListLocalCe(aOperations
);
262 case SLOT_StaticOperations
: return new Slot_ListLocalCe(aStaticOperations
);
263 case SLOT_Data
: return new Slot_ListLocalCe(aData
);
264 case SLOT_StaticData
: return new Slot_ListLocalCe(aStaticData
);
265 case SLOT_FriendClasses
: return new Slot_SequentialIds
<Ce_id
>(aFriendClasses
);
266 case SLOT_FriendOperations
: return new Slot_SequentialIds
<Ce_id
>(aFriendOperations
);
268 return new Slot_Null
;
272 Class::CIterator_Locals
273 Class::PosOfName( const List_LocalCe
& i_rList
,
274 const String
& i_sName
) const
276 for ( CIterator_Locals ret
= i_rList
.begin();
277 ret
!= i_rList
.end();
280 if ( (*ret
).sLocalName
== i_sName
)
283 return i_rList
.end();