CStringData Class

This class represents the data of a string object.

struct CStringData

Members

Methods

AddRef

Increments the reference count of the string data object.

data

Retrieves the character data of a string object.

IsLocked

Determines if the buffer of the associated string object is locked.

IsShared

Determines if the buffer of the associated string object is currently shared.

Lock

Locks the buffer of the associated string object.

Release

Releases the specified string object.

Unlock

Unlocks the buffer of the associated string object.

Data Members

nAllocLength

Length of allocated data in XCHARs (not including terminating null)

nDataLength

Length of currently used data in XCHARs (not including terminating null)

nRefs

The current reference count of the object.

pStringMgr

A pointer to the string manager of this string object.

Remarks

This class should only be used by developers implementing custom string managers. For more information on custom string managers, see Memory Management and CStringT

This class encapsulates various types of information and data associated with a higher string object, such as CStringT, CSimpleStringT, or CFixedStringT objects. Every higher string object contains a pointer to its associated CStringData object, allowing multiple string objects to point to the same string data object. This relationship is represented by the reference count (nRefs) of the CStringData object.

Note

In certain cases, a string type (such as CFixedString) will not share a string data object with more than one higher string object. For more information on this, see Memory Management and CStringT.

This data is composed of:

  • The memory manager (of type IAtlStringMgr) of the string.

  • The current length (nDataLength) of the string.

  • The allocated length (nAllocLength) of the string. For performance reasons, this can differ from the current string length

  • The current reference count (nRefs) of the CStringData object. This value is used in determining how many string objects are sharing the same CStringData object.

  • The actual character buffer (data) of the string.

    Note

    The actual character buffer of the string object is allocated by the string manager and is appended to the CStringData object.

Requirements

Header: atlsimpstr.h

See Also

Reference

Hierarchy Chart

Other Resources

ATL/MFC Shared Classes