[prev in list] [next in list] [prev in thread] [next in thread] 

List:       omniorb-list
Subject:    Re: [omniORB] Resizing a string sequence
From:       baileyk () schneider ! com
Date:       2003-11-25 17:29:37
[Download RAW message or body]


Now that I understand the method is a remote one, and it's clear you don't
care what the contents of the sequence are at the beginning of the call, I
think the canonical way to implement your requirements are

// in the idl
      attribute_list return_attributes();

// in the C++ code
      attribute_list* return_attributes()
      {
            attribute_list_var a_l( new attribute_list );
            a_l->length( /* whatever it should be */ );
            for( unsigned i = 0; i < a_l->length(); ++i )
            {
                  a_l[i] = CORBA::string_dup( /* whatever */ );
            }
            return a_l._retn();
      }

Notice the use of a _var type for exception safety, and the use of the
operator[] call on the var type, which is available for cleaner looking
syntax.

For the most part, you can treat T_out types as if they are T* types.  I
usually create a T_var to hold the value and then just before returning I
assign the value of _retn() to the T_out parameter, like so

// in the idl
      void return_attributes(out attribute_list alist );

// in the C++ code
      void return_attributes(attribute_list_out alist)
      {
            attribute_list_var a_l( new attribute_list );
            a_l->length( /* whatever it should be */ );
            for( unsigned i = 0; i < a_l->length(); ++i )
            {
                  a_l[i] = CORBA::string_dup( /* whatever */ );
            }
            alist = a_l._retn();
            return;
      }

hope this helps.

Kendall



                                                                                      \
                
                      Johan Cronje                                                    \
                
                      <jcronje@dsp.sun.        To:       Gary Duzan <gduzan@bbn.com>, \
                baileyk@schneider.com, Duncan Grisby     
                      ac.za>                    <duncan@grisby.org>                   \
                
                                               cc:       \
                omniorb-list@omniorb-support.com                                      \
                
                      11/25/2003 05:00         Fax to:                                \
                
                      AM                       Subject:  Re: [omniORB] Resizing a \
                string sequence                              
                                                                                      \
                
                                                                                      \





-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 25 November 2003 02:57, Johan Cronje wrote:
> attribute_list* return_attributes()
> to
> void return_attributes(out attribute_list a_l)

This is now:

   void return_attributes(inout attribute_list a_l);

Last night, for some reason (it can be I overlooked it) it generated the
"attribute_list_out" class regardless of whether I used out or inout for
the
attribute_list. Now it generated

   void return_attributes(attribute_list& a_l)

which is what I expected.

> ... It is, however, very late over here and I will continue this conquest
at
> a later stage in the day.

> I am very grateful for all the help you give me. I do feel however that
at
> this moment I must first go get some rest as I feel that the answer is
> staring me in the face but I'm way too tired to see it.

How true... after implementing above method, everything is now A-OK.

Thank you again Gary, Kendall and Duncan.

Best Regards
Johan
- --
"There is beauty in simplicity"                        -- Johan Cronje
- ---------------------------------------------------------------
Johan Cronje
Digital Signal Processing / Telecommunications Group
Electrical and Electronic Engineering Department
University of Stellenbosch
http://www.dsp.sun.ac.za/~jcronje
- ---------------------------------------------------------------
GNUPG Key: http://www.dsp.sun.ac.za/~jcronje/jcronje.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)

iQEVAwUBP8M2ReEeclgONaRbAQLLBgf/XQBTulrZTGlcYNJQ8BC9wKq452rABH7h
B2omUT7C/zgP6tXKMo0w/CCjyYpQbzynZYXb5CEzPlZnn50OskIcMJsoOXHmpdSA
MQwLtlFJu3/WzMtnJ7nN7BqckJ3CavDNf3aDfIhNtt3tVE7bw/Jv5BxAnJ1o5aGH
N/isuRSE03px51er3PnZ6uvXD84TVJMtfLr1xgUATn4ZbJ6yCcOcyGwI9TUrED5K
lK/ieE07vF6JPvySemR7iGGSZxqzTlD78yRGrqoBX3fCv7pVLv9Qch6xJoOEx01G
GPKHS9/zQ36I1WivFH6g69kNfO3x1kSK0gH/f5VqBx4cQtkIb0s43Q==
=S0y/
-----END PGP SIGNATURE-----







_______________________________________________
omniORB-list mailing list
omniORB-list@omniorb-support.com
http://www.omniorb-support.com/mailman/listinfo/omniorb-list


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic