diff --git a/libs/endian/support/run_timer.cpp b/libs/endian/support/run_timer.cpp deleted file mode 100644 index ed58f5a..0000000 --- a/libs/endian/support/run_timer.cpp +++ /dev/null @@ -1,132 +0,0 @@ -// boost run_timer.cpp -----------------------------------------------------// - -// Copyright Beman Dawes 1994-2006 - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/system for documentation. - -//----------------------------------------------------------------------------// - -// define BOOST_ENDIAN_SOURCE so that knows -// the library is being built (possibly exporting rather than importing code) -#define BOOST_ENDIAN_SOURCE - -#include -#include -#include -#include -#include -#include -#include - -using boost::endian::microsecond_t; -using boost::endian::times_t; -using boost::system::error_code; - -# if defined(BOOST_WINDOWS_API) -# include -# elif defined(BOOST_POSIX_API) -# include -# else -# error unknown API -# endif - -namespace -{ - const char * default_format = - " %ws wall, %us user + %ss system = %ts cpu (%p%)\n"; - -void show_time(const char * format, int places, std::ostream& os, - const times_t& times) - // NOTE WELL: Will truncate least-significant digits to LDBL_DIG, which may - // be as low as 10, although will be 15 for many common platforms. - { - if (times.wall < microsecond_t(0)) - return; - if (places > 6) - places = 6; - else if (places < 0) - places = 0; - - boost::io::ios_flags_saver ifs(os); - boost::io::ios_precision_saver ips(os); - os.setf(std::ios_base::fixed, std::ios_base::floatfield); - os.precision(places); - - const long double sec = 1000000.0L; - microsecond_t total = times.system + times.user; - long double wall_sec = times.wall / sec; - long double total_sec = total / sec; - - for (; *format; ++format) - { - if (*format != '%' || !*(format+1) || !std::strchr("wustp", *(format+1))) - os << *format; - else - { - ++format; - switch (*format) - { - case 'w': - os << times.wall / sec; - break; - case 'u': - os << times.user / sec; - break; - case 's': - os << times.system / sec; - break; - case 't': - os << total / sec; - break; - case 'p': - os.precision(1); - if (wall_sec > 0.001L && total_sec > 0.001L) - os << (total_sec/wall_sec) * 100.0; - else - os << "n/a"; - os.precision(places); - break; - default: - assert(0); - } - } - } - } - -} // unnamed namespace - -namespace boost -{ - namespace endian - { - // run_timer:: report --------------------------------------// - - void run_timer::report() - { - show_time(!m_format - ? default_format - : m_format, - m_places, m_os, this->stop()); - } - - error_code run_timer::report(error_code& ec) - { - try - { - report(); - ec = error_code(); - } - - catch (...) // eat any exceptions - { - ec = error_code(EIO, system::generic_category()); - } - - return ec; - } - - } // namespace endian -} // namespace boost diff --git a/libs/endian/support/run_timer_ctors.cpp b/libs/endian/support/run_timer_ctors.cpp deleted file mode 100644 index 4b3089e..0000000 --- a/libs/endian/support/run_timer_ctors.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// boost run_timer_ctors.cpp -----------------------------------------------// - -// Copyright Beman Dawes 2007 - -// Distributed under the Boost Software License, Version 1.0. -// See http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/system for documentation. - -//----------------------------------------------------------------------------// - -// These constructors are in a separate file so that this translation unit will -// not be linked in except when one of the constructors is actually used. This -// is important since header is required, and it incurs the cost of -// the standard stream objects even if they are not used. - -//----------------------------------------------------------------------------// - -// define BOOST_ENDIAN_SOURCE so that knows -// the library is being built (possibly exporting rather than importing code) -#define BOOST_ENDIAN_SOURCE - -#include -#include - -namespace boost -{ - namespace endian - { - run_timer::run_timer(int places) - : m_places(places), m_os(std::cout), m_format(0) {} - - run_timer::run_timer(const std::string& format, int places) - : m_places(places), m_os(std::cout), m_format(new char[format.size()+1]) - { std::strcpy(m_format, format.c_str()); } - - } // namespace endian -} // namespace boost diff --git a/libs/endian/support/timer.cpp b/libs/endian/support/timer.cpp deleted file mode 100644 index db0a0f1..0000000 --- a/libs/endian/support/timer.cpp +++ /dev/null @@ -1,167 +0,0 @@ -// boost timer.cpp ---------------------------------------------------------// - -// Copyright Beman Dawes 1994-2006 - -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/system for documentation. - -//----------------------------------------------------------------------------// - -// define BOOST_ENDIAN_SOURCE so that knows -// the library is being built (possibly exporting rather than importing code) -#define BOOST_ENDIAN_SOURCE - -#include -#include -#include -#include -#include -#include -#include - -# if defined(BOOST_WINDOWS_API) -# include -# elif defined(BOOST_POSIX_API) -# include -# include -# else -# error unknown API -# endif - -using boost::system::error_code; - -# if defined(BOOST_POSIX_API) -namespace -{ - long tick_factor() // multiplier to convert ticks - // to microseconds; -1 if unknown - { - static long tick_factor = 0; - if (!tick_factor) - { - if ((tick_factor = ::sysconf(_SC_CLK_TCK)) <= 0) - tick_factor = -1; - else - { - assert(tick_factor <= 1000000L); // doesn't handle large ticks - tick_factor = 1000000L / tick_factor; // compute factor - if (!tick_factor) tick_factor = -1; - } - } - return tick_factor; - } -} // unnamed namespace -# endif - -namespace boost -{ - namespace endian - { - - BOOST_ENDIAN_DECL - void times(times_t& current) - { - error_code ec; - if (times(current, ec)) - boost::throw_exception(system::system_error(ec, "boost::endian::times")); - } - - BOOST_ENDIAN_DECL - error_code& times(times_t& current, error_code& ec) - { - ec = error_code(); -# if defined(BOOST_WINDOWS_API) - ::GetSystemTimeAsFileTime((LPFILETIME)¤t.wall); - FILETIME creation, exit; - if (::GetProcessTimes(::GetCurrentProcess(), &creation, &exit, - (LPFILETIME)¤t.system, (LPFILETIME)¤t.user)) - { - current.wall /= 10; // Windows uses 100 nanosecond ticks - current.user /= 10; - current.system /= 10; - } - else - { - ec = error_code(::GetLastError(), system::system_category()); - current.wall = current.system = current.user = microsecond_t(-1); - } -# else - tms tm; - clock_t c = ::times(&tm); - if (c == -1) // error - { - ec = error_code(errno, system::system_category()); - current.wall = current.system = current.user = microsecond_t(-1); - } - else - { - current.wall = microsecond_t(c); - current.system = microsecond_t(tm.tms_stime + tm.tms_cstime); - current.user = microsecond_t(tm.tms_utime + tm.tms_cutime); - if (tick_factor() != -1) - { - current.wall *= tick_factor(); - current.user *= tick_factor(); - current.system *= tick_factor(); - } - else - { - ec = error_code(errno, system::system_category()); - current.wall = current.user = current.system = microsecond_t(-1); - } - } -# endif - return ec; - } - -#define BOOST_TIMES(C) \ - if (m_flags& m_nothrow) \ - { \ - error_code ec; \ - times(C, ec); \ - } \ - else \ - times(C); - - // timer ---------------------------------------------------------------// - - void timer::start() - { - m_flags = static_cast(m_flags& ~m_stopped); - BOOST_TIMES(m_times); - } - - const times_t& timer::stop() - { - if (stopped()) return m_times; - m_flags = static_cast(m_flags | m_stopped); - - times_t current; - BOOST_TIMES(current); - m_times.wall = (current.wall - m_times.wall); - m_times.user = (current.user - m_times.user); - m_times.system = (current.system - m_times.system); - return m_times; - } - - void timer::elapsed(times_t& current) - { - if (stopped()) - { - current.wall = m_times.wall; - current.user = m_times.user; - current.system = m_times.system; - } - else - { - BOOST_TIMES(current); - current.wall -= m_times.wall; - current.user -= m_times.user; - current.system -= m_times.system; - } - } - - } // namespace endian -} // namespace boost diff --git a/libs/io/doc/bin_manip.html b/libs/io/doc/bin_manip.html deleted file mode 100644 index 9e3080d..0000000 --- a/libs/io/doc/bin_manip.html +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - -Binary Stream I/O - - - - - - - - - - - -
boost.png (6897 bytes) -

