DOM StringRef: Difference between revisions
copy in Andy's text from word doc |
{{DOM tutorial}} |
||
Line 14: | Line 14: | ||
'''''NOTE for future:''' '''daeStringTable''' should be made to reuse string memory, but currently allocates new memory for each and every string.'' | '''''NOTE for future:''' '''daeStringTable''' should be made to reuse string memory, but currently allocates new memory for each and every string.'' | ||
{{DOM tutorial}} | |||
[[Category:DOM project|StringRef]] | [[Category:DOM project|StringRef]] |
Revision as of 21:04, 6 April 2007
Internal notes on StringRef.
StringRef is barely used as a type. It is used mainly in a side-effect programming style when dealing with daeString types.
It is used for all string array types, that is, xsNameArray, xsTokenArray, xsNCNameArray, even though the single versions of those types are just daeString.
daeStringTable is used to manage string memory.
The common functionality for daeStringRef is to do something like:
*(daeStringRef*)&attrMaterial = atMaterial;
The side effect of casting a daeString to a daeStringRef is that the operator= of daeStringRef gets called instead of a pointer copy.
The operator= calls daeStringTable::allocateString, which allocates memory for the string.
NOTE for future: daeStringTable should be made to reuse string memory, but currently allocates new memory for each and every string.