Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

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 std::basic_streambuf< CharVector::value_type, CharTraits >
{
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;

  // public member functions
  explicit basic_vectorbuf(std::ios_base::openmode = std::ios_base::in|std::ios_base::out);
  template<typename VectorParameter> 
    explicit basic_vectorbuf(const VectorParameter &, 
                             std::ios_base::openmode = std::ios_base::in|std::ios_base::out);
  void swap_vector(vector_type &);
  const vector_type & vector() const;
  void reserve(typename vector_type::size_type);
  void clear();
};

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 member functions

  1. explicit basic_vectorbuf(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> 
      explicit 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.

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

  4. const vector_type & vector() const;

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

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

    If the stream is in output mode and size is greater than the size of the internal vector, preallocates memory in the internal vector. Keeps the read and write positions. Throws if the internals vector's memory allocation throws.

  6. void clear();

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


PrevUpHomeNext