uTL
micro Template library
utl::ostream_dev< impl_t, data_t > Class Template Reference

Abstract base classes for output stream devices. More...

#include <ostream_dev.h>

Public Types

using type = ostream_dev_t
 Export type as identity meta-function. More...
 
using data_type = data_t
 
using pointer_type = data_t *
 

Public Member Functions

Common output device interface
size_t put (const data_t &data)
 Put interface. This function should send a single data_t object to device. More...
 
size_t put (const data_t *data, size_t n)
 Put interface. This function should send a stream of data_t objects to device. More...
 
Stream operator << interface
template<typename _Src_t >
ostream_dev_toperator<< (const _Src_t &src)
 Template operator<< implementation for for all by value/ref parameters. More...
 
template<typename _Src_t >
ostream_dev_toperator<< (_Src_t *src)=delete
 Overload to disallow pointer types as source. More...
 
ostream_dev_toperator<< (const data_t &src)
 Overload for single data_t object. More...
 
iterator end () noexcept
 
const_iterator end () const noexcept
 
const_iterator cend () const noexcept
 

Protected Member Functions

Constructor / Destructor
 ~ostream_dev ()=default
 Allow destructor from derived only. More...
 
 ostream_dev ()=default
 A default constructor from derived only. More...
 
 ostream_dev (const ostream_dev_t &)=delete
 No copies. More...
 
ostream_dev_toperator= (const ostream_dev_t &)=delete
 

Private Types

using ostream_dev_t = ostream_dev< impl_t, data_t >
 class type syntactic sugar More...
 

Private Member Functions

 _CRTP_IMPL (impl_t)
 
Common output device interface requirements
size_t put_ (const data_t &data)
 
size_t put_ (const data_t *data, size_t n)
 

STL-like Output iterator interface

using iterator = ostreamdev_it< ostream_dev_t, data_t >
 Iterator. More...
 
using const_iterator = ostreamdev_it< const ostream_dev_t, data_t >
 Const iterator. More...
 
iterator begin () noexcept
 .begin implementation More...
 
const_iterator begin () const noexcept
 
const_iterator cbegin () const noexcept
 

Detailed Description

template<typename impl_t, typename data_t>
class utl::ostream_dev< impl_t, data_t >

Abstract base classes for output stream devices.

Template base class for output stream devices using CRTP

This class force a common interface for output stream devices. By using this common interface the class implements

  • Stream-like inserting operator
  • Output iterator
  • Const output iterator to inherit to implementation.
Parameters
impl_tThe CRTP type (the derived/implementation class typename).
data_tThe devices base type of data

Definition at line 52 of file ostream_dev.h.

Member Typedef Documentation

◆ const_iterator

template<typename impl_t , typename data_t >
using utl::ostream_dev< impl_t, data_t >::const_iterator = ostreamdev_it <const ostream_dev_t, data_t>

Const iterator.

Definition at line 151 of file ostream_dev.h.

◆ data_type

template<typename impl_t , typename data_t >
using utl::ostream_dev< impl_t, data_t >::data_type = data_t

Export types as output device concept demands

Definition at line 59 of file ostream_dev.h.

◆ iterator

template<typename impl_t , typename data_t >
using utl::ostream_dev< impl_t, data_t >::iterator = ostreamdev_it <ostream_dev_t, data_t>

Iterator.

Definition at line 150 of file ostream_dev.h.

◆ ostream_dev_t

template<typename impl_t , typename data_t >
using utl::ostream_dev< impl_t, data_t >::ostream_dev_t = ostream_dev <impl_t, data_t>
private

class type syntactic sugar

Definition at line 54 of file ostream_dev.h.

◆ pointer_type

template<typename impl_t , typename data_t >
using utl::ostream_dev< impl_t, data_t >::pointer_type = data_t*

Definition at line 60 of file ostream_dev.h.

◆ type

template<typename impl_t , typename data_t >
using utl::ostream_dev< impl_t, data_t >::type = ostream_dev_t

Export type as identity meta-function.

Definition at line 62 of file ostream_dev.h.

Constructor & Destructor Documentation

◆ ~ostream_dev()

template<typename impl_t , typename data_t >
utl::ostream_dev< impl_t, data_t >::~ostream_dev ( )
protecteddefault

Allow destructor from derived only.

◆ ostream_dev() [1/2]

template<typename impl_t , typename data_t >
utl::ostream_dev< impl_t, data_t >::ostream_dev ( )
protecteddefault