Binary - I/O Manipulators
- for Binary Streams

-
- - - - - -
-

Binary - I/O Manipulators - for Strings are not yet accepted into Boost as public components. Thus the - header file is currently located in <boost/io/detail/bin_manip.hpp>

- -

Introduction

-

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.  -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.

-

Standard library streams can be opened with filemode -std::ios_base::binary, so binary I/O is possible. But the only -unformatted I/O functions available are get(), put(), -read(), and write(). These operate only on char -or array of char (with length explicitly specified), so require the -user to write casts, are hard to use, and are error prone.

-

There have been many requests on Boost and various C++ newsgroups for -unformatted binary I/O. For example, in 2003 Neal Becker wrote:

-
-

I wonder if anyone has code for implementing unformatted I/O?  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.

-
-

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 std::ios_base::binary -to avoid certain data values being treated as line endings.

-

Synopsis

-
-
namespace boost
-{
-  template <class T>
-  unspecified-type-1<T> bin(const T& x);
-
-  template <class T>
-  unspecified-type-2<T> bin(T& x);
-
-  template <class T>
-  std::ostream& operator<<(std::ostream& os, unspecified-type-1<T> x);
-
-  template <class T>
-  std::ostream& operator<<(std::ostream& os, unspecified-type-2<T> x);
-
-  template <class T>
-  std::istream& operator>>(std::istream& is, unspecified-type-2<T> x);
-}
-
-

