[omniORB] I'm beginner. I need help about sequence manipulation.
    Luke Deller 
    ldeller at xplantechnology.com
       
    Wed Nov  3 10:43:37 GMT 2004
    
    
  
unixwrld wrote:
> Hi, I have got my IDL file sample.idl:
>  
> interface sample {
>   typdef struct struct_SAMPLE {
>     long number;
>     char text[32];
>   } SAMPLE;
>  
>   typedef sequence<SAMPLE> SAMPLES;
>   void ShowData(out SAMPLES s);
> };
I suppose you haven't tried compiling this yet...
(1) You can't have two types which differ only in case (ie "sample" and "SAMPLE"). This is so that CORBA can support case-insensitive languages.
(2) "typdef" should be typedef.
Some stylistic points:
(3) There's no need for a typedef for the struct in this example
(4) CORBA has a type for text strings called "string".  If you want to limit the length of the string you can use for example "string<32>".  If you want to send binary data, use "octet"/"sequence<octet>" rather than "char"/"string".
I'll answer your next question assuming the following IDL:
interface foo {
    struct SAMPLE {
        long number;
        string text;
    };
    typedef sequence<SAMPLE> SAMPLES;
    void ShowData(out SAMPLES s);
};
> Now, I have got the follow prototype:
>  
> void SAMPLE::ShowData(SAMPLES_out s)
>  
> But I don't know how to alloc memory and data to "s".
Try something like this:
    s = new foo::SAMPLES();
    s->length(1)
    s[0].number = 42;
    s[0].text = CORBA::string_dup("foo");
Information like this can be found in the C++ language mapping specification found here:
    http://www.omg.org/technology/documents/formal/c++.htm
Language-neutral information about CORBA and IDL can be found in the CORBA spec here:
    http://www.omg.org/technology/documents/formal/corba_iiop.htm
Also, if you're learning CORBA, there's a book by Henning & Vinoski called "Advanced CORBA Programming with C++" which is pretty much the standard textbook in this area:
    http://www.awprofessional.com/title/0201379279
Regards,
Luke.
    
    
More information about the omniORB-list
mailing list