| Home | Libraries | People | FAQ | More

## Class template basic_vectorbuf

boost::interprocess::basic_vectorbuf

## Synopsis

    // In header: <boost/interprocess/streams/vectorstream.hpp>

    template<typename CharVector, typename CharTraits>
    class basic_vectorbuf {
    public:
      // types
      typedef CharVector                                     vector_type;
      typedef CharVector::value_type                         char_type;
      typedef CharTraits::int_type                           int_type;
      typedef CharTraits::pos_type                           pos_type;
      typedef CharTraits::off_type                           off_type;
      typedef CharTraits                                     traits_type;
      typedef std::basic_streambuf< char_type, traits_type > base_t;       // @ private:

      // construct/copy/destruct
      basic_vectorbuf(const basic_vectorbuf &);
      basic_vectorbuf(std::ios_base::openmode = std::ios_base::in|std::ios_base::out);
      template<typename VectorParameter>
        basic_vectorbuf(const VectorParameter &,
                        std::ios_base::openmode = std::ios_base::in|std::ios_base::out);
      basic_vectorbuf& operator=(const basic_vectorbuf &);
      ~basic_vectorbuf();

      // public member functions
      void swap_vector(vector_type &);
      const vector_type & vector() const;
      void reserve(typename vector_type::size_type);
      void clear();
      void initialize_pointers();

      // protected member functions
      int_type underflow();
      int_type pbackfail(int_type = CharTraits::eof());
      int_type overflow(int_type = CharTraits::eof());
      pos_type seekoff(off_type, std::ios_base::seekdir,
                       std::ios_base::openmode = std::ios_base::in|std::ios_base::out);
      pos_type seekpos(pos_type,
                       std::ios_base::openmode = std::ios_base::in|std::ios_base::out);
    };

## Description

A streambuf class that controls the transmission of elements to and from a basic_ivectorstream, basic_ovectorstream or basic_vectorstream. It 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_vectorbuf` public construct/copy/destruct

1.     basic_vectorbuf(const basic_vectorbuf &);

2.     basic_vectorbuf(std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out);

   Constructor. Throws if vector_type default constructor throws.

3.     template<typename VectorParameter>
         basic_vectorbuf(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.

4.     basic_vectorbuf& operator=(const basic_vectorbuf &);

5.     ~basic_vectorbuf();

### `basic_vectorbuf` public member functions

1.     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.

2.     const vector_type & vector() const;

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

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

   Preallocates memory from the internal vector. Resets the stream to the first position. Throws if the internals vector's memory allocation throws.

4.     void clear();

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

5.     void initialize_pointers();

   @ private:

### `basic_vectorbuf` protected member functions

1.     int_type underflow();

2.     int_type pbackfail(int_type c = CharTraits::eof());

3.     int_type overflow(int_type c = CharTraits::eof());

4.     pos_type seekoff(off_type off, std::ios_base::seekdir dir,
                        std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out);

5.     pos_type seekpos(pos_type pos,
                        std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out);