Archived

This forum has been archived. Please start a new discussion on GitHub.

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

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

  • matthew
    matthew NL, Canada
    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