| Home | Libraries | People | FAQ | More

## Class template basic_vectorstream

boost::interprocess::basic_vectorstream

## Synopsis

    // In header: <boost/interprocess/interprocess_fwd.hpp>

    template<typename CharVector,
             typename CharTraits = std::char_traits<typename CharVector::value_type> >
    class basic_vectorstream :
      public std::basic_iostream< CharVector::value_type, CharTraits >
    {
    public:
      // construct/copy/destruct
      basic_vectorstream(std::ios_base::openmode = std::ios_base::in|std::ios_base::out);
      template<typename VectorParameter>
        basic_vectorstream(const VectorParameter &,
                           std::ios_base::openmode = std::ios_base::in|std::ios_base::out);
      ~basic_vectorstream();

      // public member functions
      basic_vectorbuf< CharVector, CharTraits > * rdbuf() const;
      void swap_vector(vector_type &);
      const vector_type & vector() const;
      void reserve(typename vector_type::size_type);
      void clear();
    };

## Description

A basic_iostream class that holds a character vector specified by CharVector template parameter as its formatting buffer. The vector must have contiguous storage, like std::vector, boost::interprocess::vector or boost::interprocess::basic_string

### `basic_vectorstream` public construct/copy/destruct

1.     basic_vectorstream(std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out);

   Constructor. Throws if vector_type default constructor throws.

2.     template<typename VectorParameter>
         basic_vectorstream(const VectorParameter & param,
                            std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out);

   Constructor. Throws if vector_type(const VectorParameter &param) throws.

3.     ~basic_vectorstream();

### `basic_vectorstream` public member functions

1.     basic_vectorbuf< CharVector, CharTraits > * rdbuf() const;

2.     void swap_vector(vector_type & vect);

   Swaps the underlying vector with the passed vector. This function resets the read/write position in the stream. Does not throw.

3.     const vector_type & vector() const;

   Returns a const reference to the internal vector. Does not throw.

4.     void reserve(typename vector_type::size_type size);

   Calls reserve() method of the internal vector. Resets the stream to the first position. Throws if the internals vector's reserve throws.

5.     void clear();

   Calls clear() method of the internal vector. Resets the stream to the first position.