[omniORB] Looking for examples of sequence manipulation
Carlos
carlos at canama.net
Thu Mar 29 02:03:39 BST 2007
El mié, 28-03-2007 a las 10:48 -0700, Perham, David A. (Mission Systems)
escribió:
> Howdy:
>
> Looking for tips on how to manipulate sequences I came across this
> example in the mailing list archives.
> The example demonstrates how to create the sequence in idl, and how to
> pass a pointer to the sequence in the implementation code.
> Unfortunately, it does not show the syntax required to access this
> pointer within the implementation after it is created. In other
> words, after
>
> ptx = new MyInterface::randSeq(len,len,p);
>
> I'd like to do something with the sequence, like assign a value to
> something within it.
> For example if I have declared a sequence like this in IDL
> Typedef struct theStruct
> {
> short x ;
> short y ;
> } theStructType ;
> Typedef sequence <theStructType> theStructSeq ;
> Boolean DoSomethingWithTheStructSeq( out theStructSeq myStructSeq) ;
>
> And the implementation has
> Bool DoSomethingWithTheStructSeq( theStructSeq_out ss )
> {
> theStructSeq *& ptx = ss.ptr() ;
> ptx = new theStructSeq(3) ;
>
> }
>
> What is the syntax to assign a value to 'x' within an element of the
> sequence?
(*ptx)[0].x = 29;
for example
and if you want to populate all the sequence
for (CORBA::ULong i = 0; i < ptx->length(); i++) {
(*ptx)[i].x = ...;
(*ptx)[i].y = ...;
}
I expect this helps you.
Cheers.
> Thanks,
> Dave P
> > Howdy,
> > Hope the following sample helps you.
> >
> > IDL: > interface MyInterface
> > {
> > typedef sequence<octet> randSeq;
> > void getRandSeq( out randSeq tx );
> > }
> >
> > Object Implementation:
> > void MyInterface_i::getRandSeq( randSeq_out tx )
> > {
> > MyInterface::randSeq*& ptx = tx.ptr();
> > //.... > CORBA::Octet* p = new CORBA::Octet[ len ];
> > //....
> > ptx = new MyInterface::randSeq(len,len,p);
> > }
> >
> > Client: > void hello( MyInterface_ptr e )
> > {
> > MyInterface::randSeq_var tx;
> > e->getRandSeq( tx.out() );
> > long len = tx.length();
> > for ( i = 0; i < len; i++ )
> > {
> > cout << tx[i] << endl; // access
> > }
> > }
>
> _______________________________________________
> omniORB-list mailing list
> omniORB-list at omniorb-support.com
> http://www.omniorb-support.com/mailman/listinfo/omniorb-list
More information about the omniORB-list
mailing list