diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index b2d5229..dda8f39 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -99,19 +99,6 @@ boostbook standalone_declval generate.section.toc.level=1 ; -xml ostream_string : ostream_string.qbk ; -boostbook standalone_ostream_string - : - ostream_string - : - root.filename=ostream_string - chunk.section.depth=0 - chunk.first.sections=0 - toc.section.depth=1 - toc.max.depth=1 - generate.section.toc.level=1 - ; - xml string_ref : string_ref.qbk ; boostbook standalone_string_ref : @@ -136,5 +123,5 @@ alias boostdoc ; explicit boostdoc ; alias boostrelease : standalone_base_from_member standalone_compressed_pair - standalone_declval standalone_ostream_string standalone_string_ref ; + standalone_declval standalone_string_ref ; explicit boostrelease ; diff --git a/doc/ostream_string.qbk b/doc/ostream_string.qbk deleted file mode 100644 index 2fa06a8..0000000 --- a/doc/ostream_string.qbk +++ /dev/null @@ -1,78 +0,0 @@ -[/ -Copyright 2019 Glen Joseph Fernandes -(glenjofe@gmail.com) - -Distributed under the Boost Software License, Version 1.0. -(http://www.boost.org/LICENSE_1_0.txt) -] - -[article ostream_string -[quickbook 1.5] -[authors [Fernandes, Glen]] -[copyright 2019 Glen Joseph Fernandes] -[license Distributed under the Boost Software License, Version 1.0.]] - -[section Overview] - -The header provides the function template -`boost::ostream_string` for formatted output that satisfies the requirements of -\[ostream.formatted.reqmts\]. - -[endsect] - -[section Examples] - -The inserter for class template `basic_string_view` could be implemented as -follows: - -``` -template -std::basic_ostream& -operator<<(std::basic_ostream& os, - const basic_string_view& str) -{ - return boost::ostream_string(os, str.data(), str.size()); -} -``` - -[endsect] - -[section Reference] - -``` -namespace boost { - -template -std::basic_ostream& -ostream_string(std::basic_ostream& os, - const charT* data, std::size_t size); - -} /* boost */ -``` - -[heading Free functions] - -[variablelist -[[`template std::basic_ostream& -ostream_string(std::basic_ostream& os, const charT* data, -std::size_t size);`] -[[variablelist -[[Effects] -[Behaves like a formatted inserter (as described in -\[ostream.formatted.reqmts\]) of `os`. Creates a character sequence `seq` of -`size` characters starting at `data`, each widened using `os.widen()` -(\[basic.ios.members\]). Determines padding for `seq` as described in -\[ostream.formatted.reqmts\]. Inserts `seq` into `os`. Calls `width(0)`.]] -[[Returns][`os`.]]]]]] - -[endsect] - -[section History] - -[heading boost 1.71] - -* Glen Fernandes updated the implementation of the `basic_string_ref` and -`basic_string_view` stream insertion operators to write directly to the -`basic_streambuf` and refactored that functionality into this common utility. - -[endsect] diff --git a/include/boost/utility/ostream_string.hpp b/include/boost/utility/ostream_string.hpp deleted file mode 100644 index 8722e58..0000000 --- a/include/boost/utility/ostream_string.hpp +++ /dev/null @@ -1,95 +0,0 @@ -/* -Copyright 2019 Glen Joseph Fernandes -(glenjofe@gmail.com) - -Distributed under the Boost Software License, Version 1.0. -(http://www.boost.org/LICENSE_1_0.txt) -*/ -#ifndef BOOST_UTILITY_OSTREAM_STRING_HPP -#define BOOST_UTILITY_OSTREAM_STRING_HPP - -#include -#include -#include - -namespace boost { -namespace detail { - -template -inline std::size_t -oss_put(std::basic_ostream& os, const charT* data, - std::size_t size) -{ - return static_cast(os.rdbuf()->sputn(data, size)); -} - -template -inline bool -oss_fill(std::basic_ostream& os, std::size_t size) -{ - charT c = os.fill(); - charT fill[] = { c, c, c, c, c, c, c, c }; - enum { - chunk = sizeof fill / sizeof(charT) - }; - for (; size > chunk; size -= chunk) { - if (boost::detail::oss_put(os, fill, chunk) != chunk) { - return false; - } - } - return boost::detail::oss_put(os, fill, size) == size; -} - -template -class oss_guard { -public: - explicit oss_guard(std::basic_ostream& os) BOOST_NOEXCEPT - : os_(&os) { } - ~oss_guard() BOOST_NOEXCEPT_IF(false) { - if (os_) { - os_->setstate(std::basic_ostream::badbit); - } - } - void release() BOOST_NOEXCEPT { - os_ = 0; - } -private: - oss_guard(const oss_guard&); - oss_guard& operator=(const oss_guard&); - std::basic_ostream* os_; -}; - -} /* detail */ - -template -inline std::basic_ostream& -ostream_string(std::basic_ostream& os, const charT* data, - std::size_t size) -{ - typedef std::basic_ostream stream; - detail::oss_guard guard(os); - typename stream::sentry entry(os); - if (entry) { - std::size_t width = static_cast(os.width()); - if (width <= size) { - if (detail::oss_put(os, data, size) != size) { - return os; - } - } else if ((os.flags() & stream::adjustfield) == stream::left) { - if (detail::oss_put(os, data, size) != size || - !detail::oss_fill(os, width - size)) { - return os; - } - } else if (!detail::oss_fill(os, width - size) || - detail::oss_put(os, data, size) != size) { - return os; - } - os.width(0); - } - guard.release(); - return os; -} - -} /* boost */ - -#endif diff --git a/include/boost/utility/string_ref.hpp b/include/boost/utility/string_ref.hpp index 999f1c3..706967d 100644 --- a/include/boost/utility/string_ref.hpp +++ b/include/boost/utility/string_ref.hpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include @@ -427,7 +427,7 @@ namespace boost { template inline std::basic_ostream& operator<<(std::basic_ostream& os, const basic_string_ref& str) { - return boost::ostream_string(os, str.data(), str.size()); + return boost::io::ostream_put(os, str.data(), str.size()); } #if 0 diff --git a/include/boost/utility/string_view.hpp b/include/boost/utility/string_view.hpp index ba4ef93..35471fb 100644 --- a/include/boost/utility/string_view.hpp +++ b/include/boost/utility/string_view.hpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include @@ -578,7 +578,7 @@ namespace boost { inline std::basic_ostream& operator<<(std::basic_ostream& os, const basic_string_view& str) { - return boost::ostream_string(os, str.data(), str.size()); + return boost::io::ostream_put(os, str.data(), str.size()); } #if 0 diff --git a/index.html b/index.html index 7dcdd64..c2af44f 100644 --- a/index.html +++ b/index.html @@ -12,30 +12,31 @@

The Boost Utility Library isn't really a single library at all. It is just a collection for components too small to be called libraries in their own right.

But that doesn't mean there isn't useful stuff here. Take a look:

-
-

- addressof (moved to the Boost.Core library)
- base_from_member
- BOOST_BINARY
- call_traits
- checked_delete (moved to the Boost.Core library)
- compressed_pair
- declval (moved to the Boost.TypeTraits library)
- enable_if (moved to the Boost.Core library)
- in_place_factory
- iterator_adaptors
- generator iterator adaptors (moved to the Boost.Iterator library)
- next/prior (moved to the Boost.Iterator library)
- noncopyable (moved to the Boost.Core library)
- operators
- result_of
- throw_exception
- utility
- ostream_string
- string_ref
- value_init
-

-
+ +

Over time useful stuff here has moved to more appropriate Boost libraries:

+

© Copyright Beman Dawes, 2001

Distributed under the Boost Software License, Version 1.0. (See diff --git a/meta/libraries.json b/meta/libraries.json index f3c52ba..ca7c4b6 100644 --- a/meta/libraries.json +++ b/meta/libraries.json @@ -85,19 +85,6 @@ "Daniel Frey " ] }, - { - "key": "utility/ostream_string", - "name": "ostream_string", - "description": "String formatted output function.", - "documentation": "doc/html/ostream_string.html", - "category": [ - "IO" - ], - "authors": "Glen Fernandes", - "maintainers": [ - "Glen Fernandes " - ] - }, { "key": "utility/result_of", "name": "Result Of", diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d0277ef..739edc0 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -42,5 +42,3 @@ compile-fail value_init_test_fail2.cpp ; compile-fail value_init_test_fail3.cpp ; compile-fail initialized_test_fail1.cpp ; compile-fail initialized_test_fail2.cpp ; - -run ostream_string_test.cpp ; diff --git a/test/ostream_string_test.cpp b/test/ostream_string_test.cpp deleted file mode 100644 index e6145b3..0000000 --- a/test/ostream_string_test.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* -Copyright 2019 Glen Joseph Fernandes -(glenjofe@gmail.com) - -Distributed under the Boost Software License, Version 1.0. -(http://www.boost.org/LICENSE_1_0.txt) -*/ -#include -#include -#include -#include - -int main() -{ - { - std::ostringstream os; - os.width(1); - os.fill('.'); - os.setf(std::ios_base::left, std::ios_base::adjustfield); - boost::ostream_string(os, "xy", 2); - BOOST_TEST(os.good()); - BOOST_TEST(os.width() == 0); - BOOST_TEST(os.str() == "xy"); - } - { - std::wostringstream os; - os.width(1); - os.fill('.'); - os.setf(std::ios_base::left, std::ios_base::adjustfield); - boost::ostream_string(os, L"xy", 2); - BOOST_TEST(os.good()); - BOOST_TEST(os.width() == 0); - BOOST_TEST(os.str() == L"xy"); - } - { - std::ostringstream os; - os.width(1); - os.fill('.'); - os.setf(std::ios_base::right, std::ios_base::adjustfield); - boost::ostream_string(os, "xy", 2); - BOOST_TEST(os.good()); - BOOST_TEST(os.width() == 0); - BOOST_TEST(os.str() == "xy"); - } - { - std::wostringstream os; - os.width(1); - os.fill('.'); - os.setf(std::ios_base::right, std::ios_base::adjustfield); - boost::ostream_string(os, L"xy", 2); - BOOST_TEST(os.good()); - BOOST_TEST(os.width() == 0); - BOOST_TEST(os.str() == L"xy"); - } - { - std::ostringstream os; - os.width(4); - os.fill('.'); - os.setf(std::ios_base::left, std::ios_base::adjustfield); - boost::ostream_string(os, "xy", 2); - BOOST_TEST(os.good()); - BOOST_TEST(os.width() == 0); - BOOST_TEST(os.str() == "xy.."); - } - { - std::wostringstream os; - os.width(4); - os.fill(L'.'); - os.setf(std::ios_base::left, std::ios_base::adjustfield); - boost::ostream_string(os, L"xy", 2); - BOOST_TEST(os.good()); - BOOST_TEST(os.width() == 0); - BOOST_TEST(os.str() == L"xy.."); - } - { - std::ostringstream os; - os.width(4); - os.fill('.'); - os.setf(std::ios_base::right, std::ios_base::adjustfield); - boost::ostream_string(os, "xy", 2); - BOOST_TEST(os.good()); - BOOST_TEST(os.width() == 0); - BOOST_TEST(os.str() == "..xy"); - } - { - std::wostringstream os; - os.width(4); - os.fill(L'.'); - os.setf(std::ios_base::right, std::ios_base::adjustfield); - boost::ostream_string(os, L"xy", 2); - BOOST_TEST(os.good()); - BOOST_TEST(os.width() == 0); - BOOST_TEST(os.str() == L"..xy"); - } - { - std::ostringstream os; - os.width(12); - os.fill('.'); - os.setf(std::ios_base::left, std::ios_base::adjustfield); - boost::ostream_string(os, "xy", 2); - BOOST_TEST(os.good()); - BOOST_TEST(os.width() == 0); - BOOST_TEST(os.str() == "xy.........."); - } - { - std::wostringstream os; - os.width(12); - os.fill(L'.'); - os.setf(std::ios_base::left, std::ios_base::adjustfield); - boost::ostream_string(os, L"xy", 2); - BOOST_TEST(os.good()); - BOOST_TEST(os.width() == 0); - BOOST_TEST(os.str() == L"xy.........."); - } - { - std::ostringstream os; - os.width(12); - os.fill('.'); - os.setf(std::ios_base::right, std::ios_base::adjustfield); - boost::ostream_string(os, "xy", 2); - BOOST_TEST(os.good()); - BOOST_TEST(os.width() == 0); - BOOST_TEST(os.str() == "..........xy"); - } - { - std::wostringstream os; - os.width(12); - os.fill(L'.'); - os.setf(std::ios_base::right, std::ios_base::adjustfield); - boost::ostream_string(os, L"xy", 2); - BOOST_TEST(os.good()); - BOOST_TEST(os.width() == 0); - BOOST_TEST(os.str() == L"..........xy"); - } - return boost::report_errors(); -}