update dev300-m58
[ooovba.git] / autodoc / source / display / html / aryattrs.cxx
blobef86d9900e65251340be4475ba54730c28285ace
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: aryattrs.cxx,v $
10 * $Revision: 1.8 $
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 "aryattrs.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <ary/getncast.hxx>
37 #include <ary/cpp/c_class.hxx>
38 #include <ary/cpp/c_enum.hxx>
39 #include <ary/cpp/c_funct.hxx>
40 #include <ary/cpp/c_gate.hxx>
41 #include <ary/cpp/c_namesp.hxx>
42 #include <ary/cpp/cp_ce.hxx>
43 #include <ary/cpp/cp_type.hxx>
44 #include "strconst.hxx"
49 //******************** HtmlDisplay_Impl *********************//
51 const char *
52 Get_ClassTypeKey( const ary::cpp::Class & i_rClass )
54 return i_rClass.ClassKey() == ary::cpp::CK_class
55 ? C_sHFTypeTitle_Class
56 : i_rClass.ClassKey() == ary::cpp::CK_struct
57 ? C_sHFTypeTitle_Struct
58 : C_sHFTypeTitle_Union;
62 const char *
63 Get_TypeKey( const ary::cpp::CodeEntity & i_rCe )
65 if ( ary::is_type<ary::cpp::Class>(i_rCe) )
67 return Get_ClassTypeKey(
68 ary::ary_cast<ary::cpp::Class>(i_rCe) );
70 if ( ary::is_type<ary::cpp::Enum>(i_rCe) )
72 return "enum";
74 return "";
77 bool
78 Ce_IsInternal( const ary::cpp::CodeEntity & i_rCe )
80 return NOT i_rCe.IsVisible();
83 const char *
84 SyntaxText_PreName( const ary::cpp::Function & i_rFunction,
85 const ary::cpp::Gate & i_rAryGate )
87 static StreamStr sResult( 150 );
88 sResult.seekp(0);
90 // write pre-name:
91 const ary::cpp::FunctionFlags & rFlags = i_rFunction.Flags();
92 if ( rFlags.IsStaticLocal() OR rFlags.IsStaticMember() )
93 sResult << "static ";
94 if ( rFlags.IsExplicit() )
95 sResult << "explicit ";
96 if ( rFlags.IsMutable() )
97 sResult << "mutable ";
98 if ( i_rFunction.Virtuality() != ary::cpp::VIRTUAL_none )
99 sResult << "virtual ";
100 i_rAryGate.Types().Get_TypeText( sResult, i_rFunction.ReturnType() );
101 sResult << " ";
103 return sResult.c_str();
106 const char *
107 SyntaxText_PostName( const ary::cpp::Function & i_rFunction,
108 const ary::cpp::Gate & i_rAryGate )
110 static StreamStr sResult( 850 );
111 sResult.seekp(0);
113 // parameters and con_vol
114 i_rAryGate.Ces().Get_SignatureText( sResult, i_rFunction.Signature(), &i_rFunction.ParamInfos() );
116 // write Exceptions:
117 const std::vector< ary::cpp::Type_id > *
118 pThrow = i_rFunction.Exceptions();
119 if ( pThrow)
122 std::vector< ary::cpp::Type_id >::const_iterator
123 it = pThrow->begin();
124 std::vector< ary::cpp::Type_id >::const_iterator
125 it_end = pThrow->end();
127 if (it != it_end)
129 sResult << " throw( ";
130 i_rAryGate.Types().Get_TypeText(sResult, *it);
132 for ( ++it; it != it_end; ++it )
134 sResult << ", ";
135 i_rAryGate.Types().Get_TypeText(sResult, *it);
137 sResult << " )";
139 else
141 sResult << " throw( )";
143 } // endif // pThrow
145 // abstractness:
146 if ( i_rFunction.Virtuality() == ary::cpp::VIRTUAL_abstract )
147 sResult << " = 0";
149 // finish:
150 sResult << ";";
152 return sResult.c_str();
155 bool
156 Get_TypeText( const char * & o_rPreName,
157 const char * & o_rName,
158 const char * & o_rPostName,
159 ary::cpp::Type_id i_nTypeid,
160 const ary::cpp::Gate & i_rAryGate )
162 static StreamStr sResult_PreName(250);
163 static StreamStr sResult_Name(250);
164 static StreamStr sResult_PostName(250);
166 sResult_PreName.seekp(0);
167 sResult_Name.seekp(0);
168 sResult_PostName.seekp(0);
170 bool ret = i_rAryGate.Types().Get_TypeText(
171 sResult_PreName,
172 sResult_Name,
173 sResult_PostName,
174 i_nTypeid );
175 if ( sResult_PreName.tellp() > 0 )
177 char cLast = *( sResult_PreName.c_str() + (sResult_PreName.tellp() - 1) );
178 if (cLast != ':' AND cLast != ' ')
179 sResult_PreName << " ";
183 if (ret)
185 o_rPreName = sResult_PreName.c_str();
186 o_rName = sResult_Name.c_str();
187 o_rPostName = sResult_PostName.c_str();
189 else
191 o_rPreName = o_rName = o_rPostName = "";
193 return ret;
199 //********************* FunctionParam_Iterator *****************//
202 FunctionParam_Iterator::FunctionParam_Iterator()
203 : // itTypes
204 // itTypes_end
205 // itNames_andMore
206 // itNames_andMore_end
207 eConVol(ary::cpp::CONVOL_none)
209 static std::vector<ary::cpp::Type_id> aTypesNull_;
210 static StringVector aNamesNull_;
212 itTypes = itTypes_end = aTypesNull_.end();
213 itNames_andMore = itNames_andMore_end = aNamesNull_.end();
216 FunctionParam_Iterator::~FunctionParam_Iterator()
220 FunctionParam_Iterator &
221 FunctionParam_Iterator::operator++()
223 if ( IsValid() )
225 ++itTypes;
226 ++itNames_andMore;
228 return *this;
231 void
232 FunctionParam_Iterator::Assign( const ary::cpp::Function & i_rFunction )
234 const ary::cpp::OperationSignature &
235 rSigna = i_rFunction.Signature();
237 const std::vector<ary::cpp::Type_id> &
238 rTypes = rSigna.Parameters();
239 const StringVector &
240 rNames = i_rFunction.ParamInfos();
242 if ( rTypes.size() != rNames.size() OR rTypes.size() == 0 )
243 return;
245 itTypes = rTypes.begin();
246 itTypes_end = rTypes.end();
247 itNames_andMore = rNames.begin();
248 itNames_andMore_end = rNames.end();
250 eConVol = rSigna.ConVol();