On May 23, 2012, at 12:23 PM, Tom Browder <[email protected]> wrote:

I see no function to deal with changing individual bu_vls characters.
Have I just missed them or should I just access the bu_vls string
directly?

It's easy enough and common in the code to just directly access the string.  Example:

int main(int ac, char *av[]) {
    int i;
    struct bu_vls vls = BU_VLS_INIT_ZERO;
    bu_vls_printf(&vls, "hello");

    for (i=0; i < bu_vls_strlen(&vls); i++) {
        printf("The %d char is [%c]\n", i, bu_vls_addr(&vls)[i]);
        bu_vls_addr(&vls)[i] += 4;
    }
    for (i=0; i < bu_vls_strlen(&vls); i++) {
        printf("The %d char is [%c]\n", i, bu_vls_addr(&vls)[i]);
    }

    return 0;
}

Maybe we need a function like bu_vls_readc (for reading) and
bu_vls_exchc (for substituting).

The VLS interface intentionally tries to mirror libc as much as possible, treating the vls buffer both as a stream (ala FILE*) and a string (ala char*).  In that light, the function that pairs with the existing bu_vls_putc() call would be a bu_vls_getc() call.  There's no pairing for replacing characters in libc (unless you count strtok() or strchr()) since you usually just index into the string and modify.

Cheers!
Sean


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
BRL-CAD Developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-devel

Reply via email to