"~username") or an shell environment variable (
"$VARIABLE"). Also provided is a function for verifying that an external program to be invoked is available, and a function for searching the user's path.
Two classes are provided for manipulating
StringList, these classes are summarized in figure
Although these two classes are almost identical in design, their recommended uses are quite different. The first is designed for building up strings without having to be concerned about the ultimate size of the string. New characters can be appended to the string at any time, and memory will be allocated to accommodate them. When you are ready to use the string, perhaps by passing it to a function that expects the standard character array representation of the string, then simply cast the object to
InfString is publicly derived from
StringList, adding only the cast to
StringList is implemented as a list of strings, where the size of the list is not bounded ahead of time.
StringList is recommended for applications where the list structure is to be preserved. The cast to
InfString destroys the list structure, consolidating all its strings into one contiguous string.
InfString differs by only one operator, we show only that one operator.
InfString, and that value is not assigned to a
InfString variable or reference, and the
(const char*) or
(char*) cast is used, it is possible (likely under g++) that the
InfString temporary will be destroyed too soon, leaving the
const char* or
char* pointer pointing to garbage. The solution is to assign the returned value to a local
InfString before performing the cast. Suppose, for example, that the function
foo returns an
InfString. Further, suppose the function
bar takes a
char* argument. Then the following code will fail:
char* is implicit). The following code will succeed: