├── index.html ├── doc ├── theme │ ├── boost.png │ ├── wedge.gif │ └── boost_small.png ├── installation.html ├── acknowledgments.html ├── graphics │ ├── modes.gif │ ├── input_chain.gif │ ├── output_chain.gif │ ├── key_important.gif │ ├── key_input_seq.gif │ ├── key_output_seq.gif │ ├── key_read_head.gif │ ├── key_write_head.gif │ ├── seekable_chain.gif │ ├── important_modes.gif │ ├── bidirectional_chain.gif │ ├── key_read_write_head.gif │ └── key_bidirectional_seq.gif ├── functions │ ├── invert.html │ ├── slice.html │ ├── functions.html │ ├── copy.html │ └── combine.html ├── classes │ └── code_converter.html ├── tree │ └── tree.css ├── index.html ├── portability.html ├── reference.html ├── guide │ ├── buffering.html │ ├── lifetimes.html │ ├── guide.html │ ├── views.html │ └── text_processing.html ├── concepts │ ├── direct.html │ ├── optimally_buffered.html │ ├── multi_character.html │ ├── localizable.html │ ├── blocking.html │ ├── concepts.html │ └── dual_use_filter.html ├── tutorial │ └── tutorial.html └── macros │ ├── buffer_sizes.html │ └── macros.html ├── meta └── libraries.json ├── include └── boost │ └── iostreams │ ├── get.hpp │ ├── put.hpp │ ├── putback.hpp │ ├── detail │ ├── default_arg.hpp │ ├── config │ │ ├── limits.hpp │ │ ├── unreachable_return.hpp │ │ ├── enable_warnings.hpp │ │ ├── gcc.hpp │ │ ├── windows_posix.hpp │ │ ├── overload_resolution.hpp │ │ ├── dyn_link.hpp │ │ ├── fpos.hpp │ │ ├── disable_warnings.hpp │ │ ├── bzip2.hpp │ │ ├── zlib.hpp │ │ ├── auto_link.hpp │ │ ├── wide_streams.hpp │ │ └── codecvt.hpp │ ├── push_params.hpp │ ├── param_type.hpp │ ├── newline.hpp │ ├── template_params.hpp │ ├── call_traits.hpp │ ├── file_handle.hpp │ ├── is_iterator_range.hpp │ ├── broken_overload_resolution │ │ └── forward.hpp │ ├── streambuf.hpp │ ├── enable_if_stream.hpp │ ├── fstream.hpp │ ├── iostream.hpp │ ├── adapter │ │ ├── output_iterator_adapter.hpp │ │ ├── device_adapter.hpp │ │ ├── non_blocking_adapter.hpp │ │ └── filter_adapter.hpp │ ├── error.hpp │ ├── dispatch.hpp │ ├── add_facet.hpp │ ├── absolute_path.hpp │ ├── bool_trait_def.hpp │ ├── codecvt_holder.hpp │ ├── translate_int_type.hpp │ ├── ios.hpp │ ├── current_directory.hpp │ ├── counted_array.hpp │ ├── is_dereferenceable.hpp │ └── char_traits.hpp │ ├── operations.hpp │ ├── restrict.hpp │ ├── slice.hpp │ ├── operations_fwd.hpp │ ├── device │ ├── back_inserter.hpp │ └── null.hpp │ ├── constants.hpp │ ├── input_sequence.hpp │ ├── output_sequence.hpp │ ├── imbue.hpp │ ├── traits_fwd.hpp │ ├── char_traits.hpp │ ├── filter │ └── counter.hpp │ └── optimal_buffer_size.hpp ├── test ├── slice_test.cpp ├── path_test.cpp ├── sequence_test.cpp ├── filtering_stream_flush_test.hpp ├── null_test.cpp ├── stream_offset_32bit_test.cpp ├── seekable_file_test.cpp ├── seek_test.hpp ├── zlib_test.cpp ├── file_test.cpp ├── windows_pipe_test.cpp ├── detail │ └── constants.hpp ├── read_input_test.hpp ├── filtering_stream_test.cpp ├── invert_test.cpp ├── read_input_seq_test.hpp ├── read_seekable_test.hpp ├── write_output_test.hpp ├── read_input_istream_test.hpp ├── write_seekable_test.hpp ├── read_seekable_seq_test.hpp ├── buffer_size_test.cpp ├── write_output_ostream_test.hpp ├── read_bidir_streambuf_test.hpp └── write_output_seq_test.hpp ├── example ├── std_back_inserter_example.cpp ├── boost_back_inserter_example.cpp ├── iterator_range_example.cpp ├── container_sink_example.cpp ├── container_source_example.cpp └── container_device_example.cpp └── .travis.yml /index.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/index.html -------------------------------------------------------------------------------- /doc/theme/boost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/theme/boost.png -------------------------------------------------------------------------------- /doc/theme/wedge.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/theme/wedge.gif -------------------------------------------------------------------------------- /doc/installation.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/installation.html -------------------------------------------------------------------------------- /doc/acknowledgments.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/acknowledgments.html -------------------------------------------------------------------------------- /doc/graphics/modes.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/graphics/modes.gif -------------------------------------------------------------------------------- /doc/functions/invert.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/functions/invert.html -------------------------------------------------------------------------------- /doc/theme/boost_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/theme/boost_small.png -------------------------------------------------------------------------------- /doc/graphics/input_chain.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/graphics/input_chain.gif -------------------------------------------------------------------------------- /doc/graphics/output_chain.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/graphics/output_chain.gif -------------------------------------------------------------------------------- /doc/classes/code_converter.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/classes/code_converter.html -------------------------------------------------------------------------------- /doc/graphics/key_important.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/graphics/key_important.gif -------------------------------------------------------------------------------- /doc/graphics/key_input_seq.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/graphics/key_input_seq.gif -------------------------------------------------------------------------------- /doc/graphics/key_output_seq.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/graphics/key_output_seq.gif -------------------------------------------------------------------------------- /doc/graphics/key_read_head.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/graphics/key_read_head.gif -------------------------------------------------------------------------------- /doc/graphics/key_write_head.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/graphics/key_write_head.gif -------------------------------------------------------------------------------- /doc/graphics/seekable_chain.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/graphics/seekable_chain.gif -------------------------------------------------------------------------------- /doc/graphics/important_modes.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/graphics/important_modes.gif -------------------------------------------------------------------------------- /doc/graphics/bidirectional_chain.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/graphics/bidirectional_chain.gif -------------------------------------------------------------------------------- /doc/graphics/key_read_write_head.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/graphics/key_read_write_head.gif -------------------------------------------------------------------------------- /doc/graphics/key_bidirectional_seq.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LRFLEW/iostreams/develop/doc/graphics/key_bidirectional_seq.gif -------------------------------------------------------------------------------- /meta/libraries.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "iostreams", 3 | "name": "Iostreams", 4 | "authors": [ 5 | "Jonathan Turkanis" 6 | ], 7 | "description": "Boost.IOStreams provides a framework for defining streams, stream buffers and i/o filters.", 8 | "category": [ 9 | "IO", 10 | "String" 11 | ], 12 | "maintainers": [ 13 | "Jonathan Turkanis " 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /include/boost/iostreams/get.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2005-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_GET_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_GET_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include 16 | 17 | #endif // #ifndef BOOST_IOSTREAMS_GET_HPP_INCLUDED 18 | -------------------------------------------------------------------------------- /include/boost/iostreams/put.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2005-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_PUT_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_PUT_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include 16 | 17 | #endif // #ifndef BOOST_IOSTREAMS_PUT_HPP_INCLUDED 18 | -------------------------------------------------------------------------------- /test/slice_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the Boost Software License, Version 1.0.(See accompanying 3 | * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 4 | * 5 | * See http://www.boost.org/libs/iostreams for documentation. 6 | 7 | * File: test/slice_test.hpp 8 | * Date: Sun Jan 06 12:57:30 MST 2008 9 | * Copyright: 2007-2008 CodeRage, LLC 10 | * Author: Jonathan Turkanis 11 | * Contact: turkanis at coderage dot com 12 | * 13 | * Tests the overloaded function template boost::iostreams::slice. 14 | */ 15 | 16 | #define BOOST_RESTRICT_USE_SLICE 17 | #include "restrict_test.cpp" 18 | -------------------------------------------------------------------------------- /include/boost/iostreams/putback.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2005-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_PUTBACK_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_PUTBACK_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include 16 | 17 | #endif // #ifndef BOOST_IOSTREAMS_PUTBACK_HPP_INCLUDED 18 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/default_arg.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2005-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_DEFAULT_ARG_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_DEFAULT_ARG_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include 16 | #include 17 | 18 | // Obsolete. Remove. 19 | #define BOOST_IOSTREAMS_DEFAULT_ARG(arg) arg 20 | 21 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_DEFAULT_ARG_HPP_INCLUDED 22 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/config/limits.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_LIMITS_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_CONFIG_LIMITS_HPP_INCLUDED 10 | 11 | #ifndef BOOST_IOSTREAMS_MAX_FORWARDING_ARITY 12 | # define BOOST_IOSTREAMS_MAX_FORWARDING_ARITY 3 13 | #endif 14 | 15 | #ifndef BOOST_IOSTREAMS_MAX_EXECUTE_ARITY 16 | # define BOOST_IOSTREAMS_MAX_EXECUTE_ARITY 5 17 | #endif 18 | 19 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_LIMITS_HPP_INCLUDED 20 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/config/unreachable_return.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2010 Daniel James 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 4 | 5 | // See http://www.boost.org/libs/iostreams for documentation. 6 | 7 | #ifndef BOOST_IOSTREAMS_DETAIL_UNREACHABLE_RETURN_HPP_INCLUDED 8 | #define BOOST_IOSTREAMS_DETAIL_UNREACHABLE_RETURN_HPP_INCLUDED 9 | 10 | #if defined(_MSC_VER) 11 | # pragma once 12 | #endif 13 | 14 | #include 15 | 16 | #if defined(_MSC_VER) || defined(__GNUC__) 17 | #define BOOST_IOSTREAMS_UNREACHABLE_RETURN(x) \ 18 | BOOST_UNREACHABLE_RETURN(x) 19 | #else 20 | #define BOOST_IOSTREAMS_UNREACHABLE_RETURN(x) \ 21 | return x; 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /example/std_back_inserter_example.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2005-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #include 9 | #include // back_inserter 10 | #include 11 | #include 12 | 13 | namespace io = boost::iostreams; 14 | 15 | int main() 16 | { 17 | using namespace std; 18 | 19 | string result; 20 | io::filtering_ostream out(std::back_inserter(result)); 21 | out << "Hello World!"; 22 | out.flush(); 23 | assert(result == "Hello World!"); 24 | } 25 | -------------------------------------------------------------------------------- /example/boost_back_inserter_example.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2005-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace io = boost::iostreams; 14 | 15 | int main() 16 | { 17 | using namespace std; 18 | 19 | string result; 20 | io::filtering_ostream out(io::back_inserter(result)); 21 | out << "Hello World!"; 22 | out.flush(); 23 | assert(result == "Hello World!"); 24 | } 25 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/config/enable_warnings.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #if defined(BOOST_MSVC) 9 | # pragma warning(pop) 10 | #else 11 | # if BOOST_WORKAROUND(__BORLANDC__, < 0x600) 12 | # pragma warn .8008 // Condition always true/false. 13 | # pragma warn .8066 // Unreachable code. 14 | # pragma warn .8071 // Conversion may lose significant digits. 15 | # pragma warn .8072 // Suspicious pointer arithmetic. 16 | # pragma warn .8080 // identifier declared but never used. 17 | # endif 18 | #endif 19 | -------------------------------------------------------------------------------- /test/path_test.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Daniel James 2011. 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 4 | 5 | // See http://www.boost.org/libs/iostreams for documentation. 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | void path_test() 14 | { 15 | boost::filesystem::path orig("a/b"); 16 | boost::iostreams::detail::path p(orig); 17 | p = orig; 18 | } 19 | 20 | boost::unit_test::test_suite* init_unit_test_suite(int, char* []) 21 | { 22 | boost::unit_test::test_suite* test = BOOST_TEST_SUITE("mapped_file test"); 23 | test->add(BOOST_TEST_CASE(&path_test)); 24 | return test; 25 | } 26 | -------------------------------------------------------------------------------- /example/iterator_range_example.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2005-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace io = boost::iostreams; 14 | 15 | int main() 16 | { 17 | using namespace std; 18 | 19 | string input = "Hello World!"; 20 | string output; 21 | io::filtering_istream in(boost::make_iterator_range(input)); 22 | getline(in, output); 23 | assert(input == output); 24 | } 25 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/push_params.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_PUSH_PARAMS_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_PUSH_PARAMS_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #define BOOST_IOSTREAMS_PUSH_PARAMS() \ 16 | , std::streamsize buffer_size = -1 , std::streamsize pback_size = -1 \ 17 | /**/ 18 | 19 | #define BOOST_IOSTREAMS_PUSH_ARGS() , buffer_size, pback_size 20 | 21 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_PUSH_PARAMS_HPP_INCLUDED 22 | -------------------------------------------------------------------------------- /example/container_sink_example.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2005-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace io = boost::iostreams; 14 | namespace ex = boost::iostreams::example; 15 | 16 | int main() 17 | { 18 | using namespace std; 19 | typedef ex::container_sink string_sink; 20 | 21 | string result; 22 | io::stream out(result); 23 | out << "Hello World!"; 24 | out.flush(); 25 | assert(result == "Hello World!"); 26 | } 27 | -------------------------------------------------------------------------------- /example/container_source_example.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2005-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace io = boost::iostreams; 14 | namespace ex = boost::iostreams::example; 15 | 16 | int main() 17 | { 18 | using namespace std; 19 | typedef ex::container_source string_source; 20 | 21 | string input = "Hello World!"; 22 | string output; 23 | io::stream in(input); 24 | getline(in, output); 25 | assert(input == output); 26 | } 27 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/param_type.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_PARAM_TYPE_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_PARAM_TYPE_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include 16 | #include 17 | 18 | namespace boost { namespace iostreams { namespace detail { 19 | 20 | template 21 | struct param_type { 22 | typedef typename mpl::if_, T&, const T&>::type type; 23 | }; 24 | 25 | } } } // End namespaces detail, iostreams, boost. 26 | 27 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_PARAM_TYPE_HPP_INCLUDED //-----------// 28 | -------------------------------------------------------------------------------- /test/sequence_test.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #include 9 | #include "read_input_seq_test.hpp" 10 | #include "read_seekable_seq_test.hpp" 11 | #include "write_output_seq_test.hpp" 12 | #include "write_seekable_seq_test.hpp" 13 | 14 | using boost::unit_test::test_suite; 15 | 16 | test_suite* init_unit_test_suite(int, char* []) 17 | { 18 | test_suite* test = BOOST_TEST_SUITE("sequence test"); 19 | test->add(BOOST_TEST_CASE(&read_input_sequence_test)); 20 | test->add(BOOST_TEST_CASE(&read_seekable_sequence_test)); 21 | test->add(BOOST_TEST_CASE(&write_output_sequence_test)); 22 | test->add(BOOST_TEST_CASE(&write_seekable_sequence_test)); 23 | return test; 24 | } 25 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/newline.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2005-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_NEWLINE_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_NEWLINE_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | namespace boost { namespace iostreams { namespace detail { 16 | 17 | template 18 | struct newline; 19 | 20 | template<> 21 | struct newline { 22 | BOOST_STATIC_CONSTANT(char, value = '\n'); 23 | }; 24 | 25 | template<> 26 | struct newline { 27 | BOOST_STATIC_CONSTANT(wchar_t, value = L'\n'); 28 | }; 29 | 30 | } } } // End namespaces detaill, iostreams, boost. 31 | 32 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_NEWLINE_HPP_INCLUDED 33 | -------------------------------------------------------------------------------- /doc/tree/tree.css: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 3 | * (C) Copyright 2003-2007 Jonathan Turkanis 4 | * Distributed under the Boost Software License, Version 1.0. (See accompanying 5 | * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 6 | */ 7 | 8 | BODY { padding:5; margin:5 } 9 | HR { width:95%; text-align:center } 10 | DIV.tree-item { font-family:"Times New Roman",serif } 11 | SPAN.tree-icon { color:#0000ee } 12 | A.tree-icon, A.tree-text { text-decoration:none } 13 | A.tree-text { color:#0000ee } 14 | A:visited.tree-text { color:#0000ee } 15 | .lib-name, .tree-caption 16 | { 17 | margin-bottom:0; 18 | font-size:108%; 19 | font-family:Verdana,Tahoma,Arial,Helvetica,sans-serif; 20 | text-align:center; 21 | color:black 22 | } 23 | .tree-sync 24 | { 25 | font-size:10px; 26 | font-family:Verdana,Tahoma,Arial,Helvetica,sans-serif; 27 | text-decoration:none; 28 | color:#0000ee 29 | } 30 | P.tree-sync 31 | { 32 | text-align:center; 33 | margin-bottom:1em 34 | } 35 | -------------------------------------------------------------------------------- /include/boost/iostreams/operations.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2005-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_OPERATIONS_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_OPERATIONS_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #endif // #ifndef BOOST_IOSTREAMS_OPERATIONS_HPP_INCLUDED 27 | -------------------------------------------------------------------------------- /include/boost/iostreams/restrict.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the Boost Software License, Version 1.0.(See accompanying 3 | * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 4 | * 5 | * See http://www.boost.org/libs/iostreams for documentation. 6 | * 7 | * File: boost/iostreams/detail/restrict.hpp 8 | * Date: Sun Jan 06 12:57:30 MST 2008 9 | * Copyright: 2008 CodeRage, LLC 10 | 2004-2007 Jonathan Turkanis 11 | * Author: Jonathan Turkanis 12 | * Contact: turkanis at coderage dot com 13 | * 14 | * Defines the class template boost::iostreams::restriction and the 15 | * overloaded function template boost::iostreams::restrict 16 | */ 17 | 18 | #ifndef BOOST_IOSTREAMS_RESTRICT_HPP_INCLUDED 19 | #define BOOST_IOSTREAMS_RESTRICT_HPP_INCLUDED 20 | 21 | #include 22 | #define BOOST_IOSTREAMS_RESTRICT restrict 23 | #include 24 | #undef BOOST_IOSTREAMS_RESTRICT 25 | 26 | #endif // #ifndef BOOST_IOSTREAMS_RESTRICT_HPP_INCLUDED 27 | -------------------------------------------------------------------------------- /example/container_device_example.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2005-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #include 9 | #include 10 | #include 11 | #include // ios_base::beg. 12 | #include 13 | 14 | namespace io = boost::iostreams; 15 | namespace ex = boost::iostreams::example; 16 | 17 | int main() 18 | { 19 | using namespace std; 20 | typedef ex::container_device string_device; 21 | 22 | string one, two; 23 | io::stream io(one); 24 | io << "Hello World!"; 25 | io.flush(); 26 | io.seekg(0, BOOST_IOS::beg); 27 | getline(io, two); 28 | assert(one == "Hello World!"); 29 | assert(two == "Hello World!"); 30 | } 31 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/config/gcc.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | // Adapted from and from 9 | // http://www.boost.org/more/separate_compilation.html, by John Maddock. 10 | 11 | #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_GCC_HPP_INCLUDED 12 | #define BOOST_IOSTREAMS_DETAIL_CONFIG_GCC_HPP_INCLUDED 13 | 14 | #if defined(_MSC_VER) 15 | # pragma once 16 | #endif 17 | 18 | #include // BOOST_INTEL. 19 | 20 | #if defined(__GNUC__) && !defined(BOOST_INTEL) 21 | # define BOOST_IOSTREAMS_GCC (__GNUC__ * 100 + __GNUC_MINOR__) 22 | # define BOOST_IOSTREAMS_GCC_WORKAROUND_GUARD 1 23 | #else 24 | # define BOOST_IOSTREAMS_GCC_WORKAROUND_GUARD 0 25 | #endif 26 | 27 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_GCC_HPP_INCLUDED 28 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/template_params.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_TEMPLATE_PARAMS_HPP_INCLUDED 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #define BOOST_IOSTREAMS_TEMPLATE_PARAMS(arity, param) \ 15 | BOOST_PP_EXPR_IF(arity, template<) \ 16 | BOOST_PP_ENUM_PARAMS(arity, typename param) \ 17 | BOOST_PP_EXPR_IF(arity, >) \ 18 | /**/ 19 | 20 | #define BOOST_IOSTREAMS_TEMPLATE_ARGS(arity, param) \ 21 | BOOST_PP_EXPR_IF(arity, <) \ 22 | BOOST_PP_ENUM_PARAMS(arity, param) \ 23 | BOOST_PP_EXPR_IF(arity, >) \ 24 | /**/ 25 | 26 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_BUFFERS_HPP_INCLUDED 27 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/call_traits.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_VALUE_TYPE_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_VALUE_TYPE_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include 16 | #include 17 | 18 | namespace boost { namespace iostreams { namespace detail { 19 | 20 | template 21 | struct param_type { 22 | typedef typename mpl::if_, T&, const T&>::type type; 23 | }; 24 | 25 | template 26 | struct value_type { 27 | typedef typename mpl::if_, T&, T>::type type; 28 | }; 29 | 30 | } } } // End namespaces detail, iostreams, boost. 31 | 32 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_VALUE_TYPE_HPP_INCLUDED //-----------// 33 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Peter Dimov 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) 4 | 5 | language: cpp 6 | 7 | sudo: false 8 | 9 | python: "2.7" 10 | 11 | os: 12 | - linux 13 | - osx 14 | 15 | branches: 16 | only: 17 | - master 18 | - develop 19 | 20 | install: 21 | - cd .. 22 | - git clone -b $TRAVIS_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root 23 | - cd boost-root 24 | - git submodule update --init --depth 1 tools/build 25 | - git submodule update --init --depth 1 libs/config 26 | - git submodule update --init --depth 1 tools/boostdep 27 | - cp -r $TRAVIS_BUILD_DIR/* libs/iostreams 28 | - python tools/boostdep/depinst/depinst.py iostreams 29 | - ./bootstrap.sh 30 | - ./b2 headers 31 | 32 | script: 33 | - TOOLSET=gcc,clang 34 | - if [ $TRAVIS_OS_NAME == osx ]; then TOOLSET=clang; fi 35 | - ./b2 --verbose-test libs/config/test//config_info toolset=$TOOLSET || true 36 | - ./b2 libs/iostreams/test toolset=$TOOLSET 37 | 38 | notifications: 39 | email: 40 | on_success: always 41 | -------------------------------------------------------------------------------- /include/boost/iostreams/slice.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the Boost Software License, Version 1.0.(See accompanying 3 | * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 4 | * 5 | * See http://www.boost.org/libs/iostreams for documentation. 6 | * 7 | * File: boost/iostreams/detail/restrict.hpp 8 | * Date: Sun Jan 06 12:57:30 MST 2008 9 | * Copyright: 2008 CodeRage, LLC 10 | 2004-2007 Jonathan Turkanis 11 | * Author: Jonathan Turkanis 12 | * Contact: turkanis at coderage dot com 13 | * 14 | * Defines the class template boost::iostreams::restriction and the 15 | * overloaded function template boost::iostreams::slice. 16 | * 17 | * This header is provided for platforms on which "restrict" is a keyword. 18 | */ 19 | 20 | #ifndef BOOST_IOSTREAMS_RESTRICT_HPP_INCLUDED 21 | #define BOOST_IOSTREAMS_RESTRICT_HPP_INCLUDED 22 | 23 | #include 24 | #define BOOST_IOSTREAMS_RESTRICT slice 25 | #include 26 | #undef BOOST_IOSTREAMS_RESTRICT 27 | 28 | #endif // #ifndef BOOST_IOSTREAMS_RESTRICT_HPP_INCLUDED 29 | -------------------------------------------------------------------------------- /doc/index.html: -------------------------------------------------------------------------------- 1 | 3 | 8 | 9 | 10 | Boost.Iostreams 11 | 12 | 13 | 14 | 15 | 16 | <body> 17 | <a href="menu.html"></A> 18 | <a href="home.html"></A> 19 | <P CLASS="copyright"> 20 | Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <A HREF="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>) 21 | </P> 22 | </body> 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/config/windows_posix.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // (C) Copyright 2002, 2003 Beman Dawes Boost.Filesystem 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 6 | 7 | // See http://www.boost.org/libs/iostreams for documentation. 8 | 9 | #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_WINDOWS_POSIX_HPP_INCLUDED 10 | #define BOOST_IOSTREAMS_DETAIL_CONFIG_WINDOWS_POSIX_HPP_INCLUDED 11 | 12 | //------------------From boost/libs/filesystem/src/path_posix_windows.cpp-----// 13 | 14 | // BOOST_IOSTREAMS_POSIX or BOOST_IOSTREAMS_WINDOWS specify which API to use. 15 | #if !defined( BOOST_IOSTREAMS_WINDOWS ) && !defined( BOOST_IOSTREAMS_POSIX ) 16 | # if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) && \ 17 | !defined(__CYGWIN__) \ 18 | /**/ 19 | # define BOOST_IOSTREAMS_WINDOWS 20 | # else 21 | # define BOOST_IOSTREAMS_POSIX 22 | # endif 23 | #endif 24 | 25 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_WINDOWS_POSIX_HPP_INCLUDED 26 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/file_handle.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the Boost Software License, Version 1.0.(See accompanying 3 | * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 4 | * 5 | * See http://www.boost.org/libs/iostreams for documentation. 6 | * 7 | * File: boost/iostreams/detail/file_handle.hpp 8 | * Date: Sun Jun 22 14:23:12 MDT 2008 9 | * Copyright: 2008 CodeRage, LLC 10 | * Author: Jonathan Turkanis 11 | * Contact: turkanis at coderage dot com 12 | * 13 | * Defines the type boost::iostreams::detail::file_handle, representing an 14 | * operating system file handle. 15 | */ 16 | 17 | #ifndef BOOST_IOSTREAMS_DETAIL_FILE_HANDLE_HPP_INCLUDED 18 | #define BOOST_IOSTREAMS_DETAIL_FILE_HANDLE_HPP_INCLUDED 19 | 20 | #include 21 | 22 | namespace boost { namespace iostreams { namespace detail { 23 | 24 | #ifdef BOOST_IOSTREAMS_WINDOWS 25 | typedef void* file_handle; // A.k.a. HANDLE 26 | #else 27 | typedef int file_handle; 28 | #endif 29 | 30 | } } } // End namespaces detail, iostreams, boost. 31 | 32 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_FILE_HANDLE_HPP_INCLUDED 33 | -------------------------------------------------------------------------------- /doc/portability.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Portability 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Portability

13 | 14 | 15 | 16 | 17 |

18 | The Iostreams library has been tested with a wide variety of platforms. Please see the Boost regression reports for details. 19 |

20 | 21 | 22 | 23 |
24 | 25 | 26 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /include/boost/iostreams/operations_fwd.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_OPERATIONS_FWD_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_OPERATIONS_FWD_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include 16 | #include 17 | 18 | namespace boost { namespace iostreams { 19 | 20 | template 21 | struct operations; 22 | 23 | namespace detail { 24 | 25 | struct custom_tag { }; 26 | 27 | template 28 | struct is_custom 29 | : mpl::not_< 30 | is_base_and_derived< custom_tag, operations > 31 | > 32 | { }; 33 | 34 | } // End namespace detail. 35 | 36 | template 37 | struct operations : detail::custom_tag { }; 38 | 39 | } } // End namespaces iostreams, boost. 40 | 41 | #endif // #ifndef BOOST_IOSTREAMS_OPERATIONS_FWD_HPP_INCLUDED //--------------// 42 | -------------------------------------------------------------------------------- /doc/functions/slice.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Function Template slice 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Function Template slice

13 | 14 | 15 | 16 | 17 | 18 |

Description

19 | 20 |

21 | Alias of restrict, useful on platforms that treat restrict as a keyword. 22 |

23 | 24 | 25 | 26 |
27 | 28 | 29 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /test/filtering_stream_flush_test.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2011 Steven Watanabe 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 4 | 5 | // See http://www.boost.org/libs/iostreams for documentation. 6 | 7 | #include 8 | #include 9 | #include 10 | #include "detail/sequence.hpp" 11 | #include "detail/temp_file.hpp" 12 | #include "detail/verification.hpp" 13 | 14 | void test_filtering_ostream_flush() 15 | { 16 | using namespace std; 17 | using namespace boost; 18 | using namespace boost::iostreams; 19 | using namespace boost::iostreams::test; 20 | 21 | lowercase_file lower; 22 | 23 | { 24 | temp_file dest; 25 | filtering_ostream out; 26 | out.push(tolower_filter()); 27 | out.push(file_sink(dest.name(), out_mode)); 28 | write_data_in_chars(out); 29 | out.flush(); 30 | BOOST_CHECK_MESSAGE( 31 | compare_files(dest.name(), lower.name()), 32 | "failed writing to a filtering_ostream in chars with an " 33 | "output filter" 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/is_iterator_range.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_IS_ITERATOR_RANGE_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_IS_ITERATOR_RANGE_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | // Must come last. 16 | #include 17 | 18 | namespace boost { 19 | 20 | // We avoid dependence on Boost.Range by using a forward declaration. 21 | template 22 | class iterator_range; 23 | 24 | namespace iostreams { 25 | 26 | BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_iterator_range, boost::iterator_range, 1) 27 | 28 | } // End namespace iostreams. 29 | 30 | } // End namespace boost. 31 | 32 | #include 33 | 34 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_IS_ITERATOR_RANGE_HPP_INCLUDED 35 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/config/overload_resolution.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | // Adapted from and from 9 | // http://www.boost.org/more/separate_compilation.html, by John Maddock. 10 | 11 | #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_BROKEN_OVERLOAD_RESOLUTION_HPP_INCLUDED 12 | #define BOOST_IOSTREAMS_DETAIL_CONFIG_BROKEN_OVERLOAD_RESOLUTION_HPP_INCLUDED 13 | 14 | #if defined(_MSC_VER) 15 | # pragma once 16 | #endif 17 | 18 | #include // BOOST_MSVC. 19 | #include 20 | #include 21 | 22 | #if !defined(BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION) 23 | # if BOOST_WORKAROUND(__MWERKS__, <= 0x3003) || \ 24 | BOOST_WORKAROUND(__BORLANDC__, < 0x600) \ 25 | /**/ 26 | # define BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION 27 | # endif 28 | #endif 29 | 30 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_BROKEN_OVERLOAD_RESOLUTION_HPP_INCLUDED 31 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/broken_overload_resolution/forward.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_HPP_INCLUDED 10 | 11 | #include // BOOST_STATIC_CONSANT. 12 | #include 13 | #include 14 | 15 | namespace boost { namespace iostreams { namespace detail { 16 | 17 | template 18 | struct forward_impl { 19 | BOOST_STATIC_CONSTANT(bool, value = 20 | ( !is_same< U, Device >::value && 21 | !is_same< U, reference_wrapper >::value )); 22 | }; 23 | 24 | template 25 | struct forward 26 | : mpl::bool_::value> 27 | { }; 28 | 29 | } } } // End namespaces detail, iostreams, boost. 30 | 31 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_HPP_INCLUDED 32 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/config/dyn_link.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | // Adapted from http://www.boost.org/more/separate_compilation.html, by 9 | // John Maddock. 10 | 11 | #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_DYN_LINK_HPP_INCLUDED 12 | #define BOOST_IOSTREAMS_DETAIL_CONFIG_DYN_LINK_HPP_INCLUDED 13 | 14 | #if defined(_MSC_VER) 15 | # pragma once 16 | #endif 17 | 18 | #include 19 | #include 20 | 21 | //------------------Enable dynamic linking on windows-------------------------// 22 | 23 | #ifdef BOOST_HAS_DECLSPEC 24 | # if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_IOSTREAMS_DYN_LINK) 25 | # ifdef BOOST_IOSTREAMS_SOURCE 26 | # define BOOST_IOSTREAMS_DECL __declspec(dllexport) 27 | # else 28 | # define BOOST_IOSTREAMS_DECL __declspec(dllimport) 29 | # endif 30 | # endif 31 | #endif 32 | 33 | #ifndef BOOST_IOSTREAMS_DECL 34 | # define BOOST_IOSTREAMS_DECL 35 | #endif 36 | 37 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_DYN_LINK_HPP_INCLUDED 38 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/streambuf.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_STREAMBUF_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_STREAMBUF_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include 16 | #ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES 17 | # include 18 | #else 19 | # include 20 | #endif 21 | 22 | #ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES 23 | # define BOOST_IOSTREAMS_BASIC_STREAMBUF(ch, tr) std::basic_streambuf< ch, tr > 24 | # define BOOST_IOSTREAMS_PUBSYNC pubsync 25 | # define BOOST_IOSTREAMS_PUBSEEKOFF pubseekoff 26 | # define BOOST_IOSTREAMS_PUBSEEKPOS pubseekpos 27 | #else 28 | # define BOOST_IOSTREAMS_BASIC_STREAMBUF(ch, tr) std::streambuf 29 | # define BOOST_IOSTREAMS_PUBSYNC sync 30 | # define BOOST_IOSTREAMS_PUBSEEKOFF seekoff 31 | # define BOOST_IOSTREAMS_PUBSEEKPOS seekpos 32 | #endif 33 | 34 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_STREAMBUF_HPP_INCLUDED 35 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/enable_if_stream.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_ENABLE_IF_STREAM_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_ENABLE_IF_STREAM_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include // BOOST_NO_SFINAE. 16 | #include 17 | #include // is_std_io. 18 | 19 | #if !defined(BOOST_NO_SFINAE) && \ 20 | !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) 21 | # define BOOST_IOSTREAMS_ENABLE_IF_STREAM(T) \ 22 | , typename boost::enable_if< boost::iostreams::is_std_io >::type* = 0 \ 23 | /**/ 24 | # define BOOST_IOSTREAMS_DISABLE_IF_STREAM(T) \ 25 | , typename boost::disable_if< boost::iostreams::is_std_io >::type* = 0 \ 26 | /**/ 27 | #else 28 | # define BOOST_IOSTREAMS_ENABLE_IF_STREAM(T) 29 | # define BOOST_IOSTREAMS_DISABLE_IF_STREAM(T) 30 | #endif 31 | 32 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_ENABLE_IF_STREAM_HPP_INCLUDED 33 | -------------------------------------------------------------------------------- /doc/reference.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Iostreams Library Reference 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 |

Reference

17 | 18 | 19 | 20 | 21 |

4. Reference

22 | 23 |

24 | 4.1. Concepts
25 | 4.2. Classes
26 | 4.3. Functions
27 | 4.4. Macros 28 |

29 | 30 | 31 | 32 | 33 |
34 | 35 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /test/null_test.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "detail/temp_file.hpp" 14 | #include "detail/verification.hpp" 15 | 16 | using namespace std; 17 | using namespace boost; 18 | using namespace boost::iostreams; 19 | using namespace boost::iostreams::test; 20 | using boost::unit_test::test_suite; 21 | 22 | void read_null_source() 23 | { 24 | stream in; 25 | in.open(null_source()); 26 | in.get(); 27 | BOOST_CHECK(in.eof()); 28 | } 29 | 30 | void write_null_sink() 31 | { 32 | stream out; 33 | out.open(null_sink()); 34 | write_data_in_chunks(out); 35 | BOOST_CHECK(out.good()); 36 | } 37 | 38 | test_suite* init_unit_test_suite(int, char* []) 39 | { 40 | test_suite* test = BOOST_TEST_SUITE("null test"); 41 | test->add(BOOST_TEST_CASE(&read_null_source)); 42 | test->add(BOOST_TEST_CASE(&write_null_sink)); 43 | return test; 44 | } 45 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/fstream.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_FSTREAM_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_FSTREAM_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include 16 | #ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES 17 | # include 18 | #else 19 | # include 20 | #endif 21 | 22 | #ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES 23 | # define BOOST_IOSTREAMS_BASIC_IFSTREAM(Ch, Tr) std::basic_ifstream 24 | # define BOOST_IOSTREAMS_BASIC_OFSTREAM(Ch, Tr) std::basic_ofstream 25 | # define BOOST_IOSTREAMS_BASIC_FSTREAM(Ch, Tr) std::basic_fstream 26 | # define BOOST_IOSTREAMS_BASIC_FILEBUF(Ch) std::basic_filebuf 27 | #else 28 | # define BOOST_IOSTREAMS_BASIC_IFSTREAM(Ch, Tr) std::ifstream 29 | # define BOOST_IOSTREAMS_BASIC_OFSTREAM(Ch, Tr) std::ofstream 30 | # define BOOST_IOSTREAMS_BASIC_FILEBUF(Ch) std::filebuf 31 | #endif 32 | 33 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_FSTREAM_HPP_INCLUDED 34 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/iostream.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_IOSTREAM_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_IOSTREAM_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include 16 | #ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES 17 | # include 18 | # include 19 | #else 20 | # include 21 | #endif 22 | 23 | #ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES 24 | # define BOOST_IOSTREAMS_BASIC_ISTREAM(ch, tr) std::basic_istream< ch, tr > 25 | # define BOOST_IOSTREAMS_BASIC_OSTREAM(ch, tr) std::basic_ostream< ch, tr > 26 | # define BOOST_IOSTREAMS_BASIC_IOSTREAM(ch, tr) std::basic_iostream< ch, tr > 27 | #else 28 | # define BOOST_IOSTREAMS_BASIC_STREAMBUF(ch, tr) std::streambuf 29 | # define BOOST_IOSTREAMS_BASIC_ISTREAM(ch, tr) std::istream 30 | # define BOOST_IOSTREAMS_BASIC_OSTREAM(ch, tr) std::ostream 31 | # define BOOST_IOSTREAMS_BASIC_IOSTREAM(ch, tr) std::iostream 32 | #endif 33 | 34 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_IOSTREAM_HPP_INCLUDED 35 | -------------------------------------------------------------------------------- /include/boost/iostreams/device/back_inserter.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_BACK_INSERTER_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_BACK_INSERTER_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include // streamsize. 16 | #include 17 | 18 | namespace boost { namespace iostreams { 19 | 20 | template 21 | class back_insert_device { 22 | public: 23 | typedef typename Container::value_type char_type; 24 | typedef sink_tag category; 25 | back_insert_device(Container& cnt) : container(&cnt) { } 26 | std::streamsize write(const char_type* s, std::streamsize n) 27 | { 28 | container->insert(container->end(), s, s + n); 29 | return n; 30 | } 31 | protected: 32 | Container* container; 33 | }; 34 | 35 | template 36 | back_insert_device back_inserter(Container& cnt) 37 | { return back_insert_device(cnt); } 38 | 39 | } } // End namespaces iostreams, boost. 40 | 41 | #endif // #ifndef BOOST_IOSTREAMS_BACK_INSERTER_HPP_INCLUDED 42 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/config/fpos.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the Boost Software License, Version 1.0.(See accompanying 3 | * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 4 | * 5 | * See http://www.boost.org/libs/iostreams for documentation. 6 | 7 | * File: boost/iostreams/detail/execute.hpp 8 | * Date: Thu Dec 06 13:21:54 MST 2007 9 | * Copyright: 2007-2008 CodeRage, LLC 10 | * Author: Jonathan Turkanis 11 | * Contact: turkanis at coderage dot com 12 | * 13 | * Defines the preprocessor symbol BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS for 14 | * platforms that use the implementation of std::fpos from the Dinkumware 15 | * Standard Library. 16 | */ 17 | 18 | #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_FPOS_HPP_INCLUDED 19 | #define BOOST_IOSTREAMS_DETAIL_CONFIG_FPOS_HPP_INCLUDED 20 | 21 | #if defined(_MSC_VER) 22 | # pragma once 23 | #endif 24 | 25 | #include 26 | 27 | # if (defined(_YVALS) || defined(_CPPLIB_VER)) && !defined(__SGI_STL_PORT) && \ 28 | !defined(_STLPORT_VERSION) && !defined(__QNX__) && !defined(_VX_CPU) 29 | /**/ 30 | 31 | #include 32 | 33 | # define BOOST_IOSTREAMS_HAS_DINKUMWARE_FPOS 34 | 35 | #if !defined(_FPOSOFF) 36 | #define BOOST_IOSTREAMS_FPOSOFF(fp) ((long long)(fp)) 37 | #else 38 | #define BOOST_IOSTREAMS_FPOSOFF(fp) _FPOSOFF(fp) 39 | #endif 40 | 41 | # endif 42 | 43 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_FPOS_HPP_INCLUDED 44 | -------------------------------------------------------------------------------- /doc/guide/buffering.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Buffering 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

User's Guide

13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 25 | 26 | 27 | 28 |

3.11 Buffering

29 | 30 |
31 | 32 |

33 | [To be supplied in the next release] 34 |

35 | 36 | 37 | 38 |
39 | 40 | 41 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /include/boost/iostreams/constants.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | // Contains constants used by library. 9 | 10 | #ifndef BOOST_IOSTREAMS_CONSTANTS_HPP_INCLUDED 11 | #define BOOST_IOSTREAMS_CONSTANTS_HPP_INCLUDED 12 | 13 | #if defined(_MSC_VER) 14 | # pragma once 15 | #endif 16 | 17 | #ifndef BOOST_IOSTREAMS_DEFAULT_DEVICE_BUFFER_SIZE 18 | # define BOOST_IOSTREAMS_DEFAULT_DEVICE_BUFFER_SIZE 4096 19 | #endif 20 | 21 | #ifndef BOOST_IOSTREAMS_DEFAULT_FILTER_BUFFER_SIZE 22 | # define BOOST_IOSTREAMS_DEFAULT_FILTER_BUFFER_SIZE 128 23 | #endif 24 | 25 | #ifndef BOOST_IOSTREAMS_DEFAULT_PBACK_BUFFER_SIZE 26 | # define BOOST_IOSTREAMS_DEFAULT_PBACK_BUFFER_SIZE 4 27 | #endif 28 | 29 | #include // streamsize. 30 | 31 | namespace boost { namespace iostreams { 32 | 33 | const std::streamsize default_device_buffer_size = 34 | BOOST_IOSTREAMS_DEFAULT_DEVICE_BUFFER_SIZE; 35 | const std::streamsize default_filter_buffer_size = 36 | BOOST_IOSTREAMS_DEFAULT_FILTER_BUFFER_SIZE; 37 | const std::streamsize default_pback_buffer_size = 38 | BOOST_IOSTREAMS_DEFAULT_PBACK_BUFFER_SIZE; 39 | 40 | } } // End namespaces iostreams, boost. 41 | 42 | #endif // #ifndef BOOST_IOSTREAMS_CONSTANTS_HPP_INCLUDED 43 | -------------------------------------------------------------------------------- /doc/guide/lifetimes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Object Lifetimes 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

User's Guide

13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 25 | 26 | 27 | 28 |

3.7 Object Lifetimes

29 | 30 |
31 | 32 |

33 | [To be supplied in the next release] 34 |

35 | 36 | 37 | 38 |
39 | 40 | 41 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/config/disable_warnings.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #include // BOOST_MSVC. 9 | #include // BOOST_WORKAROUND. 10 | 11 | #if defined(BOOST_MSVC) 12 | # pragma warning(push) 13 | # pragma warning(disable:4127) // Conditional expression is constant. 14 | # pragma warning(disable:4130) // Logical operation on address of string constant. 15 | # pragma warning(disable:4224) // Parameter previously defined as type. 16 | # pragma warning(disable:4244) // Conversion: possible loss of data. 17 | # pragma warning(disable:4512) // Assignment operator could not be generated. 18 | # pragma warning(disable:4706) // Assignment within conditional expression. 19 | # if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) 20 | # pragma warning(disable:6334) // sizeof applied to an expression with an operator. 21 | # endif 22 | #else 23 | # if BOOST_WORKAROUND(__BORLANDC__, < 0x600) 24 | # pragma warn -8008 // Condition always true/false. 25 | # pragma warn -8066 // Unreachable code. 26 | # pragma warn -8071 // Conversion may lose significant digits. 27 | # pragma warn -8072 // Suspicious pointer arithmetic. 28 | # pragma warn -8080 // identifier declared but never used. 29 | # endif 30 | #endif 31 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/adapter/output_iterator_adapter.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_OUTPUT_ITERATOR_ADAPTER_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_OUTPUT_ITERATOR_ADAPTER_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include // copy. 16 | #include // streamsize. 17 | #include // tags. 18 | #include 19 | #include 20 | 21 | namespace boost { namespace iostreams { namespace detail { 22 | 23 | template 24 | class output_iterator_adapter { 25 | public: 26 | BOOST_STATIC_ASSERT((is_convertible::value)); 27 | typedef Ch char_type; 28 | typedef sink_tag category; 29 | explicit output_iterator_adapter(OutIt out) : out_(out) { } 30 | std::streamsize write(const char_type* s, std::streamsize n) 31 | { 32 | std::copy(s, s + n, out_); 33 | return n; 34 | } 35 | private: 36 | OutIt out_; 37 | }; 38 | 39 | } } } // End namespaces detail, iostreams, boost. 40 | 41 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_OUTPUT_ITERATOR_ADAPTER_HPP_INCLUDED //-----// 42 | -------------------------------------------------------------------------------- /doc/guide/guide.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Guide 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

User's Guide

13 | 14 | 15 | 16 | 17 |

3. User's Guide

18 | 19 |

20 | 3.1 Concepts
21 | 3.2 Modes
22 | 3.3 Generic Streams and Stream Buffers
23 | 3.4 Filtering Streams and Stream Buffers
24 | 3.5 Code Conversion
25 | 3.6 Asynchronous and Non-Blocking I/O
26 | 3.7 Object Lifetimes
27 | 3.8 Pipelines
28 | 3.9 Views
29 | 3.10 Exceptions
30 | 3.11 Buffering 31 |

32 | 33 | 34 | 35 |
36 | 37 | 38 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/error.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_ERROR_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_ERROR_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include // failure. 16 | 17 | namespace boost { namespace iostreams { namespace detail { 18 | 19 | inline BOOST_IOSTREAMS_FAILURE cant_read() 20 | { return BOOST_IOSTREAMS_FAILURE("no read access"); } 21 | 22 | inline BOOST_IOSTREAMS_FAILURE cant_write() 23 | { return BOOST_IOSTREAMS_FAILURE("no write access"); } 24 | 25 | inline BOOST_IOSTREAMS_FAILURE cant_seek() 26 | { return BOOST_IOSTREAMS_FAILURE("no random access"); } 27 | 28 | inline BOOST_IOSTREAMS_FAILURE bad_read() 29 | { return BOOST_IOSTREAMS_FAILURE("bad read"); } 30 | 31 | inline BOOST_IOSTREAMS_FAILURE bad_putback() 32 | { return BOOST_IOSTREAMS_FAILURE("putback buffer full"); } 33 | 34 | inline BOOST_IOSTREAMS_FAILURE bad_write() 35 | { return BOOST_IOSTREAMS_FAILURE("bad write"); } 36 | 37 | inline BOOST_IOSTREAMS_FAILURE write_area_exhausted() 38 | { return BOOST_IOSTREAMS_FAILURE("write area exhausted"); } 39 | 40 | inline BOOST_IOSTREAMS_FAILURE bad_seek() 41 | { return BOOST_IOSTREAMS_FAILURE("bad seek"); } 42 | 43 | } } } // End namespaces detail, iostreams, boost. 44 | 45 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_ERROR_HPP_INCLUDED 46 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/dispatch.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_DISPATCH_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_DISPATCH_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include // BOOST_DEDUCED_TYPENAME. 16 | #include 17 | #include // category_of. 18 | #include 19 | #include 20 | 21 | namespace boost { namespace iostreams {namespace detail { 22 | 23 | template< typename T, typename Tag1, typename Tag2, 24 | typename Tag3 = mpl::void_, typename Tag4 = mpl::void_, 25 | typename Tag5 = mpl::void_, typename Tag6 = mpl::void_, 26 | typename Category = 27 | BOOST_DEDUCED_TYPENAME category_of::type > 28 | struct dispatch 29 | : iostreams::select< // Disambiguation for Tru64. 30 | is_convertible, Tag1, 31 | is_convertible, Tag2, 32 | is_convertible, Tag3, 33 | is_convertible, Tag4, 34 | is_convertible, Tag5, 35 | is_convertible, Tag6 36 | > 37 | { }; 38 | 39 | } } } // End namespaces detail, iostreams, boost. 40 | 41 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_DISPATCH_HPP_INCLUDED 42 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/add_facet.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | // Borrowed from 9 | 10 | #ifndef BOOST_IOSTREAMS_DETAIL_ADD_FACET_HPP_INCLUDED 11 | #define BOOST_IOSTREAMS_DETAIL_ADD_FACET_HPP_INCLUDED 12 | 13 | #if defined(_MSC_VER) 14 | # pragma once 15 | #endif 16 | 17 | #include // BOOST_DINKUMWARE_STDLIB. 18 | #include 19 | 20 | //------------------Definition of add_facet-----------------------------------// 21 | 22 | // Does STLport uses old Dinkumware locale? 23 | #if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && \ 24 | defined(_STLP_NO_OWN_IOSTREAMS) \ 25 | /**/ 26 | # if (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER) 27 | # define BOOST_IOSTREMS_STLPORT_WITH_OLD_DINKUMWARE 28 | # endif 29 | #endif 30 | 31 | namespace boost { namespace iostreams { namespace detail { 32 | 33 | template 34 | inline std::locale add_facet(const std::locale &l, Facet * f) 35 | { 36 | return 37 | #if BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1) || \ 38 | defined(BOOST_IOSTREMS_STLPORT_WITH_OLD_DINKUMWARE) \ 39 | /**/ 40 | std::locale(std::_Addfac(l, f)); 41 | #else 42 | // standard compatible 43 | std::locale(l, f); 44 | #endif 45 | } 46 | 47 | } } } // End namespaces detail, iostreams, boost. 48 | 49 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_ADD_FACET_HPP_INCLUDED 50 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/absolute_path.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the Boost Software License, Version 1.0.(See accompanying 3 | * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 4 | * 5 | * See http://www.boost.org/libs/iostreams for documentation. 6 | 7 | * File: boost/iostreams/detail/execute.hpp 8 | * Date: Thu Dec 06 13:21:54 MST 2007 9 | * Copyright: 2007-2008 CodeRage, LLC 10 | * Author: Jonathan Turkanis 11 | * Contact: turkanis at coderage dot com 12 | * 13 | * Defines the function boost::iostreams::detail::absolute_path, used for 14 | * debug output for mapped files. 15 | */ 16 | 17 | #ifndef BOOST_IOSTREAMS_DETAIL_ABSOLUTE_PATH_HPP_INCLUDED 18 | #define BOOST_IOSTREAMS_DETAIL_ABSOLUTE_PATH_HPP_INCLUDED 19 | 20 | #include 21 | #include 22 | #ifdef BOOST_IOSTREAMS_WINDOWS 23 | # include 24 | #endif 25 | #include 26 | 27 | namespace boost { namespace iostreams { namespace detail { 28 | 29 | // Resolves the given path relative to the current working directory 30 | inline std::string absolute_path(const std::string& path) 31 | { 32 | #ifdef BOOST_IOSTREAMS_WINDOWS 33 | return path.size() && (path[0] == '/' || path[0] == '\\') || 34 | path.size() > 1 && std::isalpha(path[0]) && path[1] == ':' ? 35 | path : 36 | current_directory() + '\\' + path; 37 | #else // #ifdef BOOST_IOSTREAMS_WINDOWS 38 | return path.size() && (path[0] == '/') ? 39 | path : 40 | current_directory() + '/' + path; 41 | #endif // #ifdef BOOST_IOSTREAMS_WINDOWS 42 | } 43 | 44 | } } } // End namespaces detail, iostreams, boost. 45 | 46 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_ABSOLUTE_PATH_HPP_INCLUDED 47 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/config/bzip2.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | // Adapted from and from 9 | // http://www.boost.org/more/separate_compilation.html, by John Maddock. 10 | 11 | #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_BZIP2_HPP_INCLUDED 12 | #define BOOST_IOSTREAMS_DETAIL_CONFIG_BZIP2_HPP_INCLUDED 13 | 14 | #if defined(_MSC_VER) 15 | # pragma once 16 | #endif 17 | 18 | #if defined(BOOST_BZIP2_BINARY) 19 | # if defined(BOOST_MSVC) || \ 20 | defined(__BORLANDC__) || \ 21 | (defined(__MWERKS__) && defined(_WIN32) && (__MWERKS__ >= 0x3000)) || \ 22 | (defined(__ICL) && defined(_MSC_EXTENSIONS)) \ 23 | /**/ 24 | 25 | // Specify the name of the .lib file. 26 | # pragma comment(lib, BOOST_STRINGIZE(BOOST_BZIP2_BINARY)) 27 | # endif 28 | #else 29 | # if !defined(BOOST_IOSTREAMS_SOURCE) && \ 30 | !defined(BOOST_ALL_NO_LIB) && \ 31 | !defined(BOOST_IOSTREAMS_NO_LIB) \ 32 | /**/ 33 | 34 | // Set the name of our library, this will get undef'ed by auto_link.hpp 35 | // once it's done with it. 36 | # define BOOST_LIB_NAME boost_bzip2 37 | 38 | // If we're importing code from a dll, then tell auto_link.hpp about it. 39 | # if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_IOSTREAMS_DYN_LINK) 40 | # define BOOST_DYN_LINK 41 | # endif 42 | 43 | // And include the header that does the work. 44 | # include 45 | # endif 46 | #endif 47 | 48 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_BZIP2_HPP_INCLUDED 49 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/config/zlib.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | // Adapted from and from 9 | // http://www.boost.org/more/separate_compilation.html, by John Maddock. 10 | 11 | #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_ZLIB_HPP_INCLUDED 12 | #define BOOST_IOSTREAMS_DETAIL_CONFIG_ZLIB_HPP_INCLUDED 13 | 14 | #if defined(_MSC_VER) 15 | # pragma once 16 | #endif 17 | 18 | #include // BOOST_STRINGIZE. 19 | 20 | #if defined(BOOST_ZLIB_BINARY) 21 | # if defined(BOOST_MSVC) || \ 22 | defined(__BORLANDC__) || \ 23 | (defined(__MWERKS__) && defined(_WIN32) && (__MWERKS__ >= 0x3000)) || \ 24 | (defined(__ICL) && defined(_MSC_EXTENSIONS)) \ 25 | /**/ 26 | 27 | // Specify the name of the .lib file. 28 | # pragma comment(lib, BOOST_STRINGIZE(BOOST_ZLIB_BINARY)) 29 | # endif 30 | #else 31 | # if !defined(BOOST_IOSTREAMS_SOURCE) && \ 32 | !defined(BOOST_ALL_NO_LIB) && \ 33 | !defined(BOOST_IOSTREAMS_NO_LIB) \ 34 | /**/ 35 | 36 | // Set the name of our library, this will get undef'ed by auto_link.hpp 37 | // once it's done with it. 38 | # define BOOST_LIB_NAME boost_zlib 39 | 40 | // If we're importing code from a dll, then tell auto_link.hpp about it. 41 | # if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_IOSTREAMS_DYN_LINK) 42 | # define BOOST_DYN_LINK 43 | # endif 44 | 45 | // And include the header that does the work. 46 | # include 47 | # endif 48 | #endif 49 | 50 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_ZLIB_HPP_INCLUDED 51 | -------------------------------------------------------------------------------- /test/stream_offset_32bit_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the Boost Software License, Version 1.0.(See accompanying 3 | * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 4 | * 5 | * See http://www.boost.org/libs/iostreams for documentation. 6 | 7 | * File: libs/iostreams/test/stream_offset_32bit_test.cpp 8 | * Date: Sun Dec 23 21:11:23 MST 2007 9 | * Copyright: 2007-2008 CodeRage, LLC 10 | * Author: Jonathan Turkanis 11 | * Contact: turkanis at coderage dot com 12 | * 13 | * Tests the functions defined in the header "boost/iostreams/positioning.hpp" 14 | * with small (32-bit) file offsets. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | using namespace std; 23 | using namespace boost; 24 | using namespace boost::iostreams; 25 | using boost::unit_test::test_suite; 26 | 27 | void stream_offset_32bit_test() 28 | { 29 | stream_offset small_file = 1000000; 30 | stream_offset off = -small_file; 31 | streampos pos = offset_to_position(off); 32 | 33 | while (off < small_file) 34 | { 35 | BOOST_CHECK(off == position_to_offset(offset_to_position(off))); 36 | BOOST_CHECK(pos == offset_to_position(position_to_offset(pos))); 37 | off += 20000; 38 | pos += 20000; 39 | BOOST_CHECK(off == position_to_offset(offset_to_position(off))); 40 | BOOST_CHECK(pos == offset_to_position(position_to_offset(pos))); 41 | off -= 10000; 42 | pos -= 10000; 43 | } 44 | } 45 | 46 | test_suite* init_unit_test_suite(int, char* []) 47 | { 48 | test_suite* test = BOOST_TEST_SUITE("stream_offset 32-bit test"); 49 | test->add(BOOST_TEST_CASE(&stream_offset_32bit_test)); 50 | return test; 51 | } 52 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/config/auto_link.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | // Adapted from and from 9 | // http://www.boost.org/more/separate_compilation.html, by John Maddock. 10 | 11 | #ifndef BOOST_IOSTREAMS_DETAIL_AUTO_LINK_HPP_INCLUDED 12 | #define BOOST_IOSTREAMS_DETAIL_AUTO_LINK_HPP_INCLUDED 13 | 14 | #if defined(_MSC_VER) 15 | # pragma once 16 | #endif 17 | 18 | #if defined(BOOST_EXTERNAL_LIB_NAME) 19 | # if defined(BOOST_MSVC) \ 20 | || defined(__BORLANDC__) \ 21 | || (defined(__MWERKS__) && defined(_WIN32) && (__MWERKS__ >= 0x3000)) \ 22 | || (defined(__ICL) && defined(_MSC_EXTENSIONS)) \ 23 | /**/ 24 | # pragma comment(lib, BOOST_EXTERNAL_LIB_NAME) 25 | # endif 26 | # undef BOOST_EXTERNAL_LIB_NAME 27 | #endif 28 | 29 | //------------------Enable automatic library variant selection----------------// 30 | 31 | #if !defined(BOOST_IOSTREAMS_SOURCE) && \ 32 | !defined(BOOST_ALL_NO_LIB) && \ 33 | !defined(BOOST_IOSTREAMS_NO_LIB) \ 34 | /**/ 35 | 36 | // Set the name of our library, this will get undef'ed by auto_link.hpp 37 | // once it's done with it. 38 | # define BOOST_LIB_NAME boost_iostreams 39 | 40 | // If we're importing code from a dll, then tell auto_link.hpp about it. 41 | # if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_IOSTREAMS_DYN_LINK) 42 | # define BOOST_DYN_LINK 43 | # endif 44 | 45 | // And include the header that does the work. 46 | # include 47 | #endif // auto-linking disabled 48 | 49 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_AUTO_LINK_HPP_INCLUDED 50 | -------------------------------------------------------------------------------- /test/seekable_file_test.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "detail/temp_file.hpp" 14 | #include "detail/verification.hpp" 15 | 16 | using namespace std; 17 | using namespace boost; 18 | using namespace boost::iostreams; 19 | using namespace boost::iostreams::test; 20 | using boost::unit_test::test_suite; 21 | 22 | void seekable_file_test() 23 | { 24 | { 25 | temp_file temp; 26 | file f( temp.name(), 27 | BOOST_IOS::in | BOOST_IOS::out | 28 | BOOST_IOS::trunc | BOOST_IOS::binary); 29 | filtering_stream io(f); 30 | io.exceptions(BOOST_IOS::failbit | BOOST_IOS::badbit); 31 | BOOST_CHECK_MESSAGE( 32 | test_seekable_in_chars(io), 33 | "failed seeking within a file, in chars" 34 | ); 35 | } 36 | 37 | { 38 | temp_file temp; 39 | file f( temp.name(), 40 | BOOST_IOS::in | BOOST_IOS::out | 41 | BOOST_IOS::trunc | BOOST_IOS::binary); 42 | filtering_stream io(f); 43 | io.exceptions(BOOST_IOS::failbit | BOOST_IOS::badbit); 44 | BOOST_CHECK_MESSAGE( 45 | test_seekable_in_chunks(io), 46 | "failed seeking within a file, in chunks" 47 | ); 48 | } 49 | } 50 | 51 | test_suite* init_unit_test_suite(int, char* []) 52 | { 53 | test_suite* test = BOOST_TEST_SUITE("seekable file test"); 54 | test->add(BOOST_TEST_CASE(&seekable_file_test)); 55 | return test; 56 | } 57 | -------------------------------------------------------------------------------- /test/seek_test.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_TEST_SEEK_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_TEST_SEEK_HPP_INCLUDED 10 | 11 | 12 | #include // BOOST_MSVC, make sure size_t is in std. 13 | #include // std::size_t. 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "../example/container_device.hpp" // We use container_device instead 19 | #include "detail/verification.hpp" // of make_iterator_range to 20 | // reduce dependence on Boost.Range 21 | 22 | void seek_test() 23 | { 24 | using namespace std; 25 | using namespace boost; 26 | using namespace boost::iostreams; 27 | using namespace boost::iostreams::example; 28 | using namespace boost::iostreams::test; 29 | 30 | { 31 | string test(data_reps * data_length(), '\0'); 32 | filtering_stream io; 33 | io.push(container_device(test)); 34 | BOOST_CHECK_MESSAGE( 35 | test_seekable_in_chars(io), 36 | "failed seeking within a filtering_stream, in chars" 37 | ); 38 | } 39 | 40 | { 41 | string test(data_reps * data_length(), '\0'); 42 | filtering_stream io; 43 | io.push(container_device(test)); 44 | BOOST_CHECK_MESSAGE( 45 | test_seekable_in_chunks(io), 46 | "failed seeking within a filtering_stream, in chunks" 47 | ); 48 | } 49 | } 50 | 51 | #endif // #ifndef BOOST_IOSTREAMS_TEST_SEEK_HPP_INCLUDED 52 | -------------------------------------------------------------------------------- /test/zlib_test.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "detail/sequence.hpp" 15 | #include "detail/verification.hpp" 16 | 17 | using namespace std; 18 | using namespace boost; 19 | using namespace boost::iostreams; 20 | using namespace boost::iostreams::test; 21 | using boost::unit_test::test_suite; 22 | 23 | struct zlib_alloc : std::allocator { }; 24 | 25 | void zlib_test() 26 | { 27 | text_sequence data; 28 | BOOST_CHECK( 29 | test_filter_pair( zlib_compressor(), 30 | zlib_decompressor(), 31 | std::string(data.begin(), data.end()) ) 32 | ); 33 | BOOST_CHECK( 34 | test_filter_pair( basic_zlib_compressor(), 35 | basic_zlib_decompressor(), 36 | std::string(data.begin(), data.end()) ) 37 | ); 38 | BOOST_CHECK( 39 | test_filter_pair( zlib_compressor(), 40 | zlib_decompressor(), 41 | std::string() ) 42 | ); 43 | { 44 | filtering_istream strm; 45 | strm.push( zlib_compressor() ); 46 | strm.push( null_source() ); 47 | } 48 | { 49 | filtering_istream strm; 50 | strm.push( zlib_decompressor() ); 51 | strm.push( null_source() ); 52 | } 53 | } 54 | 55 | test_suite* init_unit_test_suite(int, char* []) 56 | { 57 | test_suite* test = BOOST_TEST_SUITE("zlib test"); 58 | test->add(BOOST_TEST_CASE(&zlib_test)); 59 | return test; 60 | } 61 | -------------------------------------------------------------------------------- /test/file_test.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #include 9 | #include 10 | #include 11 | #include "detail/temp_file.hpp" 12 | #include "detail/verification.hpp" 13 | 14 | using namespace boost; 15 | using namespace boost::iostreams; 16 | using namespace boost::iostreams::test; 17 | using std::ifstream; 18 | using boost::unit_test::test_suite; 19 | 20 | void file_test() 21 | { 22 | test_file test; 23 | 24 | //--------------Test file_source------------------------------------------// 25 | 26 | { 27 | file_source f(test.name()); 28 | BOOST_CHECK(f.is_open()); 29 | f.close(); 30 | BOOST_CHECK(!f.is_open()); 31 | f.open(test.name()); 32 | BOOST_CHECK(f.is_open()); 33 | } 34 | 35 | //--------------Test file_sink--------------------------------------------// 36 | 37 | { 38 | file_sink f(test.name()); 39 | BOOST_CHECK(f.is_open()); 40 | f.close(); 41 | BOOST_CHECK(!f.is_open()); 42 | f.open(test.name()); 43 | BOOST_CHECK(f.is_open()); 44 | } 45 | 46 | //--------------Test file-------------------------------------------------// 47 | 48 | { 49 | file f(test.name()); 50 | BOOST_CHECK(f.is_open()); 51 | f.close(); 52 | BOOST_CHECK(!f.is_open()); 53 | f.open(test.name()); 54 | BOOST_CHECK(f.is_open()); 55 | } 56 | } 57 | 58 | test_suite* init_unit_test_suite(int, char* []) 59 | { 60 | test_suite* test = BOOST_TEST_SUITE("file test"); 61 | test->add(BOOST_TEST_CASE(&file_test)); 62 | return test; 63 | } 64 | -------------------------------------------------------------------------------- /doc/guide/views.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Views 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

User's Guide

13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 25 | 26 | 27 | 28 |

3.9 Views

29 | 30 |
31 | 32 |

33 | Boost.Iostreams provides a number of templates for combining one or more Filters or Devices to produce a Filter or Device that performs i/o by delegating to the given components in a straightforward way. Each view consists of a class template, whose template parameters represnt the component Filters and Devices, together with an object generator. 34 |

35 | 36 |

37 | The views provided with Boost.Iostreams are summarized in the Quick Reference. 38 |

39 | 40 | 41 | 42 |
43 | 44 | 45 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/bool_trait_def.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_BOOL_TRAIT_DEF_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_BOOL_TRAIT_DEF_HPP_INCLUDED 10 | 11 | #include // BOOST_STATIC_CONSTANT. 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | // 20 | // Macro name: BOOST_IOSTREAMS_BOOL_TRAIT_DEF 21 | // Description: Used to generate the traits classes is_istream, is_ostream, 22 | // etc. 23 | // 24 | #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) 25 | # define BOOST_IOSTREAMS_TRAIT_NAMESPACE(trait) 26 | #else 27 | # define BOOST_IOSTREAMS_TRAIT_NAMESPACE(trait) BOOST_PP_CAT(trait, _impl_):: 28 | #endif 29 | #define BOOST_IOSTREAMS_BOOL_TRAIT_DEF(trait, type, arity) \ 30 | namespace BOOST_PP_CAT(trait, _impl_) { \ 31 | BOOST_IOSTREAMS_TEMPLATE_PARAMS(arity, T) \ 32 | type_traits::yes_type helper \ 33 | (const volatile type BOOST_IOSTREAMS_TEMPLATE_ARGS(arity, T)*); \ 34 | type_traits::no_type helper(...); \ 35 | template \ 36 | struct impl { \ 37 | BOOST_STATIC_CONSTANT(bool, value = \ 38 | (sizeof(BOOST_IOSTREAMS_TRAIT_NAMESPACE(trait) \ 39 | helper(static_cast(0))) == \ 40 | sizeof(type_traits::yes_type))); \ 41 | }; \ 42 | } \ 43 | template \ 44 | struct trait \ 45 | : mpl::bool_::value> \ 46 | { BOOST_MPL_AUX_LAMBDA_SUPPORT(1, trait, (T)) }; \ 47 | /**/ 48 | 49 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_BOOL_TRAIT_DEF_HPP_INCLUDED 50 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/config/wide_streams.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | // Adapted from http://www.boost.org/more/separate_compilation.html, by 9 | // John Maddock. 10 | 11 | #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_WIDE_STREAMS_HPP_INCLUDED 12 | #define BOOST_IOSTREAMS_DETAIL_CONFIG_WIDE_STREAMS_HPP_INCLUDED 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #if defined(_MSC_VER) 19 | # pragma once 20 | #endif 21 | 22 | //------------------Templated stream support----------------------------------// 23 | 24 | // From boost/dynamic_bitset.hpp; thanks to Matthias Troyer for cray patch. 25 | #ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES 26 | # if defined(__STL_CONFIG_H) && \ 27 | !defined (__STL_USE_NEW_IOSTREAMS) && !defined(__crayx1) \ 28 | /**/ 29 | # define BOOST_IOSTREAMS_NO_STREAM_TEMPLATES 30 | # endif 31 | #endif // #ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES 32 | 33 | //------------------Wide stream support---------------------------------------// 34 | 35 | #ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS 36 | # if defined(BOOST_IOSTREAMS_NO_STREAM_TEMPLATES) || \ 37 | defined (BOOST_NO_STD_WSTREAMBUF) && \ 38 | ( !defined(__MSL_CPP__) || defined(_MSL_NO_WCHART_CPP_SUPPORT) ) \ 39 | /**/ 40 | # define BOOST_IOSTREAMS_NO_WIDE_STREAMS 41 | # endif 42 | #endif // #ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS 43 | 44 | //------------------Locale support--------------------------------------------// 45 | 46 | #ifndef BOOST_IOSTREAMS_NO_LOCALE 47 | # if defined(BOOST_NO_STD_LOCALE) || \ 48 | defined(__CYGWIN__) && \ 49 | ( !defined(__MSL_CPP__) || defined(_MSL_NO_WCHART_CPP_SUPPORT) ) \ 50 | /**/ 51 | # define BOOST_IOSTREAMS_NO_LOCALE 52 | # endif 53 | #endif // #ifndef BOOST_IOSTREAMS_NO_LOCALE 54 | 55 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_WIDE_STREAMS_HPP_INCLUDED 56 | -------------------------------------------------------------------------------- /test/windows_pipe_test.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // (C) Copyright 2012 Boris Schaeling 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 6 | 7 | // See http://www.boost.org/libs/iostreams for documentation. 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace boost::iostreams; 17 | using boost::unit_test::test_suite; 18 | 19 | void read_from_file_descriptor_source_test() 20 | { 21 | HANDLE handles[2]; 22 | ::CreatePipe(&handles[0], &handles[1], NULL, 0); 23 | 24 | char buffer[2] = { 'a', 'b' }; 25 | DWORD written; 26 | ::WriteFile(handles[1], buffer, 2, &written, NULL); 27 | ::CloseHandle(handles[1]); 28 | 29 | file_descriptor_source is(handles[0], close_handle); 30 | 31 | BOOST_CHECK_EQUAL('a', get(is)); 32 | BOOST_CHECK_EQUAL('b', get(is)); 33 | BOOST_CHECK_EQUAL(-1, get(is)); 34 | BOOST_CHECK_EQUAL(-1, get(is)); 35 | } 36 | 37 | void read_from_filtering_istream_test() 38 | { 39 | HANDLE handles[2]; 40 | ::CreatePipe(&handles[0], &handles[1], NULL, 0); 41 | 42 | char buffer[2] = { 'a', 'b' }; 43 | DWORD written; 44 | ::WriteFile(handles[1], buffer, 2, &written, NULL); 45 | ::CloseHandle(handles[1]); 46 | 47 | file_descriptor_source source(handles[0], close_handle); 48 | filtering_istream is; 49 | is.push(source); 50 | 51 | BOOST_CHECK_EQUAL('a', get(is)); 52 | BOOST_CHECK_EQUAL('b', get(is)); 53 | BOOST_CHECK_EQUAL(-1, get(is)); 54 | BOOST_CHECK_EQUAL(-1, get(is)); 55 | } 56 | 57 | test_suite* init_unit_test_suite(int, char* []) 58 | { 59 | test_suite* test = BOOST_TEST_SUITE("Windows pipe test"); 60 | test->add(BOOST_TEST_CASE(&read_from_file_descriptor_source_test)); 61 | test->add(BOOST_TEST_CASE(&read_from_filtering_istream_test)); 62 | return test; 63 | } 64 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/codecvt_holder.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | // Contains machinery for performing code conversion. 9 | 10 | #ifndef BOOST_IOSTREAMS_DETAIL_CODECVT_HOLDER_HPP_INCLUDED 11 | #define BOOST_IOSTREAMS_DETAIL_CODECVT_HOLDER_HPP_INCLUDED 12 | 13 | #if defined(_MSC_VER) 14 | # pragma once 15 | #endif 16 | 17 | #include // mbstate_t. 18 | #include // codecvt, locale. 19 | #include // HAS_MACRO_USE_FACET. 20 | #include 21 | 22 | namespace boost { namespace iostreams { namespace detail { 23 | 24 | struct default_codecvt { 25 | typedef wchar_t intern_type, from_type; 26 | typedef char extern_type, to_type; 27 | typedef std::mbstate_t state_type; 28 | }; 29 | 30 | template 31 | struct codecvt_holder { 32 | typedef Codecvt codecvt_type; 33 | const codecvt_type& get() const { return codecvt_; } 34 | void imbue(const std::locale&) { } 35 | Codecvt codecvt_; 36 | }; 37 | 38 | template<> 39 | struct codecvt_holder { 40 | typedef std::codecvt codecvt_type; 41 | codecvt_holder() { reset_codecvt(); } 42 | const codecvt_type& get() const { return *codecvt_; } 43 | void imbue(const std::locale& loc) 44 | { 45 | loc_ = loc; 46 | reset_codecvt(); 47 | } 48 | void reset_codecvt() 49 | { 50 | using namespace std; 51 | #ifndef BOOST_HAS_MACRO_USE_FACET 52 | codecvt_ = & use_facet< codecvt_type >(loc_); 53 | #else 54 | codecvt_ = & _USE(loc_, codecvt_type); 55 | #endif 56 | } 57 | std::locale loc_; // Prevent codecvt_ from being freed. 58 | const codecvt_type* codecvt_; 59 | }; 60 | 61 | } } } // End namespaces detail, iostreams, boost. 62 | 63 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_CODECVT_HOLDER_HPP_INCLUDED 64 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/adapter/device_adapter.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Defines the class template boost::iostreams::detail::device_adapter, 3 | * a convenience base class for device adapters. 4 | * 5 | * File: boost/iostreams/detail/adapter/filter_adapter.hpp 6 | * Date: Mon Nov 26 14:35:48 MST 2007 7 | * 8 | * Copyright: 2007-2008 CodeRage, LLC 9 | * Author: Jonathan Turkanis 10 | * Contact: turkanis at coderage dot com 11 | * 12 | * Distributed under the Boost Software License, Version 1.0.(See accompanying 13 | * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 14 | * 15 | * See http://www.boost.org/libs/iostreams for documentation. 16 | */ 17 | 18 | #ifndef BOOST_IOSTREAMS_DETAIL_DEVICE_ADAPTER_HPP_INCLUDED 19 | #define BOOST_IOSTREAMS_DETAIL_DEVICE_ADAPTER_HPP_INCLUDED 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace boost { namespace iostreams { namespace detail { 29 | 30 | template 31 | class device_adapter { 32 | private: 33 | typedef typename detail::value_type::type value_type; 34 | typedef typename detail::param_type::type param_type; 35 | public: 36 | explicit device_adapter(param_type t) : t_(t) { } 37 | T& component() { return t_; } 38 | 39 | void close() 40 | { 41 | detail::close_all(t_); 42 | } 43 | 44 | void close(BOOST_IOS::openmode which) 45 | { 46 | iostreams::close(t_, which); 47 | } 48 | 49 | bool flush() 50 | { 51 | return iostreams::flush(t_); 52 | } 53 | 54 | template // Avoid dependency on 55 | void imbue(const Locale& loc) { iostreams::imbue(t_, loc); } 56 | 57 | std::streamsize optimal_buffer_size() const 58 | { return iostreams::optimal_buffer_size(t_); } 59 | public: 60 | value_type t_; 61 | }; 62 | 63 | //----------------------------------------------------------------------------// 64 | 65 | } } } // End namespaces detail, iostreams, boost. 66 | 67 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_DEVICE_ADAPTER_HPP_INCLUDED 68 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/translate_int_type.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_TRANSLATE_INT_TYPE_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_TRANSLATE_INT_TYPE_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include 16 | 17 | namespace boost { namespace iostreams { namespace detail { 18 | 19 | template 20 | struct translate_int_type_impl; 21 | 22 | // 23 | // Template name: translate_char. 24 | // Description: Translates a character or an end-of-file indicator from the 25 | // int_type of one character traits type to the int_type of another. 26 | // 27 | template 28 | typename TargetTr::int_type 29 | translate_int_type(typename SourceTr::int_type c) 30 | { 31 | typedef translate_int_type_impl::value> impl; 32 | return impl::template inner::translate(c); 33 | } 34 | 35 | //----------------------------------------------------------------------------// 36 | 37 | template<> 38 | struct translate_int_type_impl { 39 | template 40 | struct inner { 41 | static typename TargetTr::int_type 42 | translate(typename SourceTr::int_type c) { return c; } 43 | }; 44 | }; 45 | 46 | template<> 47 | struct translate_int_type_impl { 48 | template 49 | struct inner { 50 | static typename TargetTr::int_type 51 | translate(typename SourceTr::int_type c) 52 | { 53 | return SourceTr::eq_int_type(SourceTr::eof()) ? 54 | TargetTr::eof() : 55 | TargetTr::to_int_type(SourceTr::to_char_type(c)); 56 | } 57 | }; 58 | }; 59 | 60 | } } } // End namespaces detail, iostreams, boost. 61 | 62 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_TRANSLATE_INT_TYPE_HPP_INCLUDED 63 | -------------------------------------------------------------------------------- /include/boost/iostreams/input_sequence.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_INPUT_SEQUENCE_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_INPUT_SEQUENCE_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include // pair. 16 | #include // DEDUCED_TYPENAME, MSVC. 17 | #include 18 | #include 19 | #include // is_custom 20 | #include 21 | #include 22 | 23 | // Must come last. 24 | #include 25 | 26 | namespace boost { namespace iostreams { 27 | 28 | namespace detail { 29 | 30 | template 31 | struct input_sequence_impl; 32 | 33 | } // End namespace detail. 34 | 35 | template 36 | inline std::pair< 37 | BOOST_DEDUCED_TYPENAME char_type_of::type*, 38 | BOOST_DEDUCED_TYPENAME char_type_of::type* 39 | > 40 | input_sequence(T& t) 41 | { return detail::input_sequence_impl::input_sequence(t); } 42 | 43 | namespace detail { 44 | 45 | //------------------Definition of direct_impl-------------------------------// 46 | 47 | template 48 | struct input_sequence_impl 49 | : mpl::if_< 50 | detail::is_custom, 51 | operations, 52 | input_sequence_impl 53 | >::type 54 | { }; 55 | 56 | template<> 57 | struct input_sequence_impl { 58 | template 59 | static std::pair< 60 | BOOST_DEDUCED_TYPENAME char_type_of::type*, 61 | BOOST_DEDUCED_TYPENAME char_type_of::type* 62 | > 63 | input_sequence(U& u) { return u.input_sequence(); } 64 | }; 65 | 66 | } // End namespace detail. 67 | 68 | } } // End namespaces iostreams, boost. 69 | 70 | #include 71 | 72 | #endif // #ifndef BOOST_IOSTREAMS_INPUT_SEQUENCE_HPP_INCLUDED 73 | -------------------------------------------------------------------------------- /include/boost/iostreams/output_sequence.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_OUTPUT_SEQUENCE_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_OUTPUT_SEQUENCE_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include // pair. 16 | #include // DEDUCED_TYPENAME, MSVC. 17 | #include 18 | #include 19 | #include // is_custom 20 | #include 21 | #include 22 | 23 | // Must come last. 24 | #include 25 | 26 | namespace boost { namespace iostreams { 27 | 28 | namespace detail { 29 | 30 | template 31 | struct output_sequence_impl; 32 | 33 | } // End namespace detail. 34 | 35 | template 36 | inline std::pair< 37 | BOOST_DEDUCED_TYPENAME char_type_of::type*, 38 | BOOST_DEDUCED_TYPENAME char_type_of::type* 39 | > 40 | output_sequence(T& t) 41 | { return detail::output_sequence_impl::output_sequence(t); } 42 | 43 | namespace detail { 44 | 45 | //------------------Definition of output_sequence_impl------------------------// 46 | 47 | template 48 | struct output_sequence_impl 49 | : mpl::if_< 50 | detail::is_custom, 51 | operations, 52 | output_sequence_impl 53 | >::type 54 | { }; 55 | 56 | template<> 57 | struct output_sequence_impl { 58 | template 59 | static std::pair< 60 | BOOST_DEDUCED_TYPENAME char_type_of::type*, 61 | BOOST_DEDUCED_TYPENAME char_type_of::type* 62 | > 63 | output_sequence(U& u) { return u.output_sequence(); } 64 | }; 65 | 66 | } // End namespace detail. 67 | 68 | } } // End namespaces iostreams, boost. 69 | 70 | #include 71 | 72 | #endif // #ifndef BOOST_IOSTREAMS_OUTPUT_SEQUENCE_HPP_INCLUDED 73 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/ios.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_IOS_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_IOS_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include // BOOST_MSVC. 16 | #include 17 | #include 18 | #ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES 19 | # if !BOOST_WORKAROUND(__MWERKS__, <= 0x3003) 20 | # include 21 | # else 22 | # include 23 | # include 24 | # endif 25 | #else 26 | # include 27 | # include 28 | #endif 29 | 30 | namespace boost { namespace iostreams { namespace detail { 31 | 32 | #ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //--------------------------------// 33 | # define BOOST_IOSTREAMS_BASIC_IOS(ch, tr) std::basic_ios< ch, tr > 34 | # if !BOOST_WORKAROUND(__MWERKS__, <= 0x3003) && \ 35 | !BOOST_WORKAROUND(__BORLANDC__, < 0x600) \ 36 | /**/ 37 | 38 | #define BOOST_IOS std::ios 39 | #define BOOST_IOSTREAMS_FAILURE std::ios::failure 40 | 41 | # else 42 | 43 | #define BOOST_IOS std::ios_base 44 | #define BOOST_IOSTREAMS_FAILURE std::ios_base::failure 45 | 46 | # endif 47 | #else // #ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //-----------------------// 48 | 49 | #define BOOST_IOS std::ios 50 | #define BOOST_IOSTREAMS_BASIC_IOS(ch, tr) std::ios 51 | #define BOOST_IOSTREAMS_FAILURE boost::iostreams::detail::failure 52 | 53 | class failure : std::exception { 54 | public: 55 | explicit failure(const std::string& what_arg) : what_(what_arg) { } 56 | const char* what() const { return what_.c_str(); } 57 | private: 58 | std::string what_; 59 | }; 60 | 61 | #endif // #ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //----------------------// 62 | 63 | } } } // End namespace failure, iostreams, boost. 64 | 65 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_IOS_HPP_INCLUDED 66 | -------------------------------------------------------------------------------- /test/detail/constants.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | // Contains the definitions of several constants used by the test program. 9 | 10 | #ifndef BOOST_IOSTREAMS_TEST_CONSTANTS_HPP_INCLUDED 11 | #define BOOST_IOSTREAMS_TEST_CONSTANTS_HPP_INCLUDED 12 | 13 | #include 14 | #include 15 | 16 | namespace boost { namespace iostreams { namespace test { 17 | 18 | // Note: openmode could be a class type, so this header must be included 19 | // by just one TU. 20 | const BOOST_IOS::openmode in_mode = BOOST_IOS::in | BOOST_IOS::binary; 21 | const BOOST_IOS::openmode out_mode = BOOST_IOS::out | BOOST_IOS::binary; 22 | 23 | // Chunk size for reading or writing in chunks. 24 | const int chunk_size = 59; 25 | 26 | // Chunk size for reading or writing in chunks. 27 | const int small_buffer_size = 23; 28 | 29 | // Number of times data is repeated in test files. 30 | const int data_reps = 300; 31 | 32 | namespace detail { 33 | 34 | // Returns string which is used to generate test files. 35 | inline const char* data(char*) 36 | { 37 | static const char* c = 38 | "!\"#$%&'()*+,-./0123456879:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ" 39 | "[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\n"; 40 | return c; 41 | } 42 | 43 | // Returns string which is used to generate test files. 44 | inline const wchar_t* data(wchar_t*) 45 | { 46 | static const wchar_t* c = 47 | L"!\"#$%&'()*+,-./0123456879:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ" 48 | L"[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\n"; 49 | return c; 50 | } 51 | 52 | } // End namespace detail. 53 | 54 | inline const char* narrow_data() { return detail::data((char*)0); } 55 | 56 | inline const wchar_t* wide_data() { return detail::data((wchar_t*)0); } 57 | 58 | // Length of string returned by data(). 59 | inline int data_length() 60 | { 61 | static int len = (int) strlen(narrow_data()); 62 | return len; 63 | } 64 | 65 | } } } // End namespaces detail, iostreams, boost. 66 | 67 | #endif // #ifndef BOOST_IOSTREAMS_TEST_CONSTANTS_HPP_INCLUDED 68 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/adapter/non_blocking_adapter.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2005-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_NON_BLOCKING_ADAPTER_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_NON_BLOCKING_ADAPTER_HPP_INCLUDED 10 | 11 | #include // streamsize, seekdir, openmode. 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace boost { namespace iostreams { 18 | 19 | template 20 | class non_blocking_adapter { 21 | public: 22 | typedef typename char_type_of::type char_type; 23 | struct category 24 | : mode_of::type, device_tag 25 | { }; 26 | explicit non_blocking_adapter(Device& dev) : device_(dev) { } 27 | std::streamsize read(char_type* s, std::streamsize n) 28 | { 29 | std::streamsize result = 0; 30 | while (result < n) { 31 | std::streamsize amt = iostreams::read(device_, s, n); 32 | if (amt == -1) 33 | break; 34 | result += amt; 35 | } 36 | return result != 0 ? result : -1; 37 | } 38 | std::streamsize write(const char_type* s, std::streamsize n) 39 | { 40 | std::streamsize result = 0; 41 | while (result < n) { 42 | std::streamsize amt = 43 | iostreams::write(device_, s + result, n - result); 44 | result += amt; 45 | } 46 | return result; 47 | } 48 | std::streampos seek( stream_offset off, BOOST_IOS::seekdir way, 49 | BOOST_IOS::openmode which = 50 | BOOST_IOS::in | BOOST_IOS::out ) 51 | { return iostreams::seek(device_, off, way, which); } 52 | public: 53 | non_blocking_adapter& operator=(const non_blocking_adapter&); 54 | Device& device_; 55 | }; 56 | 57 | } } // End namespace iostreams. 58 | 59 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_NON_BLOCKING_ADAPTER_HPP_INCLUDED 60 | -------------------------------------------------------------------------------- /doc/concepts/direct.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Direct 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Direct

13 | 14 | 15 | 16 | 17 |

Description

18 | 19 |

20 | A Device is Direct if it provides access to its controlled sequences as in-memory arrays rather than via a socket-like interface. The difference between a Device which is Direct and one which is not is reflected in the specifications of the various Device refinements, e.g., Source and Sink.

21 |

22 | 23 |

24 | A model of Device which does not model Direct is called indirect. 25 |

26 | 27 |

Refinement of

28 | 29 |

Device.

30 | 31 | 32 |

Associated Types

33 | 34 |

Same as Device, with the following additional requirements:

35 | 36 | 37 | 38 |
CategoryA type convertible to device_tag and to direct_tag
39 | 40 | 41 |

Valid Expressions / Semantics

42 | 43 |

Same as Device.

44 | 45 |

Models

46 | 47 | 51 | 52 | 53 | 54 |
55 | 56 | 57 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /include/boost/iostreams/device/null.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | // Inspired by Daryle Walker's nullbuf from his More I/O submission. 9 | 10 | #ifndef BOOST_IOSTREAMS_NULL_HPP_INCLUDED 11 | #define BOOST_IOSTREAMS_NULL_HPP_INCLUDED 12 | 13 | #if defined(_MSC_VER) 14 | # pragma once 15 | #endif 16 | 17 | #include 18 | #include // openmode, streamsize. 19 | #include 20 | 21 | namespace boost { namespace iostreams { 22 | 23 | template 24 | class basic_null_device { 25 | public: 26 | typedef Ch char_type; 27 | struct category 28 | : public Mode, 29 | public device_tag, 30 | public closable_tag 31 | { }; 32 | std::streamsize read(Ch*, std::streamsize) { return -1; } 33 | std::streamsize write(const Ch*, std::streamsize n) { return n; } 34 | std::streampos seek( stream_offset, BOOST_IOS::seekdir, 35 | BOOST_IOS::openmode = 36 | BOOST_IOS::in | BOOST_IOS::out ) 37 | { return -1; } 38 | void close() { } 39 | void close(BOOST_IOS::openmode) { } 40 | }; 41 | 42 | template 43 | struct basic_null_source : private basic_null_device { 44 | typedef Ch char_type; 45 | typedef source_tag category; 46 | using basic_null_device::read; 47 | using basic_null_device::close; 48 | }; 49 | 50 | typedef basic_null_source null_source; 51 | typedef basic_null_source wnull_source; 52 | 53 | template 54 | struct basic_null_sink : private basic_null_device { 55 | typedef Ch char_type; 56 | typedef sink_tag category; 57 | using basic_null_device::write; 58 | using basic_null_device::close; 59 | }; 60 | 61 | typedef basic_null_sink null_sink; 62 | typedef basic_null_sink wnull_sink; 63 | 64 | } } // End namespaces iostreams, boost. 65 | 66 | #endif // #ifndef BOOST_IOSTREAMS_NULL_HPP_INCLUDED 67 | -------------------------------------------------------------------------------- /test/read_input_test.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_TEST_READ_INPUT_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_TEST_READ_INPUT_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "detail/temp_file.hpp" 16 | #include "detail/verification.hpp" 17 | 18 | void read_input_test() 19 | { 20 | using namespace std; 21 | using namespace boost; 22 | using namespace boost::iostreams; 23 | using namespace boost::iostreams::test; 24 | 25 | test_file test1; 26 | test_file test2; 27 | 28 | { 29 | filtering_istream first(file_source(test1.name()), 0); 30 | ifstream second(test2.name().c_str()); 31 | BOOST_CHECK_MESSAGE( 32 | compare_streams_in_chars(first, second), 33 | "failed reading from filtering_istream in chars with no buffer" 34 | ); 35 | } 36 | 37 | { 38 | filtering_istream first(file_source(test1.name()), 0); 39 | ifstream second(test2.name().c_str()); 40 | BOOST_CHECK_MESSAGE( 41 | compare_streams_in_chunks(first, second), 42 | "failed reading from filtering_istream in chunks with no buffer" 43 | ); 44 | } 45 | 46 | { 47 | filtering_istream first(file_source(test1.name())); 48 | ifstream second(test2.name().c_str()); 49 | BOOST_CHECK_MESSAGE( 50 | compare_streams_in_chars(first, second), 51 | "failed reading from filtering_istream in chars with buffer" 52 | ); 53 | } 54 | 55 | { 56 | filtering_istream first(file_source(test1.name())); 57 | ifstream second(test2.name().c_str()); 58 | BOOST_CHECK_MESSAGE( 59 | compare_streams_in_chunks(first, second), 60 | "failed reading from filtering_istream in chunks with buffer" 61 | ); 62 | } 63 | } 64 | 65 | #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_INPUT_HPP_INCLUDED 66 | -------------------------------------------------------------------------------- /doc/concepts/optimally_buffered.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OptimallyBuffered 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

OptimallyBuffered

13 | 14 | 15 | 16 | 17 |

Description

18 | 19 |

20 | A OptimallyBuffered Filter or Device provides a way for the Iostreams library to determine the best size of buffer to allocate for it if the user doesn't explicitly specify a buffer size. 21 |

22 | 23 |

Refinement of

24 | 25 | 26 |

Associated Types

27 | 28 |

Notation

29 | 30 | 31 | 32 | 33 | 34 |
O-A type which is a model of OptimallyBuffered
o-Object of type O
io-Alias for namespace boost::iostreams
35 | 36 |

Valid Expressions / Semantics

37 | 38 | 39 | 40 | 41 | 44 | 45 | 46 | 47 |
ExpressionExpression TypeSemantics
42 |
io::optimal_buffer_size(o)
43 |
std::streamsizeReturns the size of buffer that should be allocated for o if the user has not explicitly specified a buffer size.
48 | 49 |

Models

50 | 53 | 54 | 55 | 56 |
57 | 58 | 59 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /doc/guide/text_processing.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Text Processing Filters 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Text Processing Filters

13 | 14 | 15 | 16 | 17 |
18 |
Overview
19 |
Headers
20 |
Reference
21 |
22 | 23 | 24 |

Overview

25 | 26 |

27 | The Boost Iostreams library provides two types of Filters for text processing: Regular Expression Filters, which use the Boost Regular Expression Library ([Maddock]) to perform text substitutions, and Newline Filters, which convert between the text file formats used by various operating systems. 28 |

29 | 30 | 31 |

Headers

32 | 33 |
34 |
<boost/iostreams/filter/regex.hpp>
35 |
<boost/iostreams/filter/newline.hpp>
36 |
37 | 38 | 39 |

Reference

40 | 41 |
42 |
Class template basic_regex_filter
43 |
Class template basic_newline_filter
44 |
45 | 46 | 47 | 48 |
49 | 50 | 51 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /doc/tutorial/tutorial.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Tutorial 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Tutorial

13 |
14 | 15 | 16 | 17 |

2. Tutorial

18 | 19 |

2.1. Writing Devices

20 | 21 |

22 | 2.1.1. Overview: Devices, stream_buffer and stream
23 | 2.1.2. Writing a container_source
24 | 2.1.3. Writing a container_sink
25 | 2.1.4. Writing a container_device
26 |

27 | 28 |

2.2. Writing Filters

29 | 30 |

31 | 2.2.1. Overview: InputFilters, OutputFilters and Filter Helpers
32 | 2.2.2. Filter Usage Examples
33 | 2.2.3. Shell Comments Filters
34 | 2.2.4. Line-Wrapping Filters
35 | 2.2.5. Tab-Expanding Filters
36 | 2.2.6. Dictionary Filters
37 | 2.2.7. UNIX-to-DOS Filters
38 | 2.2.8. Multi-Character Filters
39 | 2.2.9. Dual-Use Filters
40 | 2.2.10. Finite State Filters 41 |

42 | 43 | 44 | 45 |
46 | 47 | 48 | 49 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/adapter/filter_adapter.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Defines the class template boost::iostreams::detail::filter_adapter, 3 | * a convenience base class for filter adapters. 4 | * 5 | * File: boost/iostreams/detail/adapter/filter_adapter.hpp 6 | * Date: Mon Nov 26 14:35:48 MST 2007 7 | * Copyright: 2007-2008 CodeRage, LLC 8 | * Author: Jonathan Turkanis 9 | * Contact: turkanis at coderage dot com 10 | * 11 | * Distributed under the Boost Software License, Version 1.0.(See accompanying 12 | * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 13 | * 14 | * See http://www.boost.org/libs/iostreams for documentation. 15 | */ 16 | 17 | #ifndef BOOST_IOSTREAMS_DETAIL_FILTER_ADAPTER_HPP_INCLUDED 18 | #define BOOST_IOSTREAMS_DETAIL_FILTER_ADAPTER_HPP_INCLUDED 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace boost { namespace iostreams { namespace detail { 28 | 29 | template 30 | class filter_adapter { 31 | private: 32 | typedef typename detail::value_type::type value_type; 33 | typedef typename detail::param_type::type param_type; 34 | public: 35 | explicit filter_adapter(param_type t) : t_(t) { } 36 | T& component() { return t_; } 37 | 38 | template 39 | void close(Device& dev) 40 | { 41 | detail::close_all(t_, dev); 42 | } 43 | 44 | template 45 | void close(Device& dev, BOOST_IOS::openmode which) 46 | { 47 | iostreams::close(t_, dev, which); 48 | } 49 | 50 | template 51 | void flush(Device& dev) 52 | { 53 | return iostreams::flush(t_, dev); 54 | } 55 | 56 | template // Avoid dependency on 57 | void imbue(const Locale& loc) { iostreams::imbue(t_, loc); } 58 | 59 | std::streamsize optimal_buffer_size() const 60 | { return iostreams::optimal_buffer_size(t_); } 61 | public: 62 | value_type t_; 63 | }; 64 | 65 | //----------------------------------------------------------------------------// 66 | 67 | } } } // End namespaces detail, iostreams, boost. 68 | 69 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_FILTER_ADAPTER_HPP_INCLUDED 70 | -------------------------------------------------------------------------------- /test/filtering_stream_test.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #include 9 | #include "read_input_test.hpp" 10 | #include "read_bidir_test.hpp" 11 | #include "read_seekable_test.hpp" 12 | #include "read_bidir_streambuf_test.hpp" 13 | #include "read_input_istream_test.hpp" 14 | #include "write_output_test.hpp" 15 | #include "write_bidir_test.hpp" 16 | #include "write_seekable_test.hpp" 17 | #include "write_output_iterator_test.hpp" 18 | #include "write_bidir_streambuf_test.hpp" 19 | #include "write_output_ostream_test.hpp" 20 | #include "read_input_filter_test.hpp" 21 | #include "read_bidir_filter_test.hpp" 22 | #include "write_output_filter_test.hpp" 23 | #include "write_bidir_filter_test.hpp" 24 | #include "seek_test.hpp" 25 | #include "putback_test.hpp" 26 | #include "filtering_stream_flush_test.hpp" 27 | 28 | using boost::unit_test::test_suite; 29 | 30 | test_suite* init_unit_test_suite(int, char* []) 31 | { 32 | test_suite* test = BOOST_TEST_SUITE("filtering_stream test"); 33 | test->add(BOOST_TEST_CASE(&read_input_test)); 34 | test->add(BOOST_TEST_CASE(&read_bidirectional_test)); 35 | test->add(BOOST_TEST_CASE(&read_seekable_test)); 36 | test->add(BOOST_TEST_CASE(&read_bidirectional_streambuf_test)); 37 | test->add(BOOST_TEST_CASE(&read_input_istream_test)); 38 | test->add(BOOST_TEST_CASE(&write_output_test)); 39 | test->add(BOOST_TEST_CASE(&write_bidirectional_test)); 40 | test->add(BOOST_TEST_CASE(&write_seekable_test)); 41 | test->add(BOOST_TEST_CASE(&write_output_iterator_test)); 42 | test->add(BOOST_TEST_CASE(&write_bidirectional_streambuf_test)); 43 | test->add(BOOST_TEST_CASE(&write_output_ostream_test)); 44 | test->add(BOOST_TEST_CASE(&read_input_filter_test)); 45 | test->add(BOOST_TEST_CASE(&read_bidirectional_filter_test)); 46 | test->add(BOOST_TEST_CASE(&write_output_filter_test)); 47 | test->add(BOOST_TEST_CASE(&write_bidirectional_filter_test)); 48 | test->add(BOOST_TEST_CASE(&seek_test)); 49 | test->add(BOOST_TEST_CASE(&putback_test)); 50 | test->add(BOOST_TEST_CASE(&test_filtering_ostream_flush)); 51 | return test; 52 | } 53 | -------------------------------------------------------------------------------- /doc/concepts/multi_character.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Multi-Character Filter 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Multi-Character Filter

13 | 14 | 15 | 16 | 17 |

Description

18 | 19 |

Filter which provides access to its controlled sequence or sequences several characters at a time. The difference between a Filter which is Multi-Character and one which is not is reflected in the specifications of the various Filter refinements. See, e.g., InputFilter and OutputFilter.

20 | 21 |

Refinement of

22 | 23 |

Filter.

24 | 25 | 26 |

Associated Types

27 | 28 |

Same as Filter, with the following additional requirements:

29 | 30 | 31 | 32 |
CategoryA type convertible to filter_tag and to multichar_tag
33 | 34 | 35 |

Valid Expressions / Semantics

36 | 37 |

Same as Filter.

38 | 39 |

Models

40 | 41 | 47 | 48 | 49 | 50 |
51 | 52 | 53 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /test/invert_test.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "detail/closable.hpp" 14 | #include "detail/filters.hpp" 15 | #include "detail/operation_sequence.hpp" 16 | #include "detail/temp_file.hpp" 17 | 18 | using namespace boost::iostreams; 19 | using namespace boost::iostreams::test; 20 | using boost::unit_test::test_suite; 21 | namespace io = boost::iostreams; 22 | 23 | void read_write_test() 24 | { 25 | 26 | test_file test; 27 | lowercase_file lower; 28 | uppercase_file upper; 29 | 30 | BOOST_CHECK( test_input_filter( 31 | invert(tolower_filter()), 32 | file_source(test.name(), in_mode), 33 | file_source(lower.name(), in_mode) ) ); 34 | 35 | BOOST_CHECK( test_output_filter( 36 | invert(toupper_filter()), 37 | file_source(test.name(), in_mode), 38 | file_source(upper.name(), in_mode) ) ); 39 | } 40 | 41 | void close_test() 42 | { 43 | // Invert an output filter 44 | { 45 | operation_sequence seq; 46 | chain ch; 47 | ch.push(io::invert(closable_filter(seq.new_operation(2)))); 48 | ch.push(closable_device(seq.new_operation(1))); 49 | BOOST_CHECK_NO_THROW(ch.reset()); 50 | BOOST_CHECK_OPERATION_SEQUENCE(seq); 51 | } 52 | 53 | // Invert an input filter 54 | { 55 | operation_sequence seq; 56 | chain ch; 57 | ch.push(io::invert(closable_filter(seq.new_operation(1)))); 58 | ch.push(closable_device(seq.new_operation(2))); 59 | BOOST_CHECK_NO_THROW(ch.reset()); 60 | BOOST_CHECK_OPERATION_SEQUENCE(seq); 61 | } 62 | } 63 | 64 | test_suite* init_unit_test_suite(int, char* []) 65 | { 66 | test_suite* test = BOOST_TEST_SUITE("reverse test"); 67 | test->add(BOOST_TEST_CASE(&read_write_test)); 68 | test->add(BOOST_TEST_CASE(&close_test)); 69 | return test; 70 | } 71 | -------------------------------------------------------------------------------- /test/read_input_seq_test.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_TEST_READ_INPUT_SEQUENCE_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_TEST_READ_INPUT_SEQUENCE_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "detail/sequence.hpp" 16 | #include "detail/temp_file.hpp" 17 | #include "detail/verification.hpp" 18 | 19 | void read_input_sequence_test() 20 | { 21 | using namespace std; 22 | using namespace boost; 23 | using namespace boost::iostreams; 24 | using namespace boost::iostreams::test; 25 | 26 | test_file file; 27 | test_sequence<> seq; 28 | 29 | { 30 | filtering_stream first(make_iterator_range(seq), 0); 31 | ifstream second(file.name().c_str()); 32 | BOOST_CHECK_MESSAGE( 33 | compare_streams_in_chars(first, second), 34 | "failed reading from range_adapter " 35 | "in chars with no buffer" 36 | ); 37 | } 38 | 39 | { 40 | filtering_stream first(make_iterator_range(seq), 0); 41 | ifstream second(file.name().c_str()); 42 | BOOST_CHECK_MESSAGE( 43 | compare_streams_in_chunks(first, second), 44 | "failed reading from range_adapter " 45 | "in chars with no buffer" 46 | ); 47 | } 48 | 49 | { 50 | filtering_stream first(make_iterator_range(seq)); 51 | ifstream second(file.name().c_str()); 52 | BOOST_CHECK_MESSAGE( 53 | compare_streams_in_chars(first, second), 54 | "failed reading from range_adapter " 55 | "in chars with large buffer" 56 | ); 57 | } 58 | 59 | { 60 | filtering_stream first(make_iterator_range(seq)); 61 | ifstream second(file.name().c_str()); 62 | BOOST_CHECK_MESSAGE( 63 | compare_streams_in_chunks(first, second), 64 | "failed reading from range_adapter " 65 | "in chars with large buffer" 66 | ); 67 | } 68 | } 69 | 70 | #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_INPUT_SEQUENCE_HPP_INCLUDED 71 | -------------------------------------------------------------------------------- /test/read_seekable_test.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_TEST_READ_SEEKABLE_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_TEST_READ_SEEKABLE_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "detail/temp_file.hpp" 16 | #include "detail/verification.hpp" 17 | 18 | void read_seekable_test() 19 | { 20 | using namespace std; 21 | using namespace boost; 22 | using namespace boost::iostreams; 23 | using namespace boost::iostreams::test; 24 | 25 | test_file test1; 26 | test_file test2; 27 | 28 | { 29 | filtering_stream first(file(test1.name(), in_mode), 0); 30 | ifstream second(test2.name().c_str(), in_mode); 31 | BOOST_CHECK_MESSAGE( 32 | compare_streams_in_chars(first, second), 33 | "failed reading from filtering_stream" 34 | "in chars with no buffer" 35 | ); 36 | } 37 | 38 | { 39 | filtering_stream first(file(test1.name(), in_mode), 0); 40 | ifstream second(test2.name().c_str(), in_mode); 41 | BOOST_CHECK_MESSAGE( 42 | compare_streams_in_chunks(first, second), 43 | "failed reading from filtering_stream" 44 | "in chars with no buffer" 45 | ); 46 | } 47 | 48 | { 49 | filtering_stream first(file(test1.name(), in_mode)); 50 | ifstream second(test2.name().c_str(), in_mode); 51 | BOOST_CHECK_MESSAGE( 52 | compare_streams_in_chars(first, second), 53 | "failed reading from filtering_stream" 54 | "in chars with large buffer" 55 | ); 56 | } 57 | 58 | { 59 | filtering_stream first(file(test1.name(), in_mode)); 60 | ifstream second(test2.name().c_str(), in_mode); 61 | BOOST_CHECK_MESSAGE( 62 | compare_streams_in_chunks(first, second), 63 | "failed reading from filtering_stream" 64 | "in chars with large buffer" 65 | ); 66 | } 67 | } 68 | 69 | #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_SEEKABLE_HPP_INCLUDED 70 | -------------------------------------------------------------------------------- /include/boost/iostreams/imbue.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_IMBUE_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_IMBUE_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include // DEDUCED_TYPENAME, MSVC. 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | // Must come last. 24 | #include 25 | 26 | namespace boost { namespace iostreams { 27 | 28 | namespace detail { 29 | 30 | // Implementation templates for simulated tag dispatch. 31 | template 32 | struct imbue_impl; 33 | 34 | } // End namespace detail. 35 | 36 | template 37 | void imbue(T& t, const Locale& loc) 38 | { detail::imbue_impl::imbue(detail::unwrap(t), loc); } 39 | 40 | namespace detail { 41 | 42 | //------------------Definition of imbue_impl----------------------------------// 43 | 44 | template 45 | struct imbue_impl 46 | : mpl::if_< 47 | is_custom, 48 | operations, 49 | imbue_impl< 50 | BOOST_DEDUCED_TYPENAME 51 | dispatch< 52 | T, streambuf_tag, localizable_tag, any_tag 53 | >::type 54 | > 55 | >::type 56 | { }; 57 | 58 | template<> 59 | struct imbue_impl { 60 | template 61 | static void imbue(T&, const Locale&) { } 62 | }; 63 | 64 | template<> 65 | struct imbue_impl { 66 | template 67 | static void imbue(T& t, const Locale& loc) { t.pubimbue(loc); } 68 | }; 69 | 70 | template<> 71 | struct imbue_impl { 72 | template 73 | static void imbue(T& t, const Locale& loc) { t.imbue(loc); } 74 | }; 75 | 76 | } // End namespace detail. 77 | 78 | } } // End namespaces iostreams, boost. 79 | 80 | #include 81 | 82 | #endif // #ifndef BOOST_IOSTREAMS_IMBUE_HPP_INCLUDED 83 | -------------------------------------------------------------------------------- /test/write_output_test.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_TEST_WRITE_OUTPUT_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_TEST_WRITE_OUTPUT_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "detail/sequence.hpp" 16 | #include "detail/temp_file.hpp" 17 | #include "detail/verification.hpp" 18 | 19 | void write_output_test() 20 | { 21 | using namespace std; 22 | using namespace boost; 23 | using namespace boost::iostreams; 24 | using namespace boost::iostreams::test; 25 | 26 | test_file test; 27 | 28 | { 29 | temp_file test2; 30 | filtering_ostream out(file_sink(test2.name(), out_mode), 0); 31 | write_data_in_chars(out); 32 | out.reset(); 33 | BOOST_CHECK_MESSAGE( 34 | compare_files(test2.name(), test.name()), 35 | "failed writing to filtering_ostream in chars with no buffer" 36 | ); 37 | } 38 | 39 | { 40 | temp_file test2; 41 | filtering_ostream out(file_sink(test2.name(), out_mode), 0); 42 | write_data_in_chunks(out); 43 | out.reset(); 44 | BOOST_CHECK_MESSAGE( 45 | compare_files(test2.name(), test.name()), 46 | "failed writing to filtering_ostream in chunks with no buffer" 47 | ); 48 | } 49 | 50 | { 51 | temp_file test2; 52 | filtering_ostream out(file_sink(test2.name(), out_mode)); 53 | write_data_in_chars(out); 54 | out.reset(); 55 | BOOST_CHECK_MESSAGE( 56 | compare_files(test2.name(), test.name()), 57 | "failed writing to filtering_ostream in chars with buffer" 58 | ); 59 | } 60 | 61 | { 62 | temp_file test2; 63 | filtering_ostream out(file_sink(test2.name(), out_mode)); 64 | write_data_in_chunks(out); 65 | out.reset(); 66 | BOOST_CHECK_MESSAGE( 67 | compare_files(test2.name(), test.name()), 68 | "failed writing to filtering_ostream in chunks with buffer" 69 | ); 70 | } 71 | } 72 | 73 | #endif // #ifndef BOOST_IOSTREAMS_TEST_WRITE_OUTPUT_HPP_INCLUDED 74 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/current_directory.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the Boost Software License, Version 1.0.(See accompanying 3 | * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 4 | * 5 | * See http://www.boost.org/libs/iostreams for documentation. 6 | 7 | * File: boost/iostreams/detail/execute.hpp 8 | * Date: Thu Dec 06 13:21:54 MST 2007 9 | * Copyright: 2007-2008 CodeRage, LLC 10 | * Author: Jonathan Turkanis 11 | * Contact: turkanis at coderage dot com 12 | * 13 | * Defines the function boost::iostreams::detail::current_directory, used by 14 | * boost::iostreams::detail::absolute_path. 15 | */ 16 | 17 | #ifndef BOOST_IOSTREAMS_DETAIL_CURRENT_DIRECTORY_HPP_INCLUDED 18 | #define BOOST_IOSTREAMS_DETAIL_CURRENT_DIRECTORY_HPP_INCLUDED 19 | 20 | #include // make sure size_t is in std. 21 | #include // size_t 22 | #include 23 | #include 24 | #include 25 | #include 26 | #ifdef BOOST_IOSTREAMS_WINDOWS 27 | # define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 28 | # include 29 | #else 30 | # include // sysconf. 31 | #endif 32 | 33 | // Must come last. 34 | #include 35 | 36 | namespace boost { namespace iostreams { namespace detail { 37 | 38 | // Returns the current working directory 39 | inline std::string current_directory() 40 | { 41 | #ifdef BOOST_IOSTREAMS_WINDOWS 42 | DWORD length; 43 | basic_buffer buf(MAX_PATH); 44 | while (true) { 45 | length = ::GetCurrentDirectoryA(buf.size(), buf.data()); 46 | if (!length) 47 | throw_system_failure("failed determining current directory"); 48 | if (length < static_cast(buf.size())) 49 | break; 50 | buf.resize(buf.size() * 2); 51 | } 52 | return std::string(buf.data(), length); 53 | #else // #ifdef BOOST_IOSTREAMS_WINDOWS 54 | basic_buffer buf(pathconf(".", _PC_PATH_MAX)); 55 | if (!getcwd(buf.data(), static_cast(buf.size()))) 56 | throw_system_failure("failed determining current directory"); 57 | return std::string(buf.data()); 58 | #endif // #ifdef BOOST_IOSTREAMS_WINDOWS 59 | } 60 | 61 | } } } // End namespaces detail, iostreams, boost. 62 | 63 | #include 64 | 65 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_CURRENT_DIRECTORY_HPP_INCLUDED 66 | -------------------------------------------------------------------------------- /include/boost/iostreams/traits_fwd.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | // Forward declarations of templates defined in traits.hpp. 9 | 10 | #ifndef BOOST_IOSTREAMS_IO_TRAITS_FWD_HPP_INCLUDED 11 | #define BOOST_IOSTREAMS_IO_TRAITS_FWD_HPP_INCLUDED 12 | 13 | #if defined(_MSC_VER) 14 | # pragma once 15 | #endif 16 | 17 | #include // stream types, char_traits. 18 | 19 | namespace boost { namespace iostreams { 20 | 21 | template 22 | struct is_istream; 23 | 24 | template 25 | struct is_ostream; 26 | 27 | template 28 | struct is_iostream; 29 | 30 | template 31 | struct is_streambuf; 32 | 33 | template 34 | struct is_istringstream; 35 | 36 | template 37 | struct is_ostringstream; 38 | 39 | template 40 | struct is_stringstream; 41 | 42 | template 43 | struct is_stringbuf; 44 | 45 | template 46 | struct is_ifstream; 47 | 48 | template 49 | struct is_ofstream; 50 | 51 | template 52 | struct is_fstream; 53 | 54 | template 55 | struct is_filebuf; 56 | 57 | template 58 | struct is_std_io; 59 | 60 | template 61 | struct is_std_file_device; 62 | 63 | template 64 | struct is_std_string_device; 65 | 66 | template 67 | struct char_type_of; 68 | 69 | template 70 | struct category_of; 71 | 72 | template 73 | struct int_type_of; 74 | 75 | template 76 | struct mode_of; 77 | 78 | template 79 | struct is_device; 80 | 81 | template 82 | struct is_filter; 83 | 84 | template 85 | struct is_direct; 86 | 87 | namespace detail { 88 | 89 | template 90 | struct is_boost_stream; 91 | 92 | template 93 | struct is_boost_stream_buffer; 94 | 95 | template 96 | struct is_filtering_stream; 97 | 98 | template 99 | struct is_filtering_streambuf; 100 | 101 | template 102 | struct is_linked; 103 | 104 | template 105 | struct is_boost; 106 | 107 | } // End namespace detail. 108 | 109 | } } // End namespaces iostreams, boost. 110 | 111 | #endif // #ifndef BOOST_IOSTREAMS_IO_TRAITS_FWD_HPP_INCLUDED 112 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/counted_array.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2005-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_COUNTED_ARRAY_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_COUNTED_ARRAY_HPP_INCLUDED 10 | 11 | #include // min. 12 | #include // size_t 13 | #include // char_traits 14 | #include 15 | #include 16 | #include // streamsize. 17 | 18 | namespace boost { namespace iostreams { namespace detail { 19 | 20 | template 21 | class counted_array_source { 22 | public: 23 | typedef Ch char_type; 24 | typedef source_tag category; 25 | counted_array_source(const Ch* buf, std::streamsize size) 26 | : buf_(buf), ptr_(0), end_(size) 27 | { } 28 | std::streamsize read(Ch* s, std::streamsize n) 29 | { 30 | using namespace std; 31 | streamsize result = (std::min)(n, end_ - ptr_); 32 | char_traits::copy( 33 | s, 34 | buf_ + ptr_, 35 | static_cast(result) 36 | ); 37 | ptr_ += result; 38 | return result; 39 | } 40 | std::streamsize count() const { return ptr_; } 41 | private: 42 | const Ch* buf_; 43 | std::streamsize ptr_, end_; 44 | }; 45 | 46 | template 47 | struct counted_array_sink { 48 | public: 49 | typedef Ch char_type; 50 | typedef sink_tag category; 51 | counted_array_sink(Ch* buf, std::streamsize size) 52 | : buf_(buf), ptr_(0), end_(size) 53 | { } 54 | std::streamsize write(const Ch* s, std::streamsize n) 55 | { 56 | using namespace std; 57 | std::streamsize result = (std::min)(n, end_ - ptr_); 58 | char_traits::copy( 59 | buf_ + ptr_, 60 | s, 61 | static_cast(result) 62 | ); 63 | ptr_ += result; 64 | return result; 65 | } 66 | std::streamsize count() const { return ptr_; } 67 | private: 68 | Ch* buf_; 69 | std::streamsize ptr_, end_; 70 | }; 71 | 72 | } } } // End namespaces iostreams, boost. 73 | 74 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_COUNTED_ARRAY_HPP_INCLUDED 75 | -------------------------------------------------------------------------------- /test/read_input_istream_test.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_TEST_READ_INPUT_ISTREAM_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_TEST_READ_INPUT_ISTREAM_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | #include "detail/temp_file.hpp" 15 | #include "detail/verification.hpp" 16 | 17 | void read_input_istream_test() 18 | { 19 | using namespace std; 20 | using namespace boost; 21 | using namespace boost::iostreams; 22 | using namespace boost::iostreams::test; 23 | 24 | test_file test; 25 | 26 | { 27 | test_file test2; 28 | ifstream src(test2.name().c_str()); 29 | filtering_istream first(src, 0); 30 | ifstream second(test.name().c_str()); 31 | BOOST_CHECK_MESSAGE( 32 | compare_streams_in_chars(first, second), 33 | "failed reading from filtering_istream based on an istream" 34 | "in chars with no buffer" 35 | ); 36 | } 37 | 38 | { 39 | test_file test2; 40 | ifstream src(test2.name().c_str()); 41 | filtering_istream first(src, 0); 42 | ifstream second(test.name().c_str()); 43 | BOOST_CHECK_MESSAGE( 44 | compare_streams_in_chunks(first, second), 45 | "failed reading from filtering_istream based on an istream" 46 | "in chunks with no buffer" 47 | ); 48 | } 49 | 50 | { 51 | test_file test2; 52 | ifstream src(test2.name().c_str()); 53 | filtering_istream first(src); 54 | ifstream second(test.name().c_str()); 55 | BOOST_CHECK_MESSAGE( 56 | compare_streams_in_chars(first, second), 57 | "failed reading from filtering_istream based on an istream" 58 | "in chars with large buffer" 59 | ); 60 | } 61 | 62 | { 63 | test_file test2; 64 | ifstream src(test2.name().c_str()); 65 | filtering_istream first(src); 66 | ifstream second(test.name().c_str()); 67 | BOOST_CHECK_MESSAGE( 68 | compare_streams_in_chunks(first, second), 69 | "failed reading from filtering_istream based on an istream" 70 | "in chunks with large buffer" 71 | ); 72 | } 73 | } 74 | 75 | #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_INPUT_ISTREAM_HPP_INCLUDED 76 | -------------------------------------------------------------------------------- /doc/macros/buffer_sizes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Buffer Sizes 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 |

Buffer Sizes

17 | 18 | 19 | 20 | 21 |
22 |
Overview
23 |
Headers
24 |
Synopsis
25 |
26 | 27 |
28 | 29 | 30 |

Overview

31 | 32 |

33 | The macros BOOST_IOSTREAMS_DEFAULT_DEVICE_BUFFER_SIZE, BOOST_IOSTREAMS_DEFAULT_FILTER_BUFFER_SIZE and BOOST_IOSTREAMS_DEFAULT_PBACK_BUFFER_SIZE can be used to configure the default sizes of buffers allocated by the Iostreams library when a Filter or Device is attached to a stream_buffer or stream, or when it is added to a chain. 34 |

35 | 36 |

The default values are subject to change in future versions of the Iostreams library.

37 | 38 | 39 |

Headers

40 | 41 |
42 |
<boost/iostreams/constants.hpp>
43 |
44 | 45 | 46 |

Synopsis

47 | 48 |
#define BOOST_IOSTREAMS_DEFAULT_DEVICE_BUFFER_SIZE  4096
49 | #define BOOST_IOSTREAMS_DEFAULT_FILTER_BUFFER_SIZE  128
50 | #define BOOST_IOSTREAMS_DEFAULT_PBACK_BUFFER_SIZE   4
51 | 52 | 53 | 54 | 55 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /doc/concepts/localizable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Localizable 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Localizable

13 | 14 | 15 | 16 | 17 |

Description

18 | 19 |

20 | A Localizable Filter or Device receives notifications when a stream or stream buffer which contains it has its std::locale set using std::basic_ios::imbue or std::basic_streambuf::pubimbue. 21 |

22 | 23 |

Refinement of

24 | 25 | 26 |

Associated Types

27 | 28 |

Notation

29 | 30 | 31 | 32 | 33 | 34 |
L-A type which is a model of Localizable
z-Object of type L
loc-Object of type std::locale
35 | 36 |

Valid Expressions / Semantics

37 | 38 | 39 | 40 | 41 | 44 | 45 | 46 | 47 |
ExpressionExpression TypePostcondition
42 |
boost::iostreams::imbue(z, loc)
43 |
voidlocale-sensitive i/o performed by z uses a copy of loc until a subsequent invocation of boost::iostreams::imbue
48 | 49 |

Exceptions

50 | 51 |

52 | Errors which occur during the execution of imbue are be indicated by throwing exceptions. 53 |

54 | 55 |

Models

56 | 60 | 61 | 62 | 63 |
64 | 65 | 66 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /include/boost/iostreams/char_traits.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_CHAR_TRAITS_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_CHAR_TRAITS_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include 16 | #include 17 | #include // EOF. 18 | #include // std::char_traits. 19 | #include 20 | #include 21 | #ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS 22 | # include 23 | #endif 24 | 25 | #ifdef BOOST_NO_STDC_NAMESPACE 26 | namespace std { using ::wint_t; } 27 | #endif 28 | 29 | namespace boost { namespace iostreams { 30 | 31 | // Dinkumware that comes with QNX Momentics 6.3.0, 4.0.2, incorrectly defines 32 | // the EOF and WEOF macros to not std:: qualify the wint_t type (and so does 33 | // Sun C++ 5.8 + STLport 4). Fix by placing the def in this scope. 34 | // NOTE: Use BOOST_WORKAROUND? 35 | #if (defined(__QNX__) && defined(BOOST_DINKUMWARE_STDLIB)) \ 36 | || defined(__SUNPRO_CC) 37 | using ::std::wint_t; 38 | #endif 39 | 40 | const int WOULD_BLOCK = (int) (EOF - 1); 41 | 42 | #ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS 43 | const std::wint_t WWOULD_BLOCK = (std::wint_t) (WEOF - 1); 44 | #endif 45 | 46 | template 47 | struct char_traits; 48 | 49 | template<> 50 | struct char_traits : BOOST_IOSTREAMS_CHAR_TRAITS(char) { 51 | static char newline() { return '\n'; } 52 | static int good() { return '\n'; } 53 | static int would_block() { return WOULD_BLOCK; } 54 | static bool is_good(int c) { return c != EOF && c != WOULD_BLOCK; } 55 | static bool is_eof(int c) { return c == EOF; } 56 | static bool would_block(int c) { return c == WOULD_BLOCK; } 57 | }; 58 | 59 | #ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS 60 | template<> 61 | struct char_traits : std::char_traits { 62 | static wchar_t newline() { return L'\n'; } 63 | static std::wint_t good() { return L'\n'; } 64 | static std::wint_t would_block() { return WWOULD_BLOCK; } 65 | static bool is_good(std::wint_t c) { return c != WEOF && c != WWOULD_BLOCK; } 66 | static bool is_eof(std::wint_t c) { return c == WEOF; } 67 | static bool would_block(std::wint_t c) { return c == WWOULD_BLOCK; } 68 | }; 69 | #endif 70 | 71 | } } // End namespaces iostreams, boost. 72 | 73 | #endif // #ifndef BOOST_IOSTREAMS_CHAR_TRAITS_HPP_INCLUDED 74 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/is_dereferenceable.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2005-2007 Jonathan Turkanis 3 | // (C) Copyright David Abrahams 2004. 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 6 | 7 | // See http://www.boost.org/libs/iostreams for documentation. 8 | 9 | #ifndef BOOST_IOSTREAMS_DETAIL_IS_DEREFERENCEABLE_HPP_INCLUDED 10 | #define BOOST_IOSTREAMS_DETAIL_IS_DEREFERENCEABLE_HPP_INCLUDED 11 | 12 | # include 13 | # include 14 | # include 15 | # include 16 | 17 | namespace boost { namespace iostreams { namespace detail { 18 | 19 | // is_dereferenceable metafunction 20 | // 21 | // Requires: Given x of type T&, if the expression *x is well-formed 22 | // it must have complete type; otherwise, it must neither be ambiguous 23 | // nor violate access. 24 | 25 | // This namespace ensures that ADL doesn't mess things up. 26 | namespace is_dereferenceable_ 27 | { 28 | // a type returned from operator* when no increment is found in the 29 | // type's own namespace 30 | struct tag {}; 31 | 32 | // any soaks up implicit conversions and makes the following 33 | // operator* less-preferred than any other such operator that 34 | // might be found via ADL. 35 | struct any { template any(T const&); }; 36 | 37 | // This is a last-resort operator* for when none other is found 38 | tag operator*(any const&); 39 | 40 | # if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) 41 | # define BOOST_comma(a,b) (a) 42 | # else 43 | // In case an operator++ is found that returns void, we'll use ++x,0 44 | tag operator,(tag,int); 45 | # define BOOST_comma(a,b) (a,b) 46 | # endif 47 | 48 | // two check overloads help us identify which operator++ was picked 49 | char (& check_increment(tag) )[2]; 50 | 51 | template 52 | char check_increment(T const&); 53 | 54 | template 55 | struct impl 56 | { 57 | static typename boost::remove_cv::type& x; 58 | 59 | BOOST_STATIC_CONSTANT( 60 | bool 61 | , value = sizeof(is_dereferenceable_::check_increment(BOOST_comma(*x,0))) == 1 62 | ); 63 | }; 64 | } 65 | 66 | # undef BOOST_comma 67 | 68 | template 69 | struct is_dereferenceable 70 | : public ::boost::integral_constant::value > 71 | { 72 | BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_dereferenceable,(T)) 73 | }; 74 | 75 | } } 76 | 77 | 78 | } // End namespaces detail, iostreams, boost. 79 | 80 | #endif // BOOST_IOSTREAMS_DETAIL_IS_DEREFERENCEABLE_HPP_INCLUDED 81 | -------------------------------------------------------------------------------- /include/boost/iostreams/filter/counter.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2005-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_COUNTER_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_COUNTER_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include // count. 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | // Must come last. 22 | #include // VC7.1 C4244. 23 | 24 | namespace boost { namespace iostreams { 25 | 26 | // 27 | // Template name: basic_counter. 28 | // Template parameters: 29 | // Ch - The character type. 30 | // Description: Filter which counts lines and characters. 31 | // 32 | template 33 | class basic_counter { 34 | public: 35 | typedef Ch char_type; 36 | struct category 37 | : dual_use, 38 | filter_tag, 39 | multichar_tag, 40 | optimally_buffered_tag 41 | { }; 42 | explicit basic_counter(int first_line = 0, int first_char = 0) 43 | : lines_(first_line), chars_(first_char) 44 | { } 45 | int lines() const { return lines_; } 46 | int characters() const { return chars_; } 47 | std::streamsize optimal_buffer_size() const { return 0; } 48 | 49 | template 50 | std::streamsize read(Source& src, char_type* s, std::streamsize n) 51 | { 52 | std::streamsize result = iostreams::read(src, s, n); 53 | if (result == -1) 54 | return -1; 55 | lines_ += std::count(s, s + result, char_traits::newline()); 56 | chars_ += result; 57 | return result; 58 | } 59 | 60 | template 61 | std::streamsize write(Sink& snk, const char_type* s, std::streamsize n) 62 | { 63 | std::streamsize result = iostreams::write(snk, s, n); 64 | lines_ += std::count(s, s + result, char_traits::newline()); 65 | chars_ += result; 66 | return result; 67 | } 68 | private: 69 | int lines_; 70 | int chars_; 71 | }; 72 | BOOST_IOSTREAMS_PIPABLE(basic_counter, 1) 73 | 74 | 75 | typedef basic_counter counter; 76 | typedef basic_counter wcounter; 77 | 78 | } } // End namespaces iostreams, boost. 79 | 80 | #include 81 | 82 | #endif // #ifndef BOOST_IOSTREAMS_COUNTER_HPP_INCLUDED 83 | -------------------------------------------------------------------------------- /test/write_seekable_test.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_TEST_WRITE_SEEKABLE_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_TEST_WRITE_SEEKABLE_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "detail/temp_file.hpp" 16 | #include "detail/verification.hpp" 17 | 18 | void write_seekable_test() 19 | { 20 | using namespace std; 21 | using namespace boost; 22 | using namespace boost::iostreams; 23 | using namespace boost::iostreams::test; 24 | 25 | test_file test; 26 | BOOST_IOS::openmode mode = out_mode | BOOST_IOS::trunc; 27 | 28 | { 29 | temp_file test2; 30 | filtering_stream out(file(test2.name(), mode), 0); 31 | write_data_in_chars(out); 32 | out.reset(); 33 | BOOST_CHECK_MESSAGE( 34 | compare_files(test2.name(), test.name()), 35 | "failed writing to filtering_stream in chars with" 36 | "no buffer" 37 | ); 38 | } 39 | 40 | { 41 | temp_file test2; 42 | filtering_stream out(file(test2.name(), mode), 0); 43 | write_data_in_chunks(out); 44 | out.reset(); 45 | BOOST_CHECK_MESSAGE( 46 | compare_files(test2.name(), test.name()), 47 | "failed writing to filtering_stream in chunks with" 48 | "no buffer" 49 | ); 50 | } 51 | 52 | { 53 | temp_file test2; 54 | filtering_stream out(file(test2.name(), mode)); 55 | write_data_in_chars(out); 56 | out.reset(); 57 | BOOST_CHECK_MESSAGE( 58 | compare_files(test2.name(), test.name()), 59 | "failed writing to filtering_stream in chars with" 60 | "large buffer" 61 | ); 62 | } 63 | 64 | { 65 | temp_file test2; 66 | filtering_stream out(file(test2.name(), mode)); 67 | write_data_in_chunks(out); 68 | out.reset(); 69 | BOOST_CHECK_MESSAGE( 70 | compare_files(test2.name(), test.name()), 71 | "failed writing to filtering_stream in chunks with" 72 | "large buffer" 73 | ); 74 | } 75 | } 76 | 77 | #endif // #ifndef BOOST_IOSTREAMS_TEST_WRITE_SEEKABLE_HPP_INCLUDED 78 | -------------------------------------------------------------------------------- /test/read_seekable_seq_test.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_TEST_READ_SEEKABLE_SEQUENCE_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_TEST_READ_SEEKABLE_SEQUENCE_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "detail/sequence.hpp" 17 | #include "detail/temp_file.hpp" 18 | #include "detail/verification.hpp" 19 | 20 | void read_seekable_sequence_test() 21 | { 22 | using namespace std; 23 | using namespace boost; 24 | using namespace boost::iostreams; 25 | using namespace boost::iostreams::test; 26 | 27 | test_file file; 28 | test_sequence<> seq; 29 | 30 | { 31 | filtering_stream first(make_iterator_range(seq), 0); 32 | ifstream second(file.name().c_str()); 33 | BOOST_CHECK_MESSAGE( 34 | compare_streams_in_chars(first, second), 35 | "failed reading from filtering_stream based on a" 36 | "sequence in chars with no buffer" 37 | ); 38 | } 39 | 40 | { 41 | filtering_stream first(make_iterator_range(seq), 0); 42 | ifstream second(file.name().c_str()); 43 | BOOST_CHECK_MESSAGE( 44 | compare_streams_in_chunks(first, second), 45 | "failed reading from filtering_stream based on a" 46 | "sequence in chunks with no buffer" 47 | ); 48 | } 49 | 50 | { 51 | filtering_stream first(make_iterator_range(seq)); 52 | ifstream second(file.name().c_str()); 53 | BOOST_CHECK_MESSAGE( 54 | compare_streams_in_chars(first, second), 55 | "failed reading from filtering_stream based on a" 56 | "sequence in chars with large buffer" 57 | ); 58 | } 59 | 60 | { 61 | filtering_stream first(make_iterator_range(seq)); 62 | ifstream second(file.name().c_str()); 63 | BOOST_CHECK_MESSAGE( 64 | compare_streams_in_chunks(first, second), 65 | "failed reading from filtering_stream based on a" 66 | "sequence in chunks with large buffer" 67 | ); 68 | } 69 | } 70 | 71 | #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_SEEKABLE_SEQUENCE_HPP_INCLUDED 72 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/char_traits.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // Provides std::char_traits for libraries without templated streams. Should not 7 | // be confused with , which defines the 8 | // template boost::iostreams::char_traits. 9 | 10 | // See http://www.boost.org/libs/iostreams for documentation. 11 | 12 | #ifndef BOOST_IOSTREAMS_DETAIL_CHAR_TRAITS_HPP_INCLUDED 13 | #define BOOST_IOSTREAMS_DETAIL_CHAR_TRAITS_HPP_INCLUDED 14 | 15 | #if defined(_MSC_VER) 16 | # pragma once 17 | #endif 18 | 19 | #include 20 | #include 21 | #ifdef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES 22 | # include // Make sure size_t is in std. 23 | # include 24 | # include 25 | # include 26 | #endif 27 | 28 | #ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //--------------------------------// 29 | # define BOOST_IOSTREAMS_CHAR_TRAITS(ch) std::char_traits< ch > 30 | #else 31 | # define BOOST_IOSTREAMS_CHAR_TRAITS(ch) boost::iostreams::detail::char_traits 32 | 33 | namespace boost { namespace iostreams { namespace detail { 34 | 35 | struct char_traits { 36 | typedef char char_type; 37 | typedef int int_type; 38 | typedef std::streampos pos_type; 39 | typedef std::streamoff off_type; 40 | 41 | // Note: this may not be not conforming, since it treats chars as unsigned, 42 | // but is only used to test for equality. 43 | static int compare(const char* lhs, const char* rhs, std::size_t n) 44 | { return std::strncmp(lhs, rhs, n); } 45 | static char* copy(char *dest, const char *src, std::size_t n) 46 | { return static_cast(std::memcpy(dest, src, n)); } 47 | static char* move(char *dest, const char *src, std::size_t n) 48 | { return static_cast(std::memmove(dest, src, n)); } 49 | static const char* find(const char* s, std::size_t n, const char& c) 50 | { return (const char*) (const void*) std::memchr(s, c, n); } 51 | static char to_char_type(const int& c) { return c; } 52 | static int to_int_type(const char& c) { return c; } 53 | static bool eq_int_type(const int& lhs, const int& rhs) 54 | { return lhs == rhs; } 55 | static int eof() { return EOF; } 56 | static int not_eof(const int& c) { return c != EOF ? c : '\n'; } 57 | }; 58 | 59 | } } } // End namespaces detail, iostreams, boost. 60 | 61 | #endif // #ifdef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //-----------------------// 62 | 63 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_CHAR_TRAITS_HPP_INCLUDED 64 | -------------------------------------------------------------------------------- /include/boost/iostreams/optimal_buffer_size.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_OPTIMAL_BUFFER_SIZE_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_OPTIMAL_BUFFER_SIZE_HPP_INCLUDED 10 | 11 | #if defined(_MSC_VER) 12 | # pragma once 13 | #endif 14 | 15 | #include // DEDUCED_TYPENAME, MSVC. 16 | #include 17 | #include // constants. 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | // Must come last. 24 | #include 25 | 26 | namespace boost { namespace iostreams { 27 | 28 | namespace detail { 29 | 30 | template 31 | struct optimal_buffer_size_impl; 32 | 33 | } // End namespace detail. 34 | 35 | template 36 | std::streamsize optimal_buffer_size(const T& t) 37 | { 38 | typedef detail::optimal_buffer_size_impl impl; 39 | return impl::optimal_buffer_size(detail::unwrap(t)); 40 | } 41 | 42 | namespace detail { 43 | 44 | //------------------Definition of optimal_buffer_size_impl--------------------// 45 | 46 | template 47 | struct optimal_buffer_size_impl 48 | : mpl::if_< 49 | is_custom, 50 | operations, 51 | optimal_buffer_size_impl< 52 | BOOST_DEDUCED_TYPENAME 53 | dispatch< 54 | T, optimally_buffered_tag, device_tag, filter_tag 55 | >::type 56 | > 57 | >::type 58 | { }; 59 | 60 | template<> 61 | struct optimal_buffer_size_impl { 62 | template 63 | static std::streamsize optimal_buffer_size(const T& t) 64 | { return t.optimal_buffer_size(); } 65 | }; 66 | 67 | template<> 68 | struct optimal_buffer_size_impl { 69 | template 70 | static std::streamsize optimal_buffer_size(const T&) 71 | { return default_device_buffer_size; } 72 | }; 73 | 74 | template<> 75 | struct optimal_buffer_size_impl { 76 | template 77 | static std::streamsize optimal_buffer_size(const T&) 78 | { return default_filter_buffer_size; } 79 | }; 80 | 81 | } // End namespace detail. 82 | 83 | } } // End namespaces iostreams, boost. 84 | 85 | #include 86 | 87 | #endif // #ifndef BOOST_IOSTREAMS_OPTIMAL_BUFFER_SIZE_HPP_INCLUDED 88 | -------------------------------------------------------------------------------- /doc/functions/functions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Iostreams Library Functions 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 |

Iostreams Library Functions

17 | 18 | 19 | 20 | 21 |

Functions

22 | 23 |
24 |
back_inserter
25 |
close
26 |
combine
27 |
compose
28 |
copy
29 |
flush
30 |
get
31 |
imbue
32 |
invert
33 |
offset_to_position
34 |
optimal_buffer_size
35 |
position_to_offset
36 |
put
37 |
putback
38 |
read
39 |
restrict
40 |
seek
41 |
tee
42 |
test_filter_pair
43 |
test_input_filter
44 |
test_output_filter
45 |
write
46 |
47 | 48 |
49 | 50 | 51 | 52 | 53 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /doc/concepts/blocking.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Blocking 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Blocking

13 | 14 | 15 | 16 | 17 |

Description

18 | 19 |

20 | A Device is Blocking if a read request never produces fewer characters than requested except at end-of-stream, and if a write request never consumes fewer characters than requested under any circumstances. All Devices currently provided with the Iostreams library are Blocking. Limited support for non-Blocking Devices has been provided as a foundation for future more comprehensive support of asynchronous and non-blocking i/o. 21 |

22 | 23 |

24 | The Blocking concept does not apply to filters. Instead, filters are required to be blocking-preserving, which means that 25 |

26 |
    27 |
  • 28 | a read request never produces fewer characters than requested unless end-of-stream has been reached or unless a read request to a downsteam Source produces fewer characters than requested, and 29 |
  • 30 |
  • 31 | a write request never consumes fewer characters than requested unless a write request to a downsteam Sink consumes fewer characters than requested. 32 |
  • 33 |
34 | 35 |

36 | Unlike other Iostreams library concepts, Blocking is not associated with any category tag. In the future, a non_blocking_tag may be introduced. 37 |

38 | 39 |

Refinement of

40 | 41 |

Device.

42 | 43 | 44 |

Associated Types

45 | 46 |

Same as Device.

47 | 48 | 49 |

Valid Expressions / Semantics

50 | 51 |

Valid expressions are the same as Device. The additional semantic requirements are described informally above.

52 | 53 | 54 | 55 |
56 | 57 | 58 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /test/buffer_size_test.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #include "detail/filters.hpp" // Must come before operations.hpp for VC6. 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace std; 17 | using namespace boost::iostreams; 18 | using namespace boost::iostreams::test; 19 | using boost::unit_test::test_suite; 20 | 21 | struct optimally_buffered_filter { 22 | typedef char char_type; 23 | struct category 24 | : input_filter_tag, 25 | optimally_buffered_tag 26 | { }; 27 | std::streamsize optimal_buffer_size() const 28 | { return default_filter_buffer_size + 1; } 29 | }; 30 | 31 | void buffer_size_test() 32 | { 33 | // Test device buffer sizes. 34 | 35 | BOOST_CHECK_MESSAGE( 36 | optimal_buffer_size(null_source()) == default_device_buffer_size, 37 | "wrong buffer size for sourcer" 38 | ); 39 | BOOST_CHECK_MESSAGE( 40 | optimal_buffer_size(null_sink()) == default_device_buffer_size, 41 | "wrong buffer size for sink" 42 | ); 43 | 44 | // Test filter buffer sizes. 45 | 46 | BOOST_CHECK_MESSAGE( 47 | optimal_buffer_size(toupper_filter()) == default_filter_buffer_size, 48 | "wrong buffer size for input filter" 49 | ); 50 | BOOST_CHECK_MESSAGE( 51 | optimal_buffer_size(tolower_filter()) == default_filter_buffer_size, 52 | "wrong buffer size for output filter" 53 | ); 54 | BOOST_CHECK_MESSAGE( 55 | optimal_buffer_size(toupper_multichar_filter()) 56 | == 57 | default_filter_buffer_size, 58 | "wrong buffer size for multi-character input filter" 59 | ); 60 | BOOST_CHECK_MESSAGE( 61 | optimal_buffer_size(tolower_multichar_filter()) 62 | == 63 | default_filter_buffer_size, 64 | "wrong buffer size for multi-character output filter" 65 | ); 66 | 67 | // Test custom buffer size. 68 | 69 | BOOST_CHECK_MESSAGE( 70 | optimal_buffer_size(optimally_buffered_filter()) 71 | == 72 | optimally_buffered_filter().optimal_buffer_size(), 73 | "wrong buffer size for multi-character output filter" 74 | ); 75 | } 76 | 77 | test_suite* init_unit_test_suite(int, char* []) 78 | { 79 | test_suite* test = BOOST_TEST_SUITE("buffer_size test"); 80 | test->add(BOOST_TEST_CASE(&buffer_size_test)); 81 | return test; 82 | } 83 | -------------------------------------------------------------------------------- /include/boost/iostreams/detail/config/codecvt.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2003-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_CODECVT_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_DETAIL_CONFIG_CODECVT_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #if defined(_MSC_VER) 17 | # pragma once 18 | #endif 19 | 20 | //------------------Support for codecvt with user-defined state types---------// 21 | 22 | #if defined(__MSL_CPP__) || defined(__LIBCOMO__) || \ 23 | BOOST_WORKAROUND(_STLPORT_VERSION, <= 0x450) || \ 24 | defined(_LIBCPP_VERSION) \ 25 | /**/ 26 | # define BOOST_IOSTREAMS_NO_PRIMARY_CODECVT_DEFINITION 27 | #endif 28 | 29 | #if defined(__GLIBCPP__) || defined(__GLIBCXX__) || \ 30 | BOOST_WORKAROUND(_STLPORT_VERSION, > 0x450) \ 31 | /**/ 32 | # define BOOST_IOSTREAMS_EMPTY_PRIMARY_CODECVT_DEFINITION 33 | #endif 34 | 35 | //------------------Check for codecvt ctor taking a reference count-----------// 36 | 37 | #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205)) || \ 38 | BOOST_WORKAROUND(_STLPORT_VERSION, < 0x461) \ 39 | /**/ 40 | # define BOOST_IOSTREAMS_NO_CODECVT_CTOR_FROM_SIZE_T 41 | #endif 42 | 43 | //------------------Normalize codecvt::length---------------------------------// 44 | 45 | #if !defined(__MSL_CPP__) && !defined(__LIBCOMO__) && \ 46 | (!defined(BOOST_RWSTD_VER) || BOOST_RWSTD_VER < 0x04010300) && \ 47 | (!defined(__MACH__) || !defined(__INTEL_COMPILER)) 48 | /**/ 49 | # define BOOST_IOSTREAMS_CODECVT_CV_QUALIFIER const 50 | #else 51 | # define BOOST_IOSTREAMS_CODECVT_CV_QUALIFIER 52 | #endif 53 | 54 | //------------------Check for codecvt::max_length-----------------------------// 55 | 56 | #if BOOST_WORKAROUND(_STLPORT_VERSION, < 0x461) 57 | # define BOOST_IOSTREAMS_NO_CODECVT_MAX_LENGTH 58 | #endif 59 | 60 | //------------------Put mbstate_t and codecvt in std--------------------------// 61 | 62 | #ifndef BOOST_IOSTREAMS_NO_LOCALE 63 | # include 64 | #endif 65 | 66 | // From Robert Ramey's version of utf8_codecvt_facet. 67 | namespace std { 68 | 69 | #if defined(__LIBCOMO__) 70 | using ::mbstate_t; 71 | #elif defined(BOOST_DINKUMWARE_STDLIB) && !defined(__BORLANDC__) 72 | using ::mbstate_t; 73 | #elif defined(__SGI_STL_PORT) 74 | #elif defined(BOOST_NO_STDC_NAMESPACE) 75 | using ::codecvt; 76 | using ::mbstate_t; 77 | #endif 78 | 79 | } // End namespace std. 80 | 81 | #endif // #ifndef BOOST_IOSTREAMS_DETAIL_CONFIG_CODECVT_HPP_INCLUDED 82 | -------------------------------------------------------------------------------- /test/write_output_ostream_test.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_TEST_WRITE_OUTPUT_OSTREAM_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_TEST_WRITE_OUTPUT_OSTREAM_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | #include "detail/sequence.hpp" 15 | #include "detail/temp_file.hpp" 16 | #include "detail/verification.hpp" 17 | 18 | void write_output_ostream_test() 19 | { 20 | using namespace std; 21 | using namespace boost; 22 | using namespace boost::iostreams; 23 | using namespace boost::iostreams::test; 24 | 25 | test_file test; 26 | 27 | { 28 | temp_file test2; 29 | { 30 | ofstream dest(test2.name().c_str(), out_mode); 31 | filtering_ostream out(dest, 0); 32 | write_data_in_chars(out); 33 | } 34 | BOOST_CHECK_MESSAGE( 35 | compare_files(test2.name(), test.name()), 36 | "failed writing to filtering_ostream based on an ostream " 37 | "in chars with no buffer" 38 | ); 39 | } 40 | 41 | { 42 | temp_file test2; 43 | { 44 | ofstream dest(test2.name().c_str(), out_mode); 45 | filtering_ostream out(dest, 0); 46 | write_data_in_chunks(out); 47 | } 48 | BOOST_CHECK_MESSAGE( 49 | compare_files(test2.name(), test.name()), 50 | "failed writing to filtering_ostream based on an ostream " 51 | "in chunks with no buffer" 52 | ); 53 | } 54 | 55 | { 56 | test_file test2; 57 | { 58 | ofstream dest(test2.name().c_str(), out_mode); 59 | filtering_ostream out(dest); 60 | write_data_in_chars(out); 61 | } 62 | BOOST_CHECK_MESSAGE( 63 | compare_files(test2.name(), test.name()), 64 | "failed writing to filtering_ostream based on an ostream " 65 | "in chars with large buffer" 66 | ); 67 | } 68 | 69 | { 70 | temp_file test2; 71 | { 72 | ofstream dest(test2.name().c_str(), out_mode); 73 | filtering_ostream out(dest); 74 | write_data_in_chunks(out); 75 | } 76 | BOOST_CHECK_MESSAGE( 77 | compare_files(test2.name(), test.name()), 78 | "failed writing to filtering_ostream based on an ostream " 79 | "in chunks with large buffer" 80 | ); 81 | } 82 | } 83 | 84 | #endif // #ifndef BOOST_IOSTREAMS_TEST_WRITE_OUTPUT_OSTREAM_HPP_INCLUDED 85 | -------------------------------------------------------------------------------- /doc/functions/copy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Function Template copy 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Function Template copy

13 | 14 | 15 | 16 | 17 |
18 |
Description
19 |
Headers
20 |
Synopsis
21 |
22 | 23 | 24 |

Description

25 | 26 |

The function template copy reads data from a given model of Source and writes it to a given model of Sink until the end of stream is reached. It then closes both components, using the function template close, and returns the number of characters written.

27 | 28 |

The size of the temporary buffer used may be supplied as an optional parameter.

29 | 30 |

There are four overloads of copy to accommodate all combinations of Sources and Sinks, which are passed by const reference, and streams and stream buffers, which are passed by non-const reference.

31 | 32 | 33 |

Headers

34 | 35 |
36 |
<boost/iostreams/copy.hpp>
37 |
38 | 39 | 40 |

Synopsis

41 | 42 |
namespace boost { namespace iostreams {
43 |               
44 | template<typename Source, typename Sink>
45 | std::streamsize
46 | copy( [const] Source& src, [const] Sink& sink,
47 |       std::streamsize buffer_size = default value );
48 | 
49 | } } // End namespace boost::io
50 | 51 | 52 | 53 | 54 |
55 | 56 | 57 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /doc/functions/combine.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Function Template combine 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Function Template combine

13 | 14 | 15 | 16 | 17 |
18 |
Description
19 |
Headers
20 |
Synopsis
21 |
22 | 23 | 24 |

Description

25 | 26 |

27 | The class template combination takes an InputFilter/OutputFilter pair or a Source/Sink pair and yields a Filter or Device which performs input using the first component and output using the second. The function template combine takes an InputFilter/OutputFilter pair or a Source/Sink pair and returns an appropriate specialization of combination. 28 |

29 | 30 | 31 |

Headers

32 | 33 |
34 |
<boost/iostreams/combine.hpp>
35 |
36 | 37 | 38 |

Synopsis

39 | 40 |
namespace boost { namespace iostreams {
41 |    
42 | template<typename In, typename Out>
43 | class combination;
44 | 
45 | template<typename In, typename Out>
46 | combination<In, Out> combine(const In& in, const Out& out);
47 | 
48 | } } // End namespace boost::io
49 | 50 | 51 | 52 |
53 | 54 | 55 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /doc/concepts/concepts.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Iostreams Library Concepts 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 |

Iostreams Library Concepts

17 | 18 | 19 | 20 | 21 | 22 |

Devices

23 | 24 |
25 |
BidirectionalDevice
26 |
Blocking
27 |
Device
28 |
Direct
29 |
Peekable
30 |
SeekableDevice
31 |
Sink
32 |
Source
33 |
34 | 35 | 36 |

Filters

37 | 38 |
39 |
BidirectionalFilter
40 |
DualUseFilter
41 |
Filter
42 |
InputFilter
43 |
Multi-Character
44 |
OutputFilter
45 |
Pipable
46 |
SeekableFilter
47 |
48 | 49 | 50 |

Other

51 | 52 |
53 |
Closable
54 |
Flushable
55 |
Localizable
56 |
OptimallyBuffered
57 |
SymmetricFilter
58 |
59 | 60 |
61 | 62 | 63 | 64 | 65 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /doc/macros/macros.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Iostreams Library Macros 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 |

Iostreams Library Macros

17 | 18 | 19 | 20 | 21 |

Macros

22 | 23 |
24 |
BOOST_IOS
25 |
BOOST_IOSTREAMS_BASIC_ISTREAM
26 |
BOOST_IOSTREAMS_BASIC_IOS
27 |
BOOST_IOSTREAMS_BASIC_IOSTREAM
28 |
BOOST_IOSTREAMS_BASIC_OSTREAM
29 |
BOOST_IOSTREAMS_BASIC_STREAMBUF
30 |
BOOST_IOSTREAMS_CHAR_TRAITS
31 |
BOOST_IOSTREAMS_COMPONENT
32 |
BOOST_IOSTREAMS_COMPONENT_TYPE
33 |
BOOST_IOSTREAMS_DEFAULT_DEVICE_BUFFER_SIZE
34 |
BOOST_IOSTREAMS_DEFAULT_FILTER_BUFFER_SIZE
35 |
BOOST_IOSTREAMS_DEFAULT_PBACK_BUFFER_SIZE
36 |
BOOST_IOSTREAMS_FAILURE
37 |
BOOST_IOSTREAMS_PIPABLE
38 |
BOOST_IOSTREAMS_PUBSEEKOFF
39 |
BOOST_IOSTREAMS_PUBSEEKPOS
40 |
BOOST_IOSTREAMS_PUBSYNC
41 |
42 | 43 |
44 | 45 | 46 | 47 | 48 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /test/read_bidir_streambuf_test.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_TEST_READ_BIDIRECTIONAL_STREAMBUF_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_TEST_READ_BIDIRECTIONAL_STREAMBUF_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "detail/temp_file.hpp" 16 | #include "detail/verification.hpp" 17 | 18 | void read_bidirectional_streambuf_test() 19 | { 20 | using namespace std; 21 | using namespace boost; 22 | using namespace boost::iostreams; 23 | using namespace boost::iostreams::test; 24 | 25 | test_file test1; 26 | test_file test2; 27 | 28 | { 29 | filebuf fb; 30 | fb.open(test1.name().c_str(), BOOST_IOS::in); 31 | filtering_stream first(fb, 0); 32 | ifstream second(test2.name().c_str()); 33 | BOOST_CHECK_MESSAGE( 34 | compare_streams_in_chars(first, second), 35 | "failed reading from filtering_stream based on a" 36 | "streambuf in chars with no buffer" 37 | ); 38 | } 39 | 40 | { 41 | filebuf fb; 42 | fb.open(test1.name().c_str(), BOOST_IOS::in); 43 | filtering_stream first(fb, 0); 44 | ifstream second(test2.name().c_str()); 45 | BOOST_CHECK_MESSAGE( 46 | compare_streams_in_chunks(first, second), 47 | "failed reading from filtering_stream based on a" 48 | "streambuf in chunks with no buffer" 49 | ); 50 | } 51 | 52 | { 53 | filebuf fb; 54 | fb.open(test1.name().c_str(), BOOST_IOS::in); 55 | filtering_stream first(fb); 56 | ifstream second(test2.name().c_str()); 57 | BOOST_CHECK_MESSAGE( 58 | compare_streams_in_chars(first, second), 59 | "failed reading from filtering_stream based on a" 60 | "streambuf in chars with large buffer" 61 | ); 62 | } 63 | 64 | { 65 | filebuf fb; 66 | fb.open(test1.name().c_str(), BOOST_IOS::in); 67 | filtering_stream first(fb); 68 | ifstream second(test2.name().c_str()); 69 | BOOST_CHECK_MESSAGE( 70 | compare_streams_in_chunks(first, second), 71 | "failed reading from filtering_stream based on a" 72 | "streambuf in chunks with large buffer" 73 | ); 74 | } 75 | } 76 | 77 | #endif // #ifndef BOOST_IOSTREAMS_TEST_READ_BIDIRECTIONAL_STREAMBUF_HPP_INCLUDED 78 | -------------------------------------------------------------------------------- /doc/concepts/dual_use_filter.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DualUseFilter 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

DualUseFilter

13 | 14 | 15 | 16 | 17 |

Description

18 | 19 |

20 | A DualUseFilter is a Filter which can act as an InputFilter or as an OutputFilter, but not as both simultaneously. 21 |

22 |

23 | DualUseFilters help reduce the number of different Filter types required to implement a particlar filtering algorithm. For example, by implementing basic_regex_filter as a DualUseFilter, the Iostreams library avoids having to define separate templates basic_regex_input_filter and basic_regex_output_filter. 24 |

25 | 26 |

Refinement of

27 | 28 |

InputFilter, OutputFilter.

29 | 30 |

Associated Types

31 | 32 | 33 | 34 | 35 | 36 | 39 | 40 | 41 | 42 | 45 | 46 |
Character typeThe type of the characters in the filtered sequences
Category 37 | A type convertible to filter_tag and to dual_use 38 |
Mode 43 | The unique most-derived mode tag to which Category is convertible 44 |
47 | 48 |

Valid Expressions / Semantics

49 | 50 | Same as BidirectionalFilter. 51 | 52 |

Exceptions

53 | 54 | Same as BidirectionalFilter. 55 | 56 |

Models

57 | 58 | 62 | 63 | 64 | 65 |
66 | 67 | 68 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /test/write_output_seq_test.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) 2 | // (C) Copyright 2004-2007 Jonathan Turkanis 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) 5 | 6 | // See http://www.boost.org/libs/iostreams for documentation. 7 | 8 | #ifndef BOOST_IOSTREAMS_TEST_WRITE_OUTPUT_SEQUENCE_HPP_INCLUDED 9 | #define BOOST_IOSTREAMS_TEST_WRITE_OUTPUT_SEQUENCE_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "detail/sequence.hpp" 17 | #include "detail/temp_file.hpp" 18 | #include "detail/verification.hpp" 19 | 20 | void write_output_sequence_test() 21 | { 22 | using namespace std; 23 | using namespace boost; 24 | using namespace boost::iostreams; 25 | using namespace boost::iostreams::test; 26 | 27 | test_file test; 28 | 29 | { 30 | vector first(data_reps * data_length(), '?'); 31 | filtering_ostream out(make_iterator_range(first), 0); 32 | write_data_in_chars(out); 33 | ifstream second(test.name().c_str()); 34 | BOOST_CHECK_MESSAGE( 35 | compare_container_and_stream(first, second), 36 | "failed writing to filtering_ostream based on a sequence " 37 | "in chars with no buffer" 38 | ); 39 | } 40 | 41 | { 42 | vector first(data_reps * data_length(), '?'); 43 | filtering_ostream out(make_iterator_range(first), 0); 44 | write_data_in_chunks(out); 45 | ifstream second(test.name().c_str()); 46 | BOOST_CHECK_MESSAGE( 47 | compare_container_and_stream(first, second), 48 | "failed writing to filtering_ostream based on a sequence " 49 | "in chunks with no buffer" 50 | ); 51 | } 52 | 53 | { 54 | vector first(data_reps * data_length(), '?'); 55 | filtering_ostream out(make_iterator_range(first)); 56 | write_data_in_chars(out); 57 | ifstream second(test.name().c_str()); 58 | BOOST_CHECK_MESSAGE( 59 | compare_container_and_stream(first, second), 60 | "failed writing to filtering_ostream based on a sequence " 61 | "in chars with large buffer" 62 | ); 63 | } 64 | 65 | { 66 | vector first(data_reps * data_length(), '?'); 67 | filtering_ostream out(make_iterator_range(first)); 68 | write_data_in_chunks(out); 69 | ifstream second(test.name().c_str()); 70 | BOOST_CHECK_MESSAGE( 71 | compare_container_and_stream(first, second), 72 | "failed writing to filtering_ostream based on a sequence " 73 | "in chunks with large buffer" 74 | ); 75 | } 76 | } 77 | 78 | #endif // #ifndef BOOST_IOSTREAMS_TEST_WRITE_OUTPUT_SEQUENCE_HPP_INCLUDED 79 | --------------------------------------------------------------------------------