This is the multi-page printable view of this section. Click here to print...

Return to the regular view of this page

As of 2025-07-24

smplbuf_strm_u8

Type that allows direct use of stream methods
    The smplbuf_strm_u8??? type for uint8_t also implements the stream interface, allowing use of several stream-related methods.
    // smplbuf_strm_u8<N> : local allocation
    template <int N> using smplbuf_strm_u8
      = _smplbuf_stream<uint8_t, mwx::alloc_local<uint8_t, N>>;
    
    // smplbuf_strm_u8_attach : attaches to existing buffer
    using smplbuf_strm_u8_attach
      = mwx::_smplbuf_stream<uint8_t, mwx::alloc_attach<uint8_t>>;
    
    // smplbuf_strm_u8_heap : heap allocation
    using smplbuf_strm_u8_heap
      = mwx::_smplbuf_stream<uint8_t, mwx::alloc_heap<uint8_t>>;
    
    // Definition of << operator
    template <class L_STRM, class ALOC>
    mwx::stream<L_STRM>& operator << (
            mwx::stream<L_STRM>& lhs,
            mwx::_smplbuf_stream<uint8_t, ALOC>& rhs)
    {
    		lhs << rhs.to_stream();
    		return lhs;
    }

    Example

    smplbuf_strm_u8<128> sb1;
    
    sb1 << "hello";
    sb1 << uint32_t(0x30313233);
    sb1 << format("world%d",99);
    sb1.printfmt("Z!");
    
    Serial << sb1;
    // hello0123world99Z!