Boost logo

Boost-Commit :

From: doomster_at_[hidden]
Date: 2008-05-02 06:30:52


Author: eckhardt
Date: 2008-05-02 06:30:51 EDT (Fri, 02 May 2008)
New Revision: 45017
URL: http://svn.boost.org/trac/boost/changeset/45017

Log:
- Add include file to compile Boost.IOStreams in-place.
- Add test file using IOStreams lib.

Added:
   sandbox/compile-in-place/Boost_1_35_0/boost/iostreams/compile_in_place.cpp (contents, props changed)
   sandbox/compile-in-place/test-iostreams.cpp (contents, props changed)

Added: sandbox/compile-in-place/Boost_1_35_0/boost/iostreams/compile_in_place.cpp
==============================================================================
--- (empty file)
+++ sandbox/compile-in-place/Boost_1_35_0/boost/iostreams/compile_in_place.cpp 2008-05-02 06:30:51 EDT (Fri, 02 May 2008)
@@ -0,0 +1,21 @@
+/* compile in-place support for Boost.IOStreams
+
+Copyright 2008 Ulrich Eckhardt
+
+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)
+*/
+// $Id$
+
+// This file must not be included more than once. Note that this 'once' is
+// not per translation unit but per binary! Never include this in a header!
+#ifdef BOOST_IOSTREAMS_COMPILE_IN_PLACE_CPP_INCLUDED
+# error "this file should only be included once per binary"
+#endif
+
+#define BOOST_IOSTREAMS_COMPILE_IN_PLACE_CPP_INCLUDED
+
+#include "../../libs/iostreams/src/bzip2.cpp"
+#include "../../libs/iostreams/src/file_descriptor.cpp"
+#include "../../libs/iostreams/src/mapped_file.cpp"
+#include "../../libs/iostreams/src/zlib.cpp"

Added: sandbox/compile-in-place/test-iostreams.cpp
==============================================================================
--- (empty file)
+++ sandbox/compile-in-place/test-iostreams.cpp 2008-05-02 06:30:51 EDT (Fri, 02 May 2008)
@@ -0,0 +1,50 @@
+/* example to demonstrate compile-in-place for Boost.IOStreams
+
+Compile with
+ $CXX -I path/to/boost_X_YY_Z test-iostreams.cpp -lbz2 -lz
+
+Notes:
+- '-lbz2' and '-lz' of need to be replaced with the according libraries for
+bzip2 and zlib. The above should work on Linux systems though.
+
+- It would be helpful if we could exclude the two dependent libraries from
+compilation somehow for people that don't want to use them.
+
+$Id$
+*/
+
+#include <iostream>
+#include <boost/iostreams/filtering_stream.hpp>
+#include <boost/iostreams/filter/line.hpp>
+#include <boost/iostreams/compile_in_place.cpp>
+
+namespace io = boost::iostreams;
+
+
+class shell_comments_filter:
+ public io::line_filter
+{
+public:
+ shell_comments_filter()
+ {}
+private:
+ typedef io::line_filter::string_type string_type;
+ virtual string_type do_filter(string_type const& line)
+ {
+ if(line.empty())
+ return line;
+ if(line[0] == '#')
+ return string_type();
+ return line;
+ }
+};
+
+int main()
+{
+ io::filtering_ostream out;
+ out.push(shell_comments_filter());
+ out.push(std::cout);
+ // write to out using std::ostream interface
+
+ out << std::cin.rdbuf();
+}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk