Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72187 - in sandbox/endian: boost boost/io/detail libs/endian/doc libs/endian/example libs/endian/test libs/io/doc libs/io/example libs/io/test
From: bdawes_at_[hidden]
Date: 2011-05-26 13:36:33


Author: bemandawes
Date: 2011-05-26 13:36:32 EDT (Thu, 26 May 2011)
New Revision: 72187
URL: http://svn.boost.org/trac/boost/changeset/72187

Log:
Complete move of bin_manip files from endian to io library
Added:
   sandbox/endian/boost/io/detail/bin_manip.hpp
      - copied unchanged from r72184, /sandbox/endian/boost/bin_manip.hpp
   sandbox/endian/libs/io/doc/bin_manip.html
      - copied unchanged from r72184, /sandbox/endian/libs/endian/doc/bin_manip.html
   sandbox/endian/libs/io/example/
   sandbox/endian/libs/io/example/bin_manip_example.cpp
      - copied unchanged from r72184, /sandbox/endian/libs/endian/example/bin_manip_example.html
   sandbox/endian/libs/io/test/bin_manip_test.cpp
      - copied unchanged from r72184, /sandbox/endian/libs/endian/test/bin_manip_test.cpp
Removed:
   sandbox/endian/boost/bin_manip.hpp
   sandbox/endian/libs/endian/doc/bin_manip.html
   sandbox/endian/libs/endian/example/bin_manip_example.html
   sandbox/endian/libs/endian/test/bin_manip_test.cpp

Deleted: sandbox/endian/boost/bin_manip.hpp
==============================================================================
--- sandbox/endian/boost/bin_manip.hpp 2011-05-26 13:36:32 EDT (Thu, 26 May 2011)
+++ (empty file)
@@ -1,82 +0,0 @@
-// boost/binary_stream.hpp ----------------------------------------------------------//
-
-// Copyright Beman Dawes 2009, 2011
-
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-// See documentation at http://www.boost.org/libs/utility
-
-#ifndef BOOST_BINARY_STREAM_HPP
-#define BOOST_BINARY_STREAM_HPP
-
-#include <boost/config.hpp>
-#include <ostream>
-#include <istream>
-#include <string>
-#include <cstring> // for strlen
-
-#ifndef BOOST_NO_CWCHAR
-# include <cwchar> // for wcslen
-#endif
-
-// unformatted binary (as opposed to formatted character) input and output
-
-// Caution: Use only on streams opened with filemode std::ios_base::binary. Thus
-// unformatted binary I/O should not be with the standard streams (cout, cin, etc.)
-// since they are opened in text mode. Use on text streams may produce incorrect
-// results, such as insertion of unwanted characters or premature end-of-file.
-// For example, on Windows 0x0D would become 0x0D, 0x0A.
-
-namespace boost
-{
-
-namespace detail
-{
- template <class T>
- struct const_binary_data
- {
- const char* ptr;
- explicit const_binary_data(const T& x) : ptr(reinterpret_cast<const char*>(&x)) {}
- };
- template <class T>
- struct binary_data
- {
- char* ptr;
- explicit binary_data(T& x) : ptr(reinterpret_cast<char*>(&x)) {}
- };
-}
-
-template <class T>
-inline detail::const_binary_data<T> bin(const T& x)
-{
- return detail::const_binary_data<T>(x);
-}
-
-template <class T>
-inline detail::binary_data<T> bin(T& x)
-{
- return detail::binary_data<T>(x);
-}
-
-template <class T>
-inline std::ostream& operator<<(std::ostream& os, detail::const_binary_data<T> x)
-{
- return os.write(x.ptr, sizeof(T));
-}
-
-template <class T>
-inline std::ostream& operator<<(std::ostream& os, detail::binary_data<T> x)
-{
- return os.write(x.ptr, sizeof(T));
-}
-
-template <class T>
-inline std::istream& operator>>(std::istream& is, detail::binary_data<T> x)
-{
- return is.read(x.ptr, sizeof(T));
-}
-
-} // namespace boost
-
-#endif // BOOST_BINARY_STREAM_HPP

