10
edits
m (→Data access: fix typo) |
(→Additional String methods: Change getIndependentString() to fixDependentString(), to match the code) |
||
| (One intermediate revision by the same user not shown) | |||
| Line 86: | Line 86: | ||
if (xml->isAttr) | if (xml->isAttr) | ||
name = name->appendLatin1("@"); | name = name->appendLatin1("@"); | ||
name = name-> | name = name->append(xml->getName()); | ||
} else { | } else { | ||
name = xml->getName(); | name = xml->getName(); | ||
| 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