Home Help Center

returning **char from server

ramayanaramayana Member Stanislaw ArtymowskiOrganization: Instytut Monitorowania MediówProject: Testing and learning ICE
Hi,
I would like to return **char from serwer. I know there is sequence but i don't know how to make that function will return **char by sequence. I could do that:

sequence<string> tab;
sequence<tab> tab1;

but then i returning vector of vectors of string.
I have to return **char so i could HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values) postgresql function.

Thanks for any help and suggestions.

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    I'm afraid this isn't possible, you can't map strings to char*. You'll need to build an intermediary array to pass your data as char** to the PostgrelSQL function.

    Cheers,
    Benoit.
  • ramayanaramayana Member Stanislaw ArtymowskiOrganization: Instytut Monitorowania MediówProject: Testing and learning ICE
    I know that is not the best way to do that, but the question is what is the best way to return **char?
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Sorry, it's not clear to me what you're asking. You won't be able to return a char** from an Ice operation, this isn't supported. Could you detail what you're trying to achieve by posting a code sample for example?

    Cheers,
    Benoit.
  • ramayanaramayana Member Stanislaw ArtymowskiOrganization: Instytut Monitorowania MediówProject: Testing and learning ICE
    I use some some function on server side, which take i.e. void* temp; and it fill temp with data, then i must copy each variable from out to char** value and then return value. So i created vector<vector<string> > tempString instead char** value and return to client tempString, but is there other solution to return char**to client? Meybe something faster than vector<vector<string> >?
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    As mentioned in my previous posts, no it's not possible to return a char** from a Ice invocation or servant method.

    You will need to convert your char** to an appropriate Slice defined sequence. A char** can probably either be mapped to a slice "sequence<string>" or "sequence<Ice::ByteSeq>" depending on whether or not the data contains strings or raw data (Ice::ByteSeq is defined in slice/Ice/BuiltinSequences.ice as a sequence<byte>).

    Cheers,
    Benoit.
  • ramayanaramayana Member Stanislaw ArtymowskiOrganization: Instytut Monitorowania MediówProject: Testing and learning ICE
    Thanks benoit,

    that why i have
    sequence<string> tab;
    sequence<tab> tab1;
    

    in my .ice file, and it's working, but i thought there is better solution to do that.

    If i would use Ice::Byte it will be faster, or generaly better that sequence<string>?
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    It depends on the language, in C++, marshaling a string is as efficient as marshaling a byte sequence (if no string convert is installed). In some other languages (such as Java), it requires additional overhead to convert the native Java string to UTF8... but in general you don't really have choice: you should use a sequence of bytes if your data is binary data and string if your data is string data :).

    Cheers,
    Benoit.
  • ramayanaramayana Member Stanislaw ArtymowskiOrganization: Instytut Monitorowania MediówProject: Testing and learning ICE
    Well, this explains everything, thanks a lot Benoit, like always :)
Sign In or Register to comment.