Home Help Center

is there any way to use my own struct in slice?

pi1otpi1ot Member pi1otOrganization: SINA.comProject: WEB
such as:

struct my_own_struct{
int x;
string y;
my_another_class z;
};

i must define ice_my_own_struct and ice_my_another_class in slice and write two function to translate them in my code now:

my_client( my_own_struct m ){
ice_interface( my_to_ice(m) );
}

ice_interface( ice_my_own_struct i ){
my_server_code( ice_to_mine(i) );
}

is there any way to avoid these "excrescent" code?
thanks.

Comments

  • matthewmatthew NL, CanadaMember Matthew NewhookOrganization: ZeroC, Inc.Project: Internet Communications Engine ✭✭✭
    pi1ot wrote:
    such as:

    struct my_own_struct{
    int x;
    string y;
    my_another_class z;
    };

    i must define ice_my_own_struct and ice_my_another_class in slice and write two function to translate them in my code now:

    my_client( my_own_struct m ){
    ice_interface( my_to_ice(m) );
    }

    ice_interface( ice_my_own_struct i ){
    my_server_code( ice_to_mine(i) );
    }

    is there any way to avoid these "excrescent" code?
    thanks.

    The best way is to avoid doing this, by defining these structs and classes in Slice in the first place. However, this isn't always possible -- particularly when integrating with legacy software. In these cases, you must define some translation layer, as you've done above.

    Regards, Matthew
Sign In or Register to comment.