summaryrefslogtreecommitdiffstats
path: root/src/boost/tools/quickbook/src/collector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/boost/tools/quickbook/src/collector.cpp')
-rw-r--r--src/boost/tools/quickbook/src/collector.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/boost/tools/quickbook/src/collector.cpp b/src/boost/tools/quickbook/src/collector.cpp
new file mode 100644
index 000000000..31324ab32
--- /dev/null
+++ b/src/boost/tools/quickbook/src/collector.cpp
@@ -0,0 +1,59 @@
+/*=============================================================================
+ Copyright (c) 2002 2004 2006 Joel de Guzman
+ http://spirit.sourceforge.net/
+
+ Use, modification and distribution is subject to 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)
+=============================================================================*/
+#include "collector.hpp"
+#include <boost/assert.hpp>
+
+namespace quickbook
+{
+ string_stream::string_stream()
+ : buffer_ptr(new std::string())
+ , stream_ptr(
+ new ostream(boost::iostreams::back_inserter(*buffer_ptr.get())))
+ {
+ }
+
+ string_stream::string_stream(string_stream const& other)
+ : buffer_ptr(other.buffer_ptr), stream_ptr(other.stream_ptr)
+ {
+ }
+
+ string_stream& string_stream::operator=(string_stream const& other)
+ {
+ buffer_ptr = other.buffer_ptr;
+ stream_ptr = other.stream_ptr;
+ return *this;
+ }
+
+ collector::collector() : main(default_), top(default_) {}
+
+ collector::collector(string_stream& out) : main(out), top(out) {}
+
+ collector::~collector()
+ {
+ BOOST_ASSERT(
+ streams.empty()); // assert there are no more pushes than pops!!!
+ }
+
+ void collector::push()
+ {
+ streams.push(string_stream());
+ top = boost::ref(streams.top());
+ }
+
+ void collector::pop()
+ {
+ BOOST_ASSERT(!streams.empty());
+ streams.pop();
+
+ if (streams.empty())
+ top = boost::ref(main);
+ else
+ top = boost::ref(streams.top());
+ }
+}