Update ooo320-m1
[ooovba.git] / autodoc / source / ary / cpp / c_funct.cxx
blob3da622cb0899dc8504d67331707df48f42aa1178
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_funct.cxx,v $
10 * $Revision: 1.6 $
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_funct.hxx>
36 // NOT FULLY DECLARED SERVICES
37 #include <algorithm>
38 #include <ary/cpp/c_funct.hxx>
44 namespace
46 using namespace ::ary::cpp;
49 class Parameter_2_NonTypeParamInfo
51 public:
52 String operator()(
53 const S_Parameter & i_rParam ) const;
56 class Parameter_2_Type
58 public:
59 Type_id operator()(
60 const S_Parameter & i_rParam ) const
61 { return i_rParam.nType; }
64 /** @return
65 A vector with Strings like this:
66 "ParamName" or "ParamName[ArraySize]" or "ParamName = InitValue".
68 StringVector Create_NonTypeParameterInfos(
69 const std::vector<S_Parameter> &
70 i_rParameters );
71 /** @return
72 A vector of the parameters' type ids.
74 std::vector<Type_id>
75 Create_ParameterTypeList(
76 const std::vector<S_Parameter> &
77 i_rParameters );
79 } // namspace anonymous
82 namespace ary
84 namespace cpp
87 Function::Function( const String & i_sLocalName,
88 Ce_id i_nOwner,
89 E_Protection i_eProtection,
90 Lid i_nFile,
91 Type_id i_nReturnType,
92 const std::vector<S_Parameter> &
93 i_parameters,
94 E_ConVol i_conVol,
95 E_Virtuality i_eVirtuality,
96 FunctionFlags i_aFlags,
97 bool i_bThrowExists,
98 const std::vector<Type_id> &
99 i_rExceptions )
100 : aEssentials( i_sLocalName,
101 i_nOwner,
102 i_nFile ),
103 aTemplateParameterTypes(),
104 aSignature( Create_ParameterTypeList(i_parameters),
105 i_conVol ),
106 nReturnType(i_nReturnType),
107 eProtection(i_eProtection),
108 eVirtuality(i_eVirtuality),
109 aFlags(i_aFlags),
110 aParameterInfos( Create_NonTypeParameterInfos(i_parameters) ),
111 pExceptions( i_bThrowExists ? new ExceptionTypeList(i_rExceptions) : 0 )
115 Function::~Function()
119 bool
120 Function::IsIdentical( const Function & i_f ) const
122 return
123 LocalName() == i_f.LocalName()
125 Owner() == i_f.Owner()
127 aSignature == i_f.aSignature
129 nReturnType == i_f.nReturnType
131 eProtection == i_f.eProtection
133 eVirtuality == i_f.eVirtuality
135 aFlags == i_f.aFlags
137 ( ( NOT pExceptions AND NOT i_f.pExceptions )
139 ( pExceptions AND i_f.pExceptions
140 ? *pExceptions == *i_f.pExceptions
141 : false )
144 aTemplateParameterTypes.size() == i_f.aTemplateParameterTypes.size();
147 void
148 Function::Add_TemplateParameterType( const String & i_sLocalName,
149 Type_id i_nIdAsType )
151 aTemplateParameterTypes.push_back(
152 List_TplParam::value_type(i_sLocalName, i_nIdAsType) );
156 const String &
157 Function::inq_LocalName() const
159 return aEssentials.LocalName();
163 Function::inq_Owner() const
165 return aEssentials.Owner();
169 Function::inq_Location() const
171 return aEssentials.Location();
174 void
175 Function::do_Accept(csv::ProcessorIfc & io_processor) const
177 csv::CheckedCall(io_processor,*this);
180 ClassId
181 Function::get_AryClass() const
183 return class_id;
188 } // namespace cpp
189 } // namespace ary
193 namespace
196 String
197 Parameter_2_NonTypeParamInfo::operator()( const ary::cpp::S_Parameter & i_rParam ) const
199 static StreamStr aParamName_(1020);
200 aParamName_.seekp(0);
202 aParamName_ << i_rParam.sName;
203 if ( i_rParam.sSizeExpression.length() > 0 )
205 aParamName_ << '['
206 << i_rParam.sSizeExpression
207 << ']';
209 if ( i_rParam.sInitExpression.length() > 0 )
211 aParamName_ << " = "
212 << i_rParam.sInitExpression;
215 return aParamName_.c_str();
219 StringVector
220 Create_NonTypeParameterInfos( const std::vector<S_Parameter> & i_rParameters )
222 static Parameter_2_NonTypeParamInfo
223 aTransformFunction_;
225 StringVector
226 ret(i_rParameters.size(), String::Null_());
227 std::transform( i_rParameters.begin(), i_rParameters.end(),
228 ret.begin(),
229 aTransformFunction_ );
230 return ret;
233 std::vector<Type_id>
234 Create_ParameterTypeList( const std::vector<S_Parameter> & i_rParameters )
236 static Parameter_2_Type
237 aTransformFunction_;
239 std::vector<Type_id>
240 ret(i_rParameters.size(), Type_id(0));
241 std::transform( i_rParameters.begin(), i_rParameters.end(),
242 ret.begin(),
243 aTransformFunction_ );
244 return ret;
250 } // namespace anonymous