10
edits
m (→Appending data: fix typo) |
(→Additional String methods: Change getIndependentString() to fixDependentString(), to match the code) |
||
Line 102: | Line 102: | ||
if (s->indexOfLatin1(":")) < 0) ... | if (s->indexOfLatin1(":")) < 0) ... | ||
The <tt> | The <tt>fixDependentString()</tt> function converts a substring to a normal string. This is handy if the string needs to live for a long time, but if you do not want the master of a dependent substring to live for that long. | ||
Example: | Example: | ||
Line 108: | Line 108: | ||
Stringp xml = parseVeryLargeXMLFile(); | Stringp xml = parseVeryLargeXMLFile(); | ||
Stringp start = xml->substr (0, 3); | Stringp start = xml->substr (0, 3); | ||
// if start was to be stored anywhere, the entire, | // if start was to be stored anywhere, the entire, huge XML string would remain alive | ||
// unless | // unless fixDependentString was called | ||
start->fixDependentString(); | |||
The <tt>makeDynamic()</tt> converts a string with a static buffer, or a string that is a substring to a string with a dynamic buffer. | The <tt>makeDynamic()</tt> function converts a string with a static buffer, or a string that is a substring to a string with a dynamic buffer. |
edits