|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r63006 - in trunk: boost/iostreams/filter libs/iostreams/test
From: steven_at_[hidden]
Date: 2010-06-15 18:24:24
Author: steven_watanabe
Date: 2010-06-15 18:24:24 EDT (Tue, 15 Jun 2010)
New Revision: 63006
URL: http://svn.boost.org/trac/boost/changeset/63006
Log:
Make symmetric_filter compile with wchar_t. Fixes #3279.
Text files modified:
trunk/boost/iostreams/filter/symmetric.hpp | 8 ++++----
trunk/libs/iostreams/test/symmetric_filter_test.cpp | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 4 deletions(-)
Modified: trunk/boost/iostreams/filter/symmetric.hpp
==============================================================================
--- trunk/boost/iostreams/filter/symmetric.hpp (original)
+++ trunk/boost/iostreams/filter/symmetric.hpp 2010-06-15 18:24:24 EDT (Tue, 15 Jun 2010)
@@ -162,10 +162,10 @@
// Repeatedly invoke filter() with no input.
try {
- buffer_type& buf = pimpl_->buf_;
- char dummy;
- const char* end = &dummy;
- bool again = true;
+ buffer_type& buf = pimpl_->buf_;
+ char_type dummy;
+ const char_type* end = &dummy;
+ bool again = true;
while (again) {
if (buf.ptr() != buf.eptr())
again = filter().filter( end, end, buf.ptr(),
Modified: trunk/libs/iostreams/test/symmetric_filter_test.cpp
==============================================================================
--- trunk/libs/iostreams/test/symmetric_filter_test.cpp (original)
+++ trunk/libs/iostreams/test/symmetric_filter_test.cpp 2010-06-15 18:24:24 EDT (Tue, 15 Jun 2010)
@@ -132,12 +132,50 @@
}
}
+#ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS
+
+struct wcopy_filter_impl {
+ typedef wchar_t char_type;
+ bool filter( const wchar_t*& src_begin, const wchar_t* src_end,
+ wchar_t*& dest_begin, wchar_t* dest_end, bool /* flush */ )
+ {
+ if(src_begin != src_end && dest_begin != dest_end) {
+ *dest_begin++ = *src_begin++;
+ }
+ return false;
+ }
+ void close() {}
+};
+
+typedef symmetric_filter<wcopy_filter_impl> wcopy_filter;
+
+void wide_symmetric_filter()
+{
+ {
+ warray_source src(wide_data(), wide_data() + data_length());
+ std::wstring dest;
+ io::copy(src, io::compose(wcopy_filter(16), io::back_inserter(dest)));
+ BOOST_CHECK(dest == wide_data());
+ }
+ {
+ warray_source src(wide_data(), wide_data() + data_length());
+ std::wstring dest;
+ io::copy(io::compose(wcopy_filter(16), src), io::back_inserter(dest));
+ BOOST_CHECK(dest == wide_data());
+ }
+}
+
+#endif
+
test_suite* init_unit_test_suite(int, char* [])
{
test_suite* test = BOOST_TEST_SUITE("symmetric_filter test");
test->add(BOOST_TEST_CASE(&read_symmetric_filter));
test->add(BOOST_TEST_CASE(&write_symmetric_filter));
test->add(BOOST_TEST_CASE(&close_symmetric_filter));
+#ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS
+ test->add(BOOST_TEST_CASE(&wide_symmetric_filter));
+#endif
return test;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk