summaryrefslogtreecommitdiff
path: root/boost/interprocess/streams
diff options
context:
space:
mode:
authorChanho Park <chanho61.park@samsung.com>2014-12-11 18:55:56 +0900
committerChanho Park <chanho61.park@samsung.com>2014-12-11 18:55:56 +0900
commit08c1e93fa36a49f49325a07fe91ff92c964c2b6c (patch)
tree7a7053ceb8874b28ec4b868d4c49b500008a102e /boost/interprocess/streams
parentbb4dd8289b351fae6b55e303f189127a394a1edd (diff)
downloadboost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.gz
boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.bz2
boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.zip
Imported Upstream version 1.57.0upstream/1.57.0
Diffstat (limited to 'boost/interprocess/streams')
-rw-r--r--boost/interprocess/streams/bufferstream.hpp183
-rw-r--r--boost/interprocess/streams/vectorstream.hpp155
2 files changed, 199 insertions, 139 deletions
diff --git a/boost/interprocess/streams/bufferstream.hpp b/boost/interprocess/streams/bufferstream.hpp
index 3ae9f5e2dc..cb3e637939 100644
--- a/boost/interprocess/streams/bufferstream.hpp
+++ b/boost/interprocess/streams/bufferstream.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
//
@@ -8,7 +8,7 @@
//
//////////////////////////////////////////////////////////////////////////////
//
-// This file comes from SGI's sstream file. Modified by Ion Gaztanaga 2005.
+// This file comes from SGI's sstream file. Modified by Ion Gaztanaga 2005-2012.
// Changed internal SGI string to a buffer. Added efficient
// internal buffer get/set/swap functions, so that we can obtain/establish the
// internal buffer without any reallocation or copy. Kill those temporaries!
@@ -35,6 +35,10 @@
#ifndef BOOST_INTERPROCESS_BUFFERSTREAM_HPP
#define BOOST_INTERPROCESS_BUFFERSTREAM_HPP
+#if defined(_MSC_VER)
+# pragma once
+#endif
+
#include <boost/interprocess/detail/config_begin.hpp>
#include <boost/interprocess/detail/workaround.hpp>
@@ -42,7 +46,7 @@
#include <ios>
#include <istream>
#include <ostream>
-#include <string> // char traits
+#include <string> // char traits
#include <cstddef> // ptrdiff_t
#include <boost/assert.hpp>
#include <boost/interprocess/interprocess_fwd.hpp>
@@ -74,10 +78,10 @@ class basic_bufferbuf
//!Constructor. Assigns formatting buffer.
//!Does not throw.
- explicit basic_bufferbuf(CharT *buffer, std::size_t length,
+ explicit basic_bufferbuf(CharT *buf, std::size_t length,
std::ios_base::openmode mode
= std::ios_base::in | std::ios_base::out)
- : base_t(), m_mode(mode), m_buffer(buffer), m_length(length)
+ : base_t(), m_mode(mode), m_buffer(buf), m_length(length)
{ this->set_pointers(); }
virtual ~basic_bufferbuf(){}
@@ -90,10 +94,10 @@ class basic_bufferbuf
//!Sets the underlying buffer to a new value
//!Does not throw.
- void buffer(CharT *buffer, std::size_t length)
- { m_buffer = buffer; m_length = length; this->set_pointers(); }
+ void buffer(CharT *buf, std::size_t length)
+ { m_buffer = buf; m_length = length; this->set_pointers(); }
- /// @cond
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
private:
void set_pointers()
{
@@ -177,7 +181,7 @@ class basic_bufferbuf
{
bool in = false;
bool out = false;
-
+
const std::ios_base::openmode inout =
std::ios_base::in | std::ios_base::out;
@@ -245,14 +249,17 @@ class basic_bufferbuf
std::ios_base::openmode m_mode;
CharT * m_buffer;
std::size_t m_length;
- /// @endcond
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
};
//!A basic_istream class that uses a fixed size character buffer
//!as its formatting buffer.
template <class CharT, class CharTraits>
-class basic_ibufferstream
- : public std::basic_istream<CharT, CharTraits>
+class basic_ibufferstream :
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
+ private basic_bufferbuf<CharT, CharTraits>,
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
+ public std::basic_istream<CharT, CharTraits>
{
public: // Typedefs
typedef typename std::basic_ios
@@ -262,24 +269,40 @@ class basic_ibufferstream
typedef typename std::basic_ios<char_type, CharTraits>::off_type off_type;
typedef typename std::basic_ios<char_type, CharTraits>::traits_type traits_type;
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
private:
- typedef std::basic_ios<char_type, CharTraits> basic_ios_t;
- typedef std::basic_istream<char_type, CharTraits> base_t;
+ typedef basic_bufferbuf<CharT, CharTraits> bufferbuf_t;
+ typedef std::basic_ios<char_type, CharTraits> basic_ios_t;
+ typedef std::basic_istream<char_type, CharTraits> base_t;
+ bufferbuf_t & get_buf() { return *this; }
+ const bufferbuf_t & get_buf() const{ return *this; }
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
public:
//!Constructor.
//!Does not throw.
basic_ibufferstream(std::ios_base::openmode mode = std::ios_base::in)
- : basic_ios_t(), base_t(0), m_buf(mode | std::ios_base::in)
- { basic_ios_t::init(&m_buf); }
+ : //basic_ios_t() is called first (lefting it uninitialized) as it's a
+ //virtual base of basic_istream. The class will be initialized when
+ //basic_istream is constructed calling basic_ios_t::init().
+ //As bufferbuf_t's constructor does not throw there is no risk of
+ //calling the basic_ios_t's destructor without calling basic_ios_t::init()
+ bufferbuf_t(mode | std::ios_base::in)
+ , base_t(&get_buf())
+ {}
//!Constructor. Assigns formatting buffer.
//!Does not throw.
- basic_ibufferstream(const CharT *buffer, std::size_t length,
- std::ios_base::openmode mode = std::ios_base::in)
- : basic_ios_t(), base_t(0),
- m_buf(const_cast<CharT*>(buffer), length, mode | std::ios_base::in)
- { basic_ios_t::init(&m_buf); }
+ basic_ibufferstream(const CharT *buf, std::size_t length,
+ std::ios_base::openmode mode = std::ios_base::in)
+ : //basic_ios_t() is called first (lefting it uninitialized) as it's a
+ //virtual base of basic_istream. The class will be initialized when
+ //basic_istream is constructed calling basic_ios_t::init().
+ //As bufferbuf_t's constructor does not throw there is no risk of
+ //calling the basic_ios_t's destructor without calling basic_ios_t::init()
+ bufferbuf_t(const_cast<CharT*>(buf), length, mode | std::ios_base::in)
+ , base_t(&get_buf())
+ {}
~basic_ibufferstream(){};
@@ -287,29 +310,27 @@ class basic_ibufferstream
//!Returns the address of the stored
//!stream buffer.
basic_bufferbuf<CharT, CharTraits>* rdbuf() const
- { return const_cast<basic_bufferbuf<CharT, CharTraits>*>(&m_buf); }
+ { return const_cast<basic_bufferbuf<CharT, CharTraits>*>(&get_buf()); }
//!Returns the pointer and size of the internal buffer.
//!Does not throw.
std::pair<const CharT *, std::size_t> buffer() const
- { return m_buf.buffer(); }
+ { return get_buf().buffer(); }
//!Sets the underlying buffer to a new value. Resets
//!stream position. Does not throw.
- void buffer(const CharT *buffer, std::size_t length)
- { m_buf.buffer(const_cast<CharT*>(buffer), length); }
-
- /// @cond
- private:
- basic_bufferbuf<CharT, CharTraits> m_buf;
- /// @endcond
+ void buffer(const CharT *buf, std::size_t length)
+ { get_buf().buffer(const_cast<CharT*>(buf), length); }
};
//!A basic_ostream class that uses a fixed size character buffer
//!as its formatting buffer.
template <class CharT, class CharTraits>
-class basic_obufferstream
- : public std::basic_ostream<CharT, CharTraits>
+class basic_obufferstream :
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
+ private basic_bufferbuf<CharT, CharTraits>,
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
+ public std::basic_ostream<CharT, CharTraits>
{
public:
typedef typename std::basic_ios
@@ -319,25 +340,40 @@ class basic_obufferstream
typedef typename std::basic_ios<char_type, CharTraits>::off_type off_type;
typedef typename std::basic_ios<char_type, CharTraits>::traits_type traits_type;
- /// @cond
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
private:
+ typedef basic_bufferbuf<CharT, CharTraits> bufferbuf_t;
typedef std::basic_ios<char_type, CharTraits> basic_ios_t;
typedef std::basic_ostream<char_type, CharTraits> base_t;
- /// @endcond
+ bufferbuf_t & get_buf() { return *this; }
+ const bufferbuf_t & get_buf() const{ return *this; }
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
+
public:
//!Constructor.
//!Does not throw.
basic_obufferstream(std::ios_base::openmode mode = std::ios_base::out)
- : basic_ios_t(), base_t(0), m_buf(mode | std::ios_base::out)
- { basic_ios_t::init(&m_buf); }
+ : //basic_ios_t() is called first (lefting it uninitialized) as it's a
+ //virtual base of basic_istream. The class will be initialized when
+ //basic_istream is constructed calling basic_ios_t::init().
+ //As bufferbuf_t's constructor does not throw there is no risk of
+ //calling the basic_ios_t's destructor without calling basic_ios_t::init()
+ bufferbuf_t(mode | std::ios_base::out)
+ , base_t(&get_buf())
+ {}
//!Constructor. Assigns formatting buffer.
//!Does not throw.
- basic_obufferstream(CharT *buffer, std::size_t length,
+ basic_obufferstream(CharT *buf, std::size_t length,
std::ios_base::openmode mode = std::ios_base::out)
- : basic_ios_t(), base_t(0),
- m_buf(buffer, length, mode | std::ios_base::out)
- { basic_ios_t::init(&m_buf); }
+ : //basic_ios_t() is called first (lefting it uninitialized) as it's a
+ //virtual base of basic_istream. The class will be initialized when
+ //basic_istream is constructed calling basic_ios_t::init().
+ //As bufferbuf_t's constructor does not throw there is no risk of
+ //calling the basic_ios_t's destructor without calling basic_ios_t::init()
+ bufferbuf_t(buf, length, mode | std::ios_base::out)
+ , base_t(&get_buf())
+ {}
~basic_obufferstream(){}
@@ -345,31 +381,28 @@ class basic_obufferstream
//!Returns the address of the stored
//!stream buffer.
basic_bufferbuf<CharT, CharTraits>* rdbuf() const
- { return const_cast<basic_bufferbuf<CharT, CharTraits>*>(&m_buf); }
+ { return const_cast<basic_bufferbuf<CharT, CharTraits>*>(&get_buf()); }
//!Returns the pointer and size of the internal buffer.
//!Does not throw.
std::pair<CharT *, std::size_t> buffer() const
- { return m_buf.buffer(); }
+ { return get_buf().buffer(); }
//!Sets the underlying buffer to a new value. Resets
//!stream position. Does not throw.
- void buffer(CharT *buffer, std::size_t length)
- { m_buf.buffer(buffer, length); }
-
- /// @cond
- private:
- basic_bufferbuf<CharT, CharTraits> m_buf;
- /// @endcond
+ void buffer(CharT *buf, std::size_t length)
+ { get_buf().buffer(buf, length); }
};
//!A basic_iostream class that uses a fixed size character buffer
//!as its formatting buffer.
template <class CharT, class CharTraits>
-class basic_bufferstream
- : public std::basic_iostream<CharT, CharTraits>
-
+class basic_bufferstream :
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
+ private basic_bufferbuf<CharT, CharTraits>,
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
+ public std::basic_iostream<CharT, CharTraits>
{
public: // Typedefs
typedef typename std::basic_ios
@@ -379,27 +412,42 @@ class basic_bufferstream
typedef typename std::basic_ios<char_type, CharTraits>::off_type off_type;
typedef typename std::basic_ios<char_type, CharTraits>::traits_type traits_type;
- /// @cond
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
private:
- typedef std::basic_ios<char_type, CharTraits> basic_ios_t;
- typedef std::basic_iostream<char_type, CharTraits> base_t;
- /// @endcond
+ typedef basic_bufferbuf<CharT, CharTraits> bufferbuf_t;
+ typedef std::basic_ios<char_type, CharTraits> basic_ios_t;
+ typedef std::basic_iostream<char_type, CharTraits> base_t;
+ bufferbuf_t & get_buf() { return *this; }
+ const bufferbuf_t & get_buf() const{ return *this; }
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
public:
//!Constructor.
//!Does not throw.
basic_bufferstream(std::ios_base::openmode mode
= std::ios_base::in | std::ios_base::out)
- : basic_ios_t(), base_t(0), m_buf(mode)
- { basic_ios_t::init(&m_buf); }
+ : //basic_ios_t() is called first (lefting it uninitialized) as it's a
+ //virtual base of basic_istream. The class will be initialized when
+ //basic_istream is constructed calling basic_ios_t::init().
+ //As bufferbuf_t's constructor does not throw there is no risk of
+ //calling the basic_ios_t's destructor without calling basic_ios_t::init()
+ bufferbuf_t(mode)
+ , base_t(&get_buf())
+ {}
//!Constructor. Assigns formatting buffer.
//!Does not throw.
- basic_bufferstream(CharT *buffer, std::size_t length,
+ basic_bufferstream(CharT *buf, std::size_t length,
std::ios_base::openmode mode
= std::ios_base::in | std::ios_base::out)
- : basic_ios_t(), base_t(0), m_buf(buffer, length, mode)
- { basic_ios_t::init(&m_buf); }
+ : //basic_ios_t() is called first (lefting it uninitialized) as it's a
+ //virtual base of basic_istream. The class will be initialized when
+ //basic_istream is constructed calling basic_ios_t::init().
+ //As bufferbuf_t's constructor does not throw there is no risk of
+ //calling the basic_ios_t's destructor without calling basic_ios_t::init()
+ bufferbuf_t(buf, length, mode)
+ , base_t(&get_buf())
+ {}
~basic_bufferstream(){}
@@ -407,22 +455,17 @@ class basic_bufferstream
//!Returns the address of the stored
//!stream buffer.
basic_bufferbuf<CharT, CharTraits>* rdbuf() const
- { return const_cast<basic_bufferbuf<CharT, CharTraits>*>(&m_buf); }
+ { return const_cast<basic_bufferbuf<CharT, CharTraits>*>(&get_buf()); }
//!Returns the pointer and size of the internal buffer.
//!Does not throw.
std::pair<CharT *, std::size_t> buffer() const
- { return m_buf.buffer(); }
+ { return get_buf().buffer(); }
//!Sets the underlying buffer to a new value. Resets
//!stream position. Does not throw.
- void buffer(CharT *buffer, std::size_t length)
- { m_buf.buffer(buffer, length); }
-
- /// @cond
- private:
- basic_bufferbuf<CharT, CharTraits> m_buf;
- /// @endcond
+ void buffer(CharT *buf, std::size_t length)
+ { get_buf().buffer(buf, length); }
};
//Some typedefs to simplify usage
diff --git a/boost/interprocess/streams/vectorstream.hpp b/boost/interprocess/streams/vectorstream.hpp
index 3cee7200ab..94a75723b6 100644
--- a/boost/interprocess/streams/vectorstream.hpp
+++ b/boost/interprocess/streams/vectorstream.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2012. 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)
//
@@ -8,7 +8,7 @@
//
//////////////////////////////////////////////////////////////////////////////
//
-// This file comes from SGI's sstream file. Modified by Ion Gaztanaga 2005.
+// This file comes from SGI's sstream file. Modified by Ion Gaztanaga 2005-2012.
// Changed internal SGI string to a generic, templatized vector. Added efficient
// internal buffer get/set/swap functions, so that we can obtain/establish the
// internal buffer without any reallocation or copy. Kill those temporaries!
@@ -36,6 +36,10 @@
#ifndef BOOST_INTERPROCESS_VECTORSTREAM_HPP
#define BOOST_INTERPROCESS_VECTORSTREAM_HPP
+#if defined(_MSC_VER)
+# pragma once
+#endif
+
#include <boost/interprocess/detail/config_begin.hpp>
#include <boost/interprocess/detail/workaround.hpp>
@@ -43,7 +47,7 @@
#include <ios>
#include <istream>
#include <ostream>
-#include <string> // char traits
+#include <string> // char traits
#include <cstddef> // ptrdiff_t
#include <boost/interprocess/interprocess_fwd.hpp>
#include <boost/assert.hpp>
@@ -67,13 +71,13 @@ class basic_vectorbuf
typedef typename CharTraits::off_type off_type;
typedef CharTraits traits_type;
- /// @cond
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
private:
typedef std::basic_streambuf<char_type, traits_type> base_t;
basic_vectorbuf(const basic_vectorbuf&);
basic_vectorbuf & operator =(const basic_vectorbuf&);
- /// @endcond
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
public:
//!Constructor. Throws if vector_type default
@@ -92,15 +96,13 @@ class basic_vectorbuf
: base_t(), m_mode(mode), m_vect(param)
{ this->initialize_pointers(); }
- virtual ~basic_vectorbuf(){}
-
public:
//!Swaps the underlying vector with the passed vector.
//!This function resets the read/write position in the stream.
//!Does not throw.
void swap_vector(vector_type &vect)
- {
+ {
if (this->m_mode & std::ios_base::out){
//Update high water if necessary
//And resize vector to remove extra size
@@ -119,7 +121,7 @@ class basic_vectorbuf
//!Returns a const reference to the internal vector.
//!Does not throw.
const vector_type &vector() const
- {
+ {
if (this->m_mode & std::ios_base::out){
if (mp_high_water < base_t::pptr()){
//Restore the vector's size if necessary
@@ -163,7 +165,7 @@ class basic_vectorbuf
void clear()
{ m_vect.clear(); this->initialize_pointers(); }
- /// @cond
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
private:
//Maximizes high watermark to the initial vector size,
//initializes read and write iostream buffers to the capacity
@@ -358,7 +360,7 @@ class basic_vectorbuf
std::ios_base::openmode m_mode;
mutable vector_type m_vect;
mutable char_type* mp_high_water;
- /// @endcond
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
};
//!A basic_istream class that holds a character vector specified by CharVector
@@ -367,10 +369,10 @@ class basic_vectorbuf
//!boost::interprocess::basic_string
template <class CharVector, class CharTraits>
class basic_ivectorstream
- /// @cond
- : private basic_vectorbuf<CharVector, CharTraits>
- /// @endcond
- , public std::basic_istream<typename CharVector::value_type, CharTraits>
+ : public std::basic_istream<typename CharVector::value_type, CharTraits>
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
+ , private basic_vectorbuf<CharVector, CharTraits>
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
{
public:
typedef CharVector vector_type;
@@ -381,59 +383,65 @@ class basic_ivectorstream
typedef typename std::basic_ios<char_type, CharTraits>::off_type off_type;
typedef typename std::basic_ios<char_type, CharTraits>::traits_type traits_type;
- /// @cond
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
private:
typedef basic_vectorbuf<CharVector, CharTraits> vectorbuf_t;
+ typedef std::basic_ios<char_type, CharTraits> basic_ios_t;
typedef std::basic_istream<char_type, CharTraits> base_t;
- vectorbuf_t & m_buf() { return *this; }
- const vectorbuf_t & m_buf() const{ return *this; }
- /// @endcond
+ vectorbuf_t & get_buf() { return *this; }
+ const vectorbuf_t & get_buf() const{ return *this; }
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
public:
+
//!Constructor. Throws if vector_type default
//!constructor throws.
basic_ivectorstream(std::ios_base::openmode mode = std::ios_base::in)
- : vectorbuf_t(mode | std::ios_base::in), base_t(&m_buf())
- {}
+ : base_t(0) //Initializes first the base class to safely init the virtual basic_ios base
+ //(via basic_ios::init() call in base_t's constructor) without the risk of a
+ //previous throwing vectorbuf constructor. Set the streambuf after risk has gone.
+ , vectorbuf_t(mode | std::ios_base::in)
+ { this->base_t::rdbuf(&get_buf()); }
//!Constructor. Throws if vector_type(const VectorParameter &param)
//!throws.
template<class VectorParameter>
basic_ivectorstream(const VectorParameter &param,
std::ios_base::openmode mode = std::ios_base::in)
- : vectorbuf_t(param, mode | std::ios_base::in), base_t(&m_buf())
+ : vectorbuf_t(param, mode | std::ios_base::in)
+ //basic_ios_t() is constructed uninitialized as virtual base
+ //and initialized inside base_t calling basic_ios::init()
+ , base_t(&get_buf())
{}
- ~basic_ivectorstream(){};
-
public:
//!Returns the address of the stored
//!stream buffer.
basic_vectorbuf<CharVector, CharTraits>* rdbuf() const
- { return const_cast<basic_vectorbuf<CharVector, CharTraits>*>(&m_buf()); }
+ { return const_cast<basic_vectorbuf<CharVector, CharTraits>*>(&get_buf()); }
//!Swaps the underlying vector with the passed vector.
//!This function resets the read position in the stream.
//!Does not throw.
void swap_vector(vector_type &vect)
- { m_buf().swap_vector(vect); }
+ { get_buf().swap_vector(vect); }
//!Returns a const reference to the internal vector.
//!Does not throw.
const vector_type &vector() const
- { return m_buf().vector(); }
+ { return get_buf().vector(); }
//!Calls reserve() method of the internal vector.
//!Resets the stream to the first position.
//!Throws if the internals vector's reserve throws.
void reserve(typename vector_type::size_type size)
- { m_buf().reserve(size); }
+ { get_buf().reserve(size); }
//!Calls clear() method of the internal vector.
//!Resets the stream to the first position.
void clear()
- { m_buf().clear(); }
+ { get_buf().clear(); }
};
//!A basic_ostream class that holds a character vector specified by CharVector
@@ -442,10 +450,10 @@ class basic_ivectorstream
//!boost::interprocess::basic_string
template <class CharVector, class CharTraits>
class basic_ovectorstream
- /// @cond
- : private basic_vectorbuf<CharVector, CharTraits>
- /// @endcond
- , public std::basic_ostream<typename CharVector::value_type, CharTraits>
+ : public std::basic_ostream<typename CharVector::value_type, CharTraits>
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
+ , private basic_vectorbuf<CharVector, CharTraits>
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
{
public:
typedef CharVector vector_type;
@@ -456,57 +464,61 @@ class basic_ovectorstream
typedef typename std::basic_ios<char_type, CharTraits>::off_type off_type;
typedef typename std::basic_ios<char_type, CharTraits>::traits_type traits_type;
- /// @cond
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
private:
typedef basic_vectorbuf<CharVector, CharTraits> vectorbuf_t;
+ typedef std::basic_ios<char_type, CharTraits> basic_ios_t;
typedef std::basic_ostream<char_type, CharTraits> base_t;
- vectorbuf_t & m_buf() { return *this; }
- const vectorbuf_t & m_buf()const { return *this; }
- /// @endcond
+ vectorbuf_t & get_buf() { return *this; }
+ const vectorbuf_t & get_buf()const { return *this; }
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
public:
//!Constructor. Throws if vector_type default
//!constructor throws.
basic_ovectorstream(std::ios_base::openmode mode = std::ios_base::out)
- : vectorbuf_t(mode | std::ios_base::out), base_t(&m_buf())
- {}
+ : base_t(0) //Initializes first the base class to safely init the virtual basic_ios base
+ //(via basic_ios::init() call in base_t's constructor) without the risk of a
+ //previous throwing vectorbuf constructor. Set the streambuf after risk has gone.
+ , vectorbuf_t(mode | std::ios_base::out)
+ { this->base_t::rdbuf(&get_buf()); }
//!Constructor. Throws if vector_type(const VectorParameter &param)
//!throws.
template<class VectorParameter>
basic_ovectorstream(const VectorParameter &param,
std::ios_base::openmode mode = std::ios_base::out)
- : vectorbuf_t(param, mode | std::ios_base::out), base_t(&m_buf())
- {}
-
- ~basic_ovectorstream(){}
+ : base_t(0) //Initializes first the base class to safely init the virtual basic_ios base
+ //(via basic_ios::init() call in base_t's constructor) without the risk of a
+ //previous throwing vectorbuf constructor. Set the streambuf after risk has gone.
+ , vectorbuf_t(param, mode | std::ios_base::out)
+ { this->base_t::rdbuf(&get_buf()); }
public:
//!Returns the address of the stored
//!stream buffer.
basic_vectorbuf<CharVector, CharTraits>* rdbuf() const
- { return const_cast<basic_vectorbuf<CharVector, CharTraits>*>(&m_buf()); }
+ { return const_cast<basic_vectorbuf<CharVector, CharTraits>*>(&get_buf()); }
//!Swaps the underlying vector with the passed vector.
//!This function resets the write position in the stream.
//!Does not throw.
void swap_vector(vector_type &vect)
- { m_buf().swap_vector(vect); }
+ { get_buf().swap_vector(vect); }
//!Returns a const reference to the internal vector.
//!Does not throw.
const vector_type &vector() const
- { return m_buf().vector(); }
+ { return get_buf().vector(); }
//!Calls reserve() method of the internal vector.
//!Resets the stream to the first position.
//!Throws if the internals vector's reserve throws.
void reserve(typename vector_type::size_type size)
- { m_buf().reserve(size); }
+ { get_buf().reserve(size); }
};
-
//!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
@@ -514,7 +526,9 @@ class basic_ovectorstream
template <class CharVector, class CharTraits>
class basic_vectorstream
: public std::basic_iostream<typename CharVector::value_type, CharTraits>
-
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
+ , private basic_vectorbuf<CharVector, CharTraits>
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
{
public:
typedef CharVector vector_type;
@@ -525,61 +539,64 @@ class basic_vectorstream
typedef typename std::basic_ios<char_type, CharTraits>::off_type off_type;
typedef typename std::basic_ios<char_type, CharTraits>::traits_type traits_type;
- /// @cond
+ #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
private:
- typedef std::basic_ios<char_type, CharTraits> basic_ios_t;
- typedef std::basic_iostream<char_type, CharTraits> base_t;
- /// @endcond
+ typedef basic_vectorbuf<CharVector, CharTraits> vectorbuf_t;
+ typedef std::basic_ios<char_type, CharTraits> basic_ios_t;
+ typedef std::basic_iostream<char_type, CharTraits> base_t;
+
+ vectorbuf_t & get_buf() { return *this; }
+ const vectorbuf_t & get_buf() const{ return *this; }
+ #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
public:
//!Constructor. Throws if vector_type default
//!constructor throws.
basic_vectorstream(std::ios_base::openmode mode
= std::ios_base::in | std::ios_base::out)
- : basic_ios_t(), base_t(0), m_buf(mode)
- { basic_ios_t::init(&m_buf); }
+ : base_t(0) //Initializes first the base class to safely init the virtual basic_ios base
+ //(via basic_ios::init() call in base_t's constructor) without the risk of a
+ //previous throwing vectorbuf constructor. Set the streambuf after risk has gone.
+ , vectorbuf_t(mode)
+ { this->base_t::rdbuf(&get_buf()); }
//!Constructor. Throws if vector_type(const VectorParameter &param)
//!throws.
template<class VectorParameter>
basic_vectorstream(const VectorParameter &param, std::ios_base::openmode mode
= std::ios_base::in | std::ios_base::out)
- : basic_ios_t(), base_t(0), m_buf(param, mode)
- { basic_ios_t::init(&m_buf); }
-
- ~basic_vectorstream(){}
+ : base_t(0) //Initializes first the base class to safely init the virtual basic_ios base
+ //(via basic_ios::init() call in base_t's constructor) without the risk of a
+ //previous throwing vectorbuf constructor. Set the streambuf after risk has gone.
+ , vectorbuf_t(param, mode)
+ { this->base_t::rdbuf(&get_buf()); }
public:
//Returns the address of the stored stream buffer.
basic_vectorbuf<CharVector, CharTraits>* rdbuf() const
- { return const_cast<basic_vectorbuf<CharVector, CharTraits>*>(&m_buf); }
+ { return const_cast<basic_vectorbuf<CharVector, CharTraits>*>(&get_buf()); }
//!Swaps the underlying vector with the passed vector.
//!This function resets the read/write position in the stream.
//!Does not throw.
void swap_vector(vector_type &vect)
- { m_buf.swap_vector(vect); }
+ { get_buf().swap_vector(vect); }
//!Returns a const reference to the internal vector.
//!Does not throw.
const vector_type &vector() const
- { return m_buf.vector(); }
+ { return get_buf().vector(); }
//!Calls reserve() method of the internal vector.
//!Resets the stream to the first position.
//!Throws if the internals vector's reserve throws.
void reserve(typename vector_type::size_type size)
- { m_buf.reserve(size); }
+ { get_buf().reserve(size); }
//!Calls clear() method of the internal vector.
//!Resets the stream to the first position.
void clear()
- { m_buf.clear(); }
-
- /// @cond
- private:
- basic_vectorbuf<CharVector, CharTraits> m_buf;
- /// @endcond
+ { get_buf().clear(); }
};
//Some typedefs to simplify usage