Deleted: sandbox/endian/libs/endian/doc/bin_manip.html
==============================================================================
--- sandbox/endian/libs/endian/doc/bin_manip.html 2011-05-26 13:36:32 EDT (Thu, 26 May 2011)
+++ (empty file)
@@ -1,103 +0,0 @@
-<html>
-
-<head>
-<meta http-equiv="Content-Language" content="en-us">
-<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
-<meta name="ProgId" content="FrontPage.Editor.Document">
-<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
-<title>Binary Stream I/O</title>
-<link rel="stylesheet" type="text/css" href="../../../doc/html/minimal.css">
-</head>
-
-<body>
-
-<h1>Proposal for Binary Stream I/O</h1>
-<h2>Introduction</h2>
-<p>The C++ standard library's stream I/O facilities are type-safe and very
-convenient for performing formatted (i.e. human readable) I/O. But they offer only
-rudimentary and not very type-safe operations for performing unformatted binary I/O.&nbsp;
-Although formatted I/O is often preferable, some applications need the speed and
-storage efficiency of unformatted binary I/O or need to interoperate with third-party
-applications that require unformatted binary file or network data formats.</p>
-<p>Standard library streams can be opened with filemode <code>
-std::ios_base::binary</code>, so binary I/O is possible. But the only
-unformatted I/O functions available are <code>get()</code>, <code>put()</code>,
-<code>read()</code>, and <code>write()</code>. These operate only on <code>char</code>
-or array of <code>char</code> (with length explicitly specified), so require the
-user to write casts, are hard to use, and are error prone.</p>
-<p>There have been many requests on Boost and various C++ newsgroups for
-unformatted binary I/O. For example, in 2003 Neal Becker wrote:</p>
-<blockquote>
-<p>I wonder if anyone has code for implementing unformatted I/O?&nbsp; What I
-have in mind is for the simple case where the application that reads data knows
-the data types, so this is not as complicated as the general marshalling
-situation.</p>
-</blockquote>
-<p>This proposal provides a simple solution that works with standard library
-input and output streams. The one caveat is that the stream must be opened with filemode <code>std::ios_base::binary</code>
-to avoid certain data values being treated as line endings.</p>
-<h2>Synopsis</h2>
-<div dir="ltr">
- <pre>namespace boost
-{
- template &lt;class T&gt;
- <i>unspecified-type-1&lt;T&gt;</i> bin(const T&amp; x);
-
- template &lt;class T&gt;
- <i>unspecified-type-2&lt;T&gt;</i> bin(T&amp; x);
-
- template &lt;class T&gt;
- std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, <i>unspecified-type-1&lt;T&gt;</i> x);
-
- template &lt;class T&gt;
- std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, <i>unspecified-type-2&lt;T&gt;</i> x);
-
- template &lt;class T&gt;
- std::istream&amp; operator&gt;&gt;(std::istream&amp; is, <i>unspecified-type-2&lt;T&gt;</i> x);
-}</pre>
-</div>
-<p><i><code>unspecified-type-1</code></i> and <i><code>unspecified-type-2</code></i>
-are implementation supplied types.</p>
-<h2>Example</h2>
-<blockquote>
- <pre>int main()
-{
- fstream f(&quot;binary_stream_example.dat&quot;,
- std::ios_base::trunc | std::ios_base::in | std::ios_base::out | std::ios_base::binary);
-
- int32_t x = 0x01020304;
- int32_t y = 0;
-
- f &lt;&lt; bin(x);
- f.seekg(0);
- f &gt;&gt; bin(y);
-
- BOOST_ASSERT(x == y);
-
- return 0;
-}</pre>
-</blockquote>
-<p>The file produced with be four bytes in length. On a big-endian machine, the
-contents in hexadecimal are:</p>
-<blockquote>
- <pre>01020304</pre>
-</blockquote>
-<p>On a little-endian machine, the contents in hexadecimal are:</p>
-<blockquote>
- <pre>04030201</pre>
-</blockquote>
-<hr>
-<p>Last revised:
-<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->24 April, 2011<!--webbot bot="Timestamp" endspan i-checksum="29830" --></p>
-<p>© Copyright Beman Dawes, 2009, 2011</p>
-<p>Distributed under the Boost Software License, Version 1.0. See
-www.boost.org/ LICENSE_1_0.txt</p>
-
-<p>&nbsp;</p>
-<p>&nbsp;</p>
-<p>&nbsp;</p>
-<p>&nbsp;</p>
-
-</body>
-
-</html>
\ No newline at end of file

