[omniORB] Getting sequence type to C++ vector

Stefan Naewe stefan.naewe at atlas-elektronik.com
Fri Oct 5 10:53:11 BST 2007


On 10/5/2007 6:52 AM, janarbek wrote:
> *Dear all,*
> ** 
> *As I mentioned in my previous post I want to get the sequence <short>
> type in my IDL to the vector in my C++ code.*
>  
> typedef sequence<short> seqShort;
> interface shortSeqTestServer {
>   void setSize(inout short size);
>   void acceptType(inout seqShort value);
>   seqShort returnType();
> };
>  
> Then in C++,
>  
>  vector<CORBA::Short> testPattern;
>  testPattern.resize(dummy, (short)5);
>  
>  testPattern = (myObject->returnType());
>  
>  
> *Is this possible?*

I'd say: not without a copy:

// Untested!!

    seqShort* s = myObject->returnType();

    CORBA::Short* first = s->get_buffer();
    CORBA::Short* last  = first + s->length();
    std::vector<CORBA::Short> testPattern(first, last);


Regards,
     Stefan
-- 
----------------------------------------------------------------------
Dipl.-Inform. Stefan Naewe                       ATLAS Elektronik GmbH
                                                         Dept.: NUS T4
phone: +49-(0)421-457-1378                Sebaldsbruecker Heerstr. 235
fax:   +49-(0)421-457-3913                                28305 Bremen



More information about the omniORB-list mailing list