0

I got a problem with array and object in IDL corba This is my code:

    interface ISinhVien
{
    SinhVien[] DocFile(in String filename);
    void GhiFile(in SinhVien[] sv,in String filename);
};

And error when I compile it:

CORBA_SinhVien>idlj -fall SinhVienIDL.idl
SinhVienIDL.idl (line 3):  SinhVien is an undeclared type.
        SinhVien[] DocFile(in String filename);
         ^
SinhVienIDL.idl (line 3):  Expected `<identifier>'; encountered `['.
        SinhVien[] DocFile(in String filename);
         ^
SinhVienIDL.idl (line 3):  WARNING: Identifier `String' collides with a keyword;
 use an escaped identifier to ensure future compatibility.
        SinhVien[] DocFile(in String filename);
                       ^
SinhVienIDL.idl (line 4):  SinhVien is an undeclared type.
        void GhiFile(in SinhVien[] sv,in String filename);
                         ^
SinhVienIDL.idl (line 4):  Expected `<identifier>'; encountered `['.
        void GhiFile(in SinhVien[] sv,in String filename);
                         ^
SinhVienIDL.idl (line 4):  WARNING: Identifier `String' collides with a keyword;
 use an escaped identifier to ensure future compatibility.
        void GhiFile(in SinhVien[] sv,in String filename);

Somebody help me, please !!!!!!!!!!!!!!!!!!!!

1 Answers1

1

The CORBA language specification does not allow the arrays of any type to be returned unless they are first typedefed.

You have 2 options available here - fixed arrays or sequences - the latter is more flexible, allowing for the array size to be set by the implementing code.

interface SinhVien {
  boolean someOperation(in long id);
  // more operations
};

typedef sequence<SinhVien> sinhviens;


interface ISinhVien
{
    sinhviens docFile(in string filename);
    void ghiFile(in sinhviens sv, in string filename);
};

Aside: Be careful not to mix Java syntax with IDL syntax: string appears as all lowercase.

Reimeus
  • 158,255
  • 15
  • 216
  • 276
  • I edit code follow your help! this my code is edited: typedef sequence sinhviens; interface ISinhVien { sinhviens DocFile(in string filename); void GhiFile(in sinhviens sv,in string filename); } but got error : SinhVienIDL.idl (line 1): SinhVien is an undeclared type. typedef sequence sinhviens; help me,please!! – Nguyễn Quang Minh Tuấn Apr 23 '13 at 15:21
  • As the error says you need to define the type `SinhVien`. This can either be an `interface` or a `struct`. You can do this in the same IDL file or using a `#include` directive – Reimeus Apr 23 '13 at 17:03
  • you can explain detail for me? I am new beginning – Nguyễn Quang Minh Tuấn Apr 23 '13 at 17:13
  • As already stated, you need to define the `SinhVien` type before it can be used. Read this [tutorial](http://documentation.progress.com/output/Iona/orbix/gen3/33/html/orbix33java_pguide/IDL.html) – Reimeus Apr 23 '13 at 17:59