# Array Devices

Overview
Implementation
Headers
Reference

Class template `basic_array_source`
Class template `basic_array_sink`
Class template `basic_array`

Acknowledgments

## Overview

The class templates `basic_array_source`, `basic_array_sink` and `basic_array` provide access to a sequence of characters in memory. The array Devices do not manage the lifetimes of the underlying character sequences.

## Implementation

The array Devices are implemented as Direct Devices in order to provide efficient unbuffered access to the underlying character sequences.

## Headers

`<boost/iostreams/device/array.hpp>`

## Reference

### Class template `basic_array_source`

#### Description

Model of Source providing read-only access to a sequence of characters in memory.

#### Synopsis

    namespace boost { namespace iostreams {

    template<typename Ch>
    class basic_array_source {
    public:
        typedef Ch          char_type;
        typedef source_tag  category;

        template<int N> basic_array_source(char_type (&)[N]);
        basic_array_source(const char_type* begin, const char_type* end);
        basic_array_source(const char_type* begin, std::size_t length);
        ...
    };

    } } // End namespace boost::io

#### Template parameters

Ch | - | The character type.

#### `basic_array_source::basic_array_source`

    template<int N> basic_array_source(char_type (&)[N]);
    basic_array_source(const char_type* begin, const char_type* end);
    basic_array_source(const char_type* begin, std::size_t length);

Constructs a `basic_array_source` to read from the indicated character sequence.

### Class template `basic_array_sink`

#### Description

Model of Sink providing write-only access to a sequence of characters in memory.

#### Synopsis

    namespace boost { namespace iostreams {

    template<typename Ch>
    class basic_array_sink {
    public:
        typedef Ch        char_type;
        typedef sink_tag  category;

        template<int N> basic_array_sink(char_type (&)[N]);
        basic_array_sink(char_type* begin, char_type* end);
        basic_array_sink(char_type* begin, std::size_t length);

        // Additional nember functions
    };

    } } // End namespace boost::io

#### Template parameters

Ch | - | The character type.

#### `basic_array_sink::basic_array_sink`

    template<int N> basic_array_sink(char_type (&)[N]);
    basic_array_sink(char_type* begin, char_type* end);
    basic_array_sink(char_type* begin, std::size_t length);

Constructs an `basic_array_sink` to write to the indicated character sequence.

### Class template `basic_array`

#### Description

Model of SeekableDevice providing read-write access to a sequence of characters in memory.

#### Synopsis

    namespace boost { namespace iostreams {

    template<typename Ch>
    class basic_array {
    public:
        typedef Ch                   char_type;
        typedef seekable_device_tag  category;

        template<int N> basic_array(char_type (&)[N]);
        basic_array(char_type* begin, char_type* end);
        basic_array(char_type* begin, std::size_t length);

        // Additional nember functions
    };

    } } // End namespace boost::io

#### Template parameters

Ch | - | The character type.

#### `array::array`

    template<int N> basic_array(char_type (&)[N]);
    basic_array(char_type* begin, char_type* end);
    basic_array(char_type* begin, std::size_t length);

Constructs a `basic_array` to access the indicated character sequence.

## Acknowledgments

The concept of Devices which provide unbuffered access to character sequences was suggested by Daryle Walker's `array_stream` template.

Revised 20 May, 2004

© Copyright Jonathan Turkanis, 2004

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)