Back to Arangodb

Null Devices

3rdParty/boost/1.78.0/libs/iostreams/doc/classes/null.html

3.12.9.16.2 KB
Original Source

Null Devices

OverviewAcknowledgmentsHeadersReferenceClass template basic_null_sourceClass template basic_null_sinkClass template basic_null_device


Overview

The class templates basic_null_source, basic_null_sink and basic_null_device are models of Device whose member functions all have trivial implementations. A basic_null_source is a Source whose member function read returns -1, indicating end-of-sequence. A basic_null_sink is a Sink whose member function write consumes and ignores the characters passed to it. A basic_null_device combines — depending on its template parameter Mode — the trivial read and write functions just described with a member seek that always returns an invalid stream position.

In addition, each of the above templates is Closable, with a no-op implementation of close.

Acknowledgments

The templates described here were inspired by Daryle Walker's basic_nullbuf template. See Disconnected Streams.

Headers

<boost/iostreams/device/null.hpp>

Reference

Class template basic_null_source

Description

Model of Source whose member function read returns -1, indicating end-of-sequence.

Synopsis

namespaceboost {namespaceiostreams {template<typename[Ch](#null_source_params)>class[basic\_null\_source](#null_source_params){public:typedefCh char_type;typedef[implementation-defined]category;[basic\_null\_source](#null_source_ctor)();    
    std::streamsize[read](#null_source_read)(char_type* s, std::streamsize n);void[close](#null_source_close)();
};typedefbasic_null_source<char>null\_source;typedefbasic_null_source<wchar\_t>wnull\_source;

} }// End namespace boost::io

Template parameters

|

Ch

| - |

The character type type.

|

basic_null_source::basic_null_source

basic_null_source();

Constructs a basic_null_source.

basic_null_source::read

std::streamsize read(char_type* s, std::streamsize n);

Returns -1.

basic_null_source::close

voidclose();

No-op.

Class template basic_null_sink

Description

Model of Sink whose member function write consumes and ignores the contents of the character buffer passed to it.

Synopsis

namespaceboost {namespaceiostreams {template<typename[Ch](#null_sink_params)>class[basic\_null\_sink](#null_sink_params){public:typedefCh char_type;typedef[implementation-defined]category;[basic\_null\_sink](#null_sink_ctor)();
    std::streamsize[write](#null_sink_write)(constchar_type* s, std::streamsize n);void[close](#null_sink_close)();
};typedefbasic_null_sink<char>null\_sink;typedefbasic_null_sink<wchar\_t>wnull\_sink;

} }// End namespace boost::io

Template parameters

|

Ch

| - |

The character type type.

|

basic_null_sink::basic_null_sink

basic_null_sink();

Constructs a basic_null_sink.

basic_null_sink::write

std::streamsize write(constchar_type* s, std::streamsize n);

Returns n.

basic_null_sink::close

voidclose();

No-op.

Class template basic_null_device

Description

Model of Device whose mode is specified as a template parameter, and whose member functions have trivial implementations, as follows:

  • read returns -1, indicating end-of-sequence
  • write consumes but ignores the entire contents of the character buffer passed to it
  • seek returns an invalid stream position

Synopsis

namespaceboost {namespaceiostreams {template<typename[Ch](#null_device_params),typename[Mode](#null_device_params)>class[basic\_null\_device](#null_device_params){public:typedefCh char_type;typedef[implementation-defined]category;[basic\_null\_device](#null_device_ctor)();
    std::streamsize[read](#null_device_read)(char_type* s, std::streamsize n);
    std::streamsize[write](#null_device_write)(constchar_type* s, std::streamsize n);[stream\_offset](../functions/positioning.html#synopsis)[seek](#null_device_seek)([stream\_offset](../functions/positioning.html#synopsis)off, std::ios_base::seekdir way,
                        std::ios_base::openmode which =
                            std::ios_base::in | std::ios_base::out );void[close](#null_device_close)();
};

} }// End namespace boost::io

Template parameters

|

Ch

| - |

The character type.

| |

Mode

| - |

The mode.

|

basic_null_device::basic_null_device

basic_null_device();

Constructs a basic_null_device.

basic_null_device::read

std::streamsize read(char_type* s, std::streamsize n);

Returns -1. Enabled if Mode refines input.

basic_null_device::write

std::streamsize write(constchar_type* s, std::streamsize n);

Returns n. Enabled if Mode refines output.

basic_null_device::seek

[stream\_offset](../functions/positioning.html#synopsis)seek([stream\_offset](../functions/positioning.html#synopsis)off, std::ios_base::seekdir way,
                         std::ios_base::openmode which =
                             std::ios_base::in | std::ios_base::out );

Returns an invalid stream position. Enabled if Mode permits random access.

basic_null_device::close

voidclose();

No-op.


© Copyright 2008 CodeRage, LLC
© Copyright 2004-2007 Jonathan Turkanis

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)