Playing with XMString objects' guts ? - Motif

This is a discussion on Playing with XMString objects' guts ? - Motif ; Having downloaded the openmotif source, I am able to look into the code that deals with XmStrings. My goal is to provide a case insensitive compare compare or searchg (eg: strcmp or strstr in C parlance, but case insensitive). The ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Playing with XMString objects' guts ?

  1. Playing with XMString objects' guts ?

    Having downloaded the openmotif source, I am able to look into the code that
    deals with XmStrings.

    My goal is to provide a case insensitive compare compare or searchg (eg:
    strcmp or strstr in C parlance, but case insensitive).

    The overhead of just accessing the string data of an XmString seems huge
    judging by the code.

    Is it common for programmers to "hack" they way into the XmString structures
    to get greater and faster access to it, or is it really expected that all
    programmers will keep XmString totally opaque and just use the available
    routines, even if it means an extraordinary amount of overhead ?

    Also, when using routines such as XmStringGetLtoR, it is kosher to
    manipulate/write to the string that was returned ? (it *seems* to be allocated
    just for you and you have to XtFree it after you're done with it).

    (for instance, if I want to make the string all upppercase, can I just
    uppercase in situ, or must I make yert another copy of a string that has
    already been copied a few times ?)

  2. Re: Playing with XMString objects' guts ?



    JF Mezei wrote:
    >
    > Having downloaded the openmotif source, I am able to look into the code that
    > deals with XmStrings.
    >
    > My goal is to provide a case insensitive compare compare or searchg (eg:
    > strcmp or strstr in C parlance, but case insensitive).
    >
    > The overhead of just accessing the string data of an XmString seems huge
    > judging by the code.
    >
    > Is it common for programmers to "hack" they way into the XmString structures
    > to get greater and faster access to it, or is it really expected that all
    > programmers will keep XmString totally opaque and just use the available
    > routines, even if it means an extraordinary amount of overhead ?


    The problem with 'hacking' it like that is that there is no guarantee
    that the internals of an XmString will not change at some future date.
    For example, there is a huge difference in the internal structure of
    XmStrings in Motif2.x vs. Motif1.2. So your hack, if done to work with
    Motif2.1, would not be compatible with Motif1.2.

    >
    > Also, when using routines such as XmStringGetLtoR, it is kosher to
    > manipulate/write to the string that was returned ? (it *seems* to be allocated
    > just for you and you have to XtFree it after you're done with it).
    >
    > (for instance, if I want to make the string all upppercase, can I just
    > uppercase in situ, or must I make yert another copy of a string that has
    > already been copied a few times ?)


    You can treat it just as if you had created it using XtMalloc.

    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Common User Interface Services
    M/S 2R-94 (206)544-5225

+ Reply to Thread