Share via


ReadValueChunk (Compact 7)

3/12/2014

This method will read up to a maximum of the specified chunk size (as available) from the value of the current node and copy the value into the specified buffer.

Syntax

HRESULT ReadValueChunk (
    WCHAR* pBuffer, 
    UINT cwhChunkSize, 
    UINT* pcwchRead
);

Arguments

  • pBuffer
    [in] You must pass in a buffer that is at least cwhChunkSize characters long. The value of the token will be read into the buffer.
  • cwhChunkSize
    [in] The chunk size required, in characters. Any value from 0 to 4GB is valid.
  • pcwchRead
    [out] The size of the string read. This argument cannot be NULL.

Return Value

This interface returns S_OK if no error is generated and returns S_FALSE if no more content is available to be read.

Remarks

The size of the buffer should be greater than or equal to that of the specified chunk size.

If the remaining value is shorter than the required chunk size, the method will return only the remaining value and notify the call through the pcwchRead argument of its size.

This method will not span a surrogate pair. When the number of characters requested would split a surrogate pair, this method returns one less WCHAR than the number that was requested.

The following code reads a chunk of a value:

while (TRUE)
{
    hr = pReader->ReadValueChunk(buff, buffSize - 1, &charsRead);
    if (S_FALSE == hr || 0 == charsRead)
        break;
    if (S_OK != hr)
    {
        wprintf(L"\nXmlLite Error: %08.8lx\n", hr);
        return -1;
    }
    buff[charsRead] = L'\0';
    dotWhiteSpace(buff, charsRead);
    wprintf(L"attribute chunk size:%d >%s<\n", charsRead, buff);
}

See Also

Reference

IXmlReader Methods
Read
GetValue
IXmlReader Properties
Error Codes