Skip to content

Latest commit

 

History

History
53 lines (34 loc) · 1.94 KB

4.1-4.2.rst

File metadata and controls

53 lines (34 loc) · 1.94 KB

From v4.1 to v4.2

Summary

Stream methods

The :cpp:func:`Stream::readBytes` has been virtualised and overridden for :cpp:class:`IDataSourceStream` descendents for more efficient operation, especially with ArduinoJson. For normal read operations where the stream position is to be updated, applications should use this method in preference to :cpp:func:`IDataSourceStream::readMemoryBlock`.

An addition method :cpp:func:`IDataSourceStream::moveString` has been added to support extracting the content of a memory-based stream into a String object without duplicating the data. This is supported by :cpp:class:`LimitedMemoryStream` and :cpp:class:`MemoryDataStream`.

Stream / file seeking

To provide a consistent interface :cpp:type:`SeekOrigin` is now used with all seek methods for streams, and also by file system functions. Mappings are:

SeekOrigin::Start instead of eSO_FileStart
SeekOrigin::Current instead of eSO_CurrentPos
SeekOrigin::End instead of eSO_FileEnd

These map to the standard C SEEK_SET, SEEK_CUR and SEEK_END but as SeekOrigin is strongly typed it offers compile-time checking, and has a toString(SeekOrigin) overload.

getBody methods

The :cpp:func:`HttpRequest::getBody` and :cpp:func:`HttpResponse::getBody` methods have been revised to use move semantics. Previously, the data was copied into a new String which effectively doubled memory usage.

If you have set a non-memory stream type (e.g. :cpp:class:`FileStream`) which does not implement :cpp:func:`IDataSourceStream::moveString()` then an invalid String will be returned. In this situation you should use :cpp:func:`HttpResponse::getBodyStream` instead.

ContentType / MIME types

:cpp:func:`String toString(MimeType)` has been moved out of the ContentType namespace, so no longer requires the ContentType:: qualifier.