| 1 | // Copyright Kevlin Henney, 2000-2005. |
| 2 | // Copyright Alexander Nasonov, 2006-2010. |
| 3 | // Copyright Antony Polukhin, 2011-2024. |
| 4 | // |
| 5 | // Distributed under the Boost Software License, Version 1.0. (See |
| 6 | // accompanying file LICENSE_1_0.txt or copy at |
| 7 | // http://www.boost.org/LICENSE_1_0.txt) |
| 8 | |
| 9 | #ifndef BOOST_LEXICAL_CAST_DETAIL_CONVERTER_LEXICAL_BASIC_UNLOCKEDBUF_HPP |
| 10 | #define BOOST_LEXICAL_CAST_DETAIL_CONVERTER_LEXICAL_BASIC_UNLOCKEDBUF_HPP |
| 11 | |
| 12 | #include <boost/config.hpp> |
| 13 | #ifdef BOOST_HAS_PRAGMA_ONCE |
| 14 | # pragma once |
| 15 | #endif |
| 16 | |
| 17 | |
| 18 | #ifdef BOOST_NO_STRINGSTREAM |
| 19 | #include <strstream> |
| 20 | #else |
| 21 | #include <sstream> |
| 22 | #endif |
| 23 | |
| 24 | #include <boost/detail/basic_pointerbuf.hpp> |
| 25 | #ifndef BOOST_NO_CWCHAR |
| 26 | # include <cwchar> |
| 27 | #endif |
| 28 | |
| 29 | namespace boost { namespace detail { namespace lcast { |
| 30 | |
| 31 | // acts as a stream buffer which wraps around a pair of pointers |
| 32 | // and gives acces to internals |
| 33 | template <class BufferType, class CharT> |
| 34 | class basic_unlockedbuf : public basic_pointerbuf<CharT, BufferType> { |
| 35 | public: |
| 36 | typedef basic_pointerbuf<CharT, BufferType> base_type; |
| 37 | typedef typename base_type::streamsize streamsize; |
| 38 | |
| 39 | using base_type::pptr; |
| 40 | using base_type::pbase; |
| 41 | using base_type::setbuf; |
| 42 | }; |
| 43 | |
| 44 | #if defined(BOOST_NO_STRINGSTREAM) |
| 45 | template <class CharT, class Traits> |
| 46 | using out_stream_t = std::ostream; |
| 47 | |
| 48 | template <class CharT, class Traits> |
| 49 | using stringbuffer_t = basic_unlockedbuf<std::strstreambuf, char>; |
| 50 | #elif defined(BOOST_NO_STD_LOCALE) |
| 51 | template <class CharT, class Traits> |
| 52 | using out_stream_t = std::ostream; |
| 53 | |
| 54 | template <class CharT, class Traits> |
| 55 | using stringbuffer_t = basic_unlockedbuf<std::stringbuf, char>; |
| 56 | |
| 57 | template <class CharT, class Traits> |
| 58 | using buffer_t = basic_unlockedbuf<std::streambuf, char>; |
| 59 | #else |
| 60 | template <class CharT, class Traits> |
| 61 | using out_stream_t = std::basic_ostream<CharT, Traits>; |
| 62 | |
| 63 | template <class CharT, class Traits> |
| 64 | using stringbuffer_t = basic_unlockedbuf<std::basic_stringbuf<CharT, Traits>, CharT>; |
| 65 | |
| 66 | template <class CharT, class Traits> |
| 67 | using buffer_t = basic_unlockedbuf<std::basic_streambuf<CharT, Traits>, CharT>; |
| 68 | #endif |
| 69 | |
| 70 | }}} // namespace boost::detail::lcast |
| 71 | |
| 72 | #endif // BOOST_LEXICAL_CAST_DETAIL_CONVERTER_LEXICAL_BASIC_UNLOCKEDBUF_HPP |
| 73 | |
| 74 | |