Public Member Functions | |
this (IBuffer buffer, uint contentLength, UConverter cvt) | |
void | read (IReader r) |
StringDecoder | createDecoder (UConverter c, uint bytes) |
Definition at line 221 of file UString.d.
|
Another constructor for loading known content length into a UString. Definition at line 271 of file UString.d. References UString::VersionMango::UStringDecoder::load(). |
|
Read as many bytes from the input as is necessary to produce the expected number of wchar elements. This uses the default wchar handler, which can be altered by binding a StringDecoder to the IReader in use (see UMango for details). We're mutable, so ensure we don't mess with the IO buffers. Interestingly, changing the length of a D array will account for slice assignments (it checks the pointer to see if it's a starting point in the pool). Unfortunately, that doesn't catch the case where a slice starts at offset 0, which is where IBuffer slices may come from. To be safe, we ask the allocator in use whether the content it provided can be mutated or not. Note that this is not necessary for UText, since that is a read-only construct. Definition at line 301 of file UString.d. References IReader::get, IReader::getAllocator(), and IArrayAllocator::isMutable(). |
|
Return a streaming decoder that can be used to populate this UString with a specified number of input bytes. This differs from the above read() method in the way content is read: in the above case, exactly the specified number of wchar elements will be converter from the input, whereas in this case a variable number of wchar elements are converted until 'bytes' have been read from the input. This is useful in those cases where the original number of elements has been lost, and only the resultant converted byte-count remains (a la HTTP). The returned StringDecoder is one-shot only. You may reuse it (both the converter and the byte count) via its reset() method. One applies the resultant converter directly with an IReader like so:
which will read the specified number of bytes from the input and convert them to an appropriate number of wchars within the UString. |