Deleted: sandbox/endian/libs/endian/example/bin_manip_example.html
==============================================================================
--- sandbox/endian/libs/endian/example/bin_manip_example.html 2011-05-26 13:36:32 EDT (Thu, 26 May 2011)
+++ (empty file)
@@ -1,30 +0,0 @@
-// binary_stream_example.cpp ---------------------------------------------------------//
-
-// Copyright Beman Dawes 2011
-
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-#include <boost/binary_stream.hpp>
-#include <boost/integer.hpp>
-#include <boost/assert.hpp>
-#include <fstream>
-
-using namespace boost;
-using namespace std;
-
-int main()
-{
- fstream f("binary_stream_example.dat",
- std::ios_base::trunc | std::ios_base::in | std::ios_base::out | std::ios_base::binary);
-
- int32_t x = 0x01020304;
- int32_t y = 0;
-
- f << bin(x);
- f.seekg(0);
- f >> bin(y);
- BOOST_ASSERT(x == y);
-
- return 0;
-}

Deleted: sandbox/endian/libs/endian/test/bin_manip_test.cpp
==============================================================================
--- sandbox/endian/libs/endian/test/bin_manip_test.cpp 2011-05-26 13:36:32 EDT (Thu, 26 May 2011)
+++ (empty file)
@@ -1,112 +0,0 @@
-// binary_stream_test.cpp ------------------------------------------------------------//
-
-// Copyright Beman Dawes 2009
-
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-#include <boost/binary_stream.hpp>
-#include <string>
-#include <iostream>
-#include <sstream>
-#include <boost/detail/lightweight_test.hpp>
-
-using namespace boost;
-using namespace std;
-
-int main()
-{
- std::stringstream ss( std::ios_base::in | std::ios_base::out | std::ios_base::binary );
-
- short short_1(0x0102), short_2;
- ss.clear();
- ss << bin(short_1);
- ss >> bin(short_2);
- BOOST_TEST( short_1 == short_2 );
-
- unsigned short ushort_1(0x0102), ushort_2;
- ss.clear();
- ss << bin(ushort_1);
- ss >> bin(ushort_2);
- BOOST_TEST( ushort_1 == ushort_2 );
-
- int int_1(0x01020304), int_2;
- ss.clear();
- ss << bin(int_1);
- ss >> bin(int_2);
- BOOST_TEST( int_1 == int_2 );
-
- unsigned int uint_1(0x01020304), uint_2;
- ss.clear();
- ss << bin(uint_1);
- ss >> bin(uint_2);
- BOOST_TEST( uint_1 == uint_2 );
-
- long long_1(0x01020304L), long_2;
- ss.clear();
- ss << bin(long_1);
- ss >> bin(long_2);
- BOOST_TEST( long_1 == long_2 );
-
- unsigned long ulong_1(0x01020304UL), ulong_2;
- ss.clear();
- ss << bin(ulong_1);
- ss >> bin(ulong_2);
- BOOST_TEST( ulong_1 == ulong_2 );
-
- long long long_long_1(0x0102030405060708LL), long_long_2;
- ss.clear();
- ss << bin(long_long_1);
- ss >> bin(long_long_2);
- BOOST_TEST( long_long_1 == long_long_2 );
-
- unsigned long long ulong_long_1(0x0102030405060708ULL), ulong_long_2;
- ss.clear();
- ss << bin(ulong_long_1);
- ss >> bin(ulong_long_2);
- BOOST_TEST( ulong_long_1 == ulong_long_2 );
-
- float float_1(1.2F), float_2;
- ss.clear();
- ss << bin(float_1);
- ss >> bin(float_2);
- BOOST_TEST( float_1 == float_2 );
-
- double double_1(1.2), double_2;
- ss.clear();
- ss << bin(double_1);
- ss >> bin(double_2);
- BOOST_TEST( double_1 == double_2 );
-
- long double long_double_1(1.2), long_double_2;
- ss.clear();
- ss << bin(long_double_1);
- ss >> bin(long_double_2);
- BOOST_TEST( long_double_1 == long_double_2 );
-
- char char_1(0x01), char_2;
- ss.clear();
- ss << bin(char_1);
- ss >> bin(char_2);
- BOOST_TEST( char_1 == char_2 );
-
- signed char schar_1(0x01), schar_2;
- ss.clear();
- ss << bin(schar_1);
- ss >> bin(schar_2);
- BOOST_TEST( schar_1 == schar_2 );
-
- unsigned char uchar_1(0x01), uchar_2;
- ss.clear();
- ss << bin(uchar_1);
- ss >> bin(uchar_2);
- BOOST_TEST( uchar_1 == uchar_2 );
-
- wchar_t wchar_t_1(L'1'), wchar_t_2;
- ss.clear();
- ss << bin(wchar_t_1);
- ss >> bin(wchar_t_2);
- BOOST_TEST( wchar_t_1 == wchar_t_2 );
-
- return ::boost::report_errors();
-}


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