I think it would be useful for the Foundation set of classes to have a new member designed to provide strings in a more efficient way than std::string. These strings are for construction from a long-lived buffer. For example, when one reads a record from a file and does alot of string processing on it, it would be useful if the strings used during processing where constructed from the buffer and its length. Traditionally this has been done by simply creating a new std::string from it. However, a new class could just store the buffer address and the length.This class can provide methods to split and search the string where the return values are also variables of this type. Let us refer to this new type as a string index. This makes string operations that employ a long-lived string buffer very efficient. Lots of std::string creations and copies can be very expensive for small strings. This is wasteful when such copies are copies from a buffer that is going to hang around. These string indexes have to hold a length parameter as well as a buffer pointer, so string length functions operate much faster. I think this would be a useful addition to the Foundation set of classes.
I have in mind some implementation for this but I just wanted to float the idea past initially. It would also be good to get some suggestions for what this class might be called. I want to avoid the work 'reference', since it might make people think of reference counting. So far I have come up with StringIndex and/or StringDescriptor. StringIndex is more precise than StringDescriptor since it is to due to with storing an index into the original buffer, but descriptor sounds nicer.
Any thoughts?
Andrew Marlow