unspecified-type-1 and unspecified-type-2 -are implementation supplied types.

-

Example

-
-
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;
-}
-
-

The file produced will be four bytes in length. On a big-endian machine, the -contents in hexadecimal are:

-
-
01020304
-
-

On a little-endian machine, the contents in hexadecimal are:

-
-
04030201
-
-
-

Last revised: -26 May, 2011

-

© Copyright Beman Dawes, 2009, 2011

-

Distributed under the Boost Software License, Version 1.0. See -www.boost.org/ LICENSE_1_0.txt

- -

 

-

 

-

 

-

 

- - - - \ No newline at end of file diff --git a/libs/io/doc/index.html b/libs/io/doc/index.html deleted file mode 100644 index 4885739..0000000 --- a/libs/io/doc/index.html +++ /dev/null @@ -1,67 +0,0 @@ - - - -Boost I/O Library - - - - - - - - - - - - -
boost.png (6897 bytes)HomeLibrariesPeopleFAQMore
- -

Boost Input/Output Library

- - - - - - - - - - - - - - -
Header / DocsContents
- <boost/io_fwd.hpp> - - Forward declaration header. -
- <boost/io/ios_state.hpp>
-
documentation -
- State-saving classes for various IOStream attributes. -
- -

Rationale

- -

The I/O sub-library of Boost helps segregate the large number of -Boost headers. This sub-library should contain various items to use -with/for the standard I/O library.

- -
- -

Revised: 26 Feb 2002

- -

Copyright 2002 Daryle Walker. Use, modification, and distribution are -subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)

- - diff --git a/libs/io/example/bin_manip_example.cpp b/libs/io/example/bin_manip_example.cpp deleted file mode 100644 index fdb3118..0000000 --- a/libs/io/example/bin_manip_example.cpp +++ /dev/null @@ -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 -#include -#include -#include - -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; -} diff --git a/libs/io/test/Jamfile.v2 b/libs/io/test/Jamfile.v2 deleted file mode 100644 index 458b6c6..0000000 --- a/libs/io/test/Jamfile.v2 +++ /dev/null @@ -1,27 +0,0 @@ -# Boost.IO Library test Jamfile -# -# Copyright 2003 Daryle Walker. Use, modification, and distribution -# are subject to the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or a copy at -# .) -# -# See for the library's home page. - -test-suite "io" - : [ run ios_state_unit_test.cpp - ../../../libs/test/build//boost_unit_test_framework/static - : # args - : # input files - # : std::locale-support - ] - - [ run ios_state_test.cpp - ../../../libs/test/build//boost_test_exec_monitor/static - : # args - : # input files - # : std::locale-support - ] - - [ run quoted_manip_test.cpp ] - [ run bin_manip_test.cpp ] - ; diff --git a/libs/io/test/bin_manip_test.cpp b/libs/io/test/bin_manip_test.cpp deleted file mode 100644 index 95f042b..0000000 --- a/libs/io/test/bin_manip_test.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// bin_manip_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 -#include -#include -#include -#include - -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(); -}