Logo Search packages:      
Sourcecode: xulrunner version File versions

void nsStringBuffer::ToString ( PRUint32  len,
nsAString str 

The ToString methods assign this string buffer to a given string object. If the string object does not support sharable string buffers, then its value will be set to a copy of the given string buffer. Otherwise, these methods increment the reference count of the given string buffer. It is important to specify the length (in storage units) of the string contained in the string buffer since the length of the string may be less than its storage size. The string must have a null terminator at the offset specified by |len|.

NOTE: storage size is measured in bytes even for wide strings; however, string length is always measured in storage units (2-byte units for wide strings).

Definition at line 279 of file nsSubstring.cpp.

References AddRef(), and Data().

    PRUnichar* data = static_cast<PRUnichar*>(Data());

    nsAStringAccessor* accessor = static_cast<nsAStringAccessor*>(&str);
    if (accessor->vtable() != nsObsoleteAString::sCanonicalVTable)
        str.Assign(data, len);
    NS_ASSERTION(data[len] == PRUnichar(0), "data should be null terminated");

    // preserve class flags
    PRUint32 flags = accessor->flags();
    flags = (flags & 0xFFFF0000) | nsSubstring::F_SHARED | nsSubstring::F_TERMINATED;

    accessor->set(data, len, flags);

Generated by  Doxygen 1.6.0   Back to index