On Tue, 29 Jul 2003 21:08:35 -0500 (EST), Kenneth Chiu wrote
> On Tue, 29 Jul 2003 [EMAIL PROTECTED] wrote:
> 
> > Hi all,
> >
> > Passing arrays as parameters to a method
> > ----------------------------------------
> > Doing this C++ differs from Java. Usually in C++ we pass the size of the
> > array in another parameter so that inside the method it know the size of 
the
> > array.
> >
> > In Java this is not a problem because an Array itself is a class that has 
the
> > size. So a method in java,
> >           int EchoIntArray(int []) corresponds to int EchoArray(int [], 
int)
> > in C++.
> >
> > Suppose some one needs to write a web service for this method and the 
method
> > signature that the WSDL describes corresponds to the method signature in 
Java
> > exactly but not the C++ one.
> >
> > So how should a C++ developer implement his service corresponding to the
> > WSDL ?
> >
> > This way that we (Axis C++) asks the C++ web service developer should be
> > decided in order to improve Wrapper Class Generator (WCG) to handle 
passing
> > and returning arrays from methods.
> >
> > I find that we can give 2 solutions,
> >
> > 1. Introduce Axis C++ own Array class. So the method signature becomes
> >          int EchoIntArray(AxisArray a)
> >
> > 2. Ask the C++ developer to specify the meaning of other parameters by 
using
> > a predefined Axis C++ macro. Then the method signature becomes,
> >          int EchoIntArray(int [], ARRAYINSIZE int);
> >
> > Which is the best option to choose. IMO I like second.
> >
> > Also if you find any other solution please discuss.
> >
> > Comments on this is very much appreciated.
> 

> I suggest 1, or use std::array, simply because number 2
> seems error-prone.  Also, if you encapsulate the array in an
> object, you can add range checking.  You can
> #ifdef-out the range-checking in the release build.

I am not aware of an array class in STL. you must be refering to std::list.
Anyway we hope to allow passing most of STL types as parameters as it is. 
When we allow this anyone can pass a std::list or std::map (etc) to a method 
as parameters. Only thing is we have to improve the Wrapper Class Generator 
(WCG) to use Axis implimented Serializers and Deserializers for each of those 
STL types.

I too like if we can ask C++ web service developers to use std::list instead 
of an array. If so we (the WCG) can just forget about handling arrays. 

But usually its unlikely that a C++ developer use a std::list when he wants 
to pass an array of integers (list<int> instead of int[]) but array of 
complex types (say list<Address> instead of Address[]) is OK.

Also we can use both 1 & 2 methods.
May be 2 for simple types as int char etc and 1 for complex types ????

Susantha.

> 
> Whether to write your own or use std::array depends on a lot
> of factors.


--
Lanka Software Foundation (http://www.opensource.lk)
Promoting Open-Source Development in Sri Lanka

Reply via email to