A default constructor from derived only.

◆ ostream_dev() [2/2]

template<typename impl_t , typename data_t >
utl::ostream_dev< impl_t, data_t >::ostream_dev ( const ostream_dev_t )
protecteddelete

No copies.

Member Function Documentation

◆ _CRTP_IMPL()

template<typename impl_t , typename data_t >
utl::ostream_dev< impl_t, data_t >::_CRTP_IMPL ( impl_t  )
private

◆ begin() [1/2]

template<typename impl_t , typename data_t >
iterator utl::ostream_dev< impl_t, data_t >::begin ( )
inlinenoexcept

.begin implementation

Definition at line 154 of file ostream_dev.h.

◆ begin() [2/2]

template<typename impl_t , typename data_t >
const_iterator utl::ostream_dev< impl_t, data_t >::begin ( ) const
inlinenoexcept

Definition at line 155 of file ostream_dev.h.

◆ cbegin()

template<typename impl_t , typename data_t >
const_iterator utl::ostream_dev< impl_t, data_t >::cbegin ( ) const
inlinenoexcept

Definition at line 156 of file ostream_dev.h.

◆ cend()

template<typename impl_t , typename data_t >
const_iterator utl::ostream_dev< impl_t, data_t >::cend ( ) const
inlinenoexcept

Definition at line 161 of file ostream_dev.h.

◆ end() [1/2]

template<typename impl_t , typename data_t >
iterator utl::ostream_dev< impl_t, data_t >::end ( )
inlinenoexcept

.end implementation

Definition at line 159 of file ostream_dev.h.

◆ end() [2/2]

template<typename impl_t , typename data_t >
const_iterator utl::ostream_dev< impl_t, data_t >::end ( ) const
inlinenoexcept

Definition at line 160 of file ostream_dev.h.

◆ operator<<() [1/3]

template<typename impl_t , typename data_t >
template<typename _Src_t >
ostream_dev_t& utl::ostream_dev< impl_t, data_t >::operator<< ( const _Src_t &  src)
inline

Template operator<< implementation for for all by value/ref parameters.

Note
In the case _Src_t size is not an exact multiple of data_t size the write data will be truncated and there may be data loss.
Parameters
srcReference to source data
Returns
Reference to this device for chaining

Definition at line 128 of file ostream_dev.h.

◆ operator<<() [2/3]

template<typename impl_t , typename data_t >
template<typename _Src_t >
ostream_dev_t& utl::ostream_dev< impl_t, data_t >::operator<< ( _Src_t *  src)
delete

Overload to disallow pointer types as source.

◆ operator<<() [3/3]

template<typename impl_t , typename data_t >
ostream_dev_t& utl::ostream_dev< impl_t, data_t >::operator<< ( const data_t &  src)
inline

Overload for single data_t object.

Definition at line 139 of file ostream_dev.h.

◆ operator=()

template<typename impl_t , typename data_t >
ostream_dev_t& utl::ostream_dev< impl_t, data_t >::operator= ( const ostream_dev_t )
protecteddelete

No copy assignments

◆ put() [1/2]

template<typename impl_t , typename data_t >
size_t utl::ostream_dev< impl_t, data_t >::put ( const data_t &  data)
inline

Put interface. This function should send a single data_t object to device.

Parameters
dataThe data to send
Returns
The number of transmitted data items
Note
A successful call should return 1

Definition at line 96 of file ostream_dev.h.

◆ put() [2/2]

template<typename impl_t , typename data_t >
size_t utl::ostream_dev< impl_t, data_t >::put ( const data_t *  data,
size_t  n 
)
inline

Put interface. This function should send a stream of data_t objects to device.

Parameters
dataPointer to buffer indenting write to device.
nThe number of data of type data_t to send
Returns
The number of transmitted items.

Definition at line 108 of file ostream_dev.h.

◆ put_() [1/2]

template<typename impl_t , typename data_t >
size_t utl::ostream_dev< impl_t, data_t >::put_ ( const data_t &  data)
inlineprivate

Definition at line 77 of file ostream_dev.h.

◆ put_() [2/2]

template<typename impl_t , typename data_t >
size_t utl::ostream_dev< impl_t, data_t >::put_ ( const data_t *  data,
size_t  n 
)
inlineprivate

Definition at line 78 of file ostream_dev.h.


The documentation for this class was generated from the following file: