DOM StringRef: Difference between revisions

From COLLADA Public Wiki
Jump to navigation Jump to search
Elf (talk | contribs)
m tutorial -> navigation
Elf (talk | contribs)
m fmt
Line 1: Line 1:
Internal notes on '''StringRef'''.
'''Summary:'''Internal notes on <code>StringRef</code>.


'''StringRef''' is barely used as a type. It is used mainly in a side-effect programming style when dealing with '''daeString''' types.
<code>StringRef</code> is barely used as a type. It is used mainly in a side-effect programming style when dealing with <code>daeString</code> 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'''.
It is used for all string array types, that is, <code>xsNameArray</code>, <code>xsTokenArray</code>, <code>xsNCNameArray</code>, even though the single versions of those types are just <code>daeString</code>.


'''daeStringTable''' is used to manage string memory.
<code>daeStringTable</code> is used to manage string memory.


The common functionality for '''daeStringRef''' is to do something like:
The common functionality for <code>daeStringRef</code> is to do something like:
  *(daeStringRef*)&attrMaterial = atMaterial;
  *(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 side effect of casting a <code>daeString</code> to a <code>daeStringRef</code> is that the operator= of <code>daeStringRef</code> gets called instead of a pointer copy.


The operator= calls '''daeStringTable::allocateString''', which allocates memory for the string.
The operator= calls <code>daeStringTable::allocateString</code>, 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.''
'''''NOTE for future:''' <code>daeStringTable</code> should be made to reuse string memory, but currently allocates new memory for each and every string.''


{{DOM navigation}}
{{DOM navigation}}


[[Category:DOM subsystems|StringRef]]
[[Category:DOM subsystems|StringRef]]

Revision as of 05:25, 23 May 2007

Summary: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.


COLLADA DOM - Version 2.4 Historical Reference
List of main articles under the DOM portal.
User Guide chapters:  • Intro  • Architecture  • Setting up  • Working with documents  • Creating docs  • Importing docs  • Representing elements  • Working with elements  • Resolving URIs  • Resolving SIDs  • Using custom COLLADA data  • Integration templates  • Error handling

Systems:  • URI resolver  • Meta  • Load/save flow  • Runtime database  • Memory • StringRef  • Code generator
Additional information:  • What's new  • Backward compatibility  • Future work
Terminology categories:  • COLLADA  • DOM  • XML