Archived

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

returning **char from server

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

  • benoit
    benoit Rennes, France
    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.
  • I know that is not the best way to do that, but the question is what is the best way to return **char?
  • benoit
    benoit Rennes, France
    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.
  • 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> >?
  • benoit
    benoit Rennes, France
    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.
  • 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>?
  • benoit
    benoit Rennes, France
    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.
  • Well, this explains everything, thanks a lot Benoit, like always :)