annotate DEPENDENCIES/generic/include/boost/log/detail/code_conversion.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
rev   line source
Chris@16 1 /*
Chris@16 2 * Copyright Andrey Semashev 2007 - 2013.
Chris@16 3 * Distributed under the Boost Software License, Version 1.0.
Chris@16 4 * (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 5 * http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 */
Chris@16 7 /*!
Chris@16 8 * \file code_conversion.hpp
Chris@16 9 * \author Andrey Semashev
Chris@16 10 * \date 08.11.2008
Chris@16 11 *
Chris@16 12 * \brief This header is the Boost.Log library implementation, see the library documentation
Chris@16 13 * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
Chris@16 14 */
Chris@16 15
Chris@16 16 #ifndef BOOST_LOG_DETAIL_CODE_CONVERSION_HPP_INCLUDED_
Chris@16 17 #define BOOST_LOG_DETAIL_CODE_CONVERSION_HPP_INCLUDED_
Chris@16 18
Chris@16 19 #include <locale>
Chris@16 20 #include <string>
Chris@16 21 #include <boost/log/detail/config.hpp>
Chris@16 22 #include <boost/log/detail/header.hpp>
Chris@16 23
Chris@16 24 #ifdef BOOST_HAS_PRAGMA_ONCE
Chris@16 25 #pragma once
Chris@16 26 #endif
Chris@16 27
Chris@16 28 namespace boost {
Chris@16 29
Chris@16 30 BOOST_LOG_OPEN_NAMESPACE
Chris@16 31
Chris@16 32 namespace aux {
Chris@16 33
Chris@16 34 //! The function converts one string to the character type of another
Chris@16 35 BOOST_LOG_API void code_convert(const wchar_t* str1, std::size_t len, std::string& str2, std::locale const& loc = std::locale());
Chris@16 36 //! The function converts one string to the character type of another
Chris@16 37 BOOST_LOG_API void code_convert(const char* str1, std::size_t len, std::wstring& str2, std::locale const& loc = std::locale());
Chris@16 38 #if !defined(BOOST_NO_CXX11_CHAR16_T)
Chris@16 39 //! The function converts one string to the character type of another
Chris@16 40 BOOST_LOG_API void code_convert(const char16_t* str1, std::size_t len, std::string& str2, std::locale const& loc = std::locale());
Chris@16 41 //! The function converts one string to the character type of another
Chris@16 42 BOOST_LOG_API void code_convert(const char* str1, std::size_t len, std::u16string& str2, std::locale const& loc = std::locale());
Chris@16 43 #endif
Chris@16 44 #if !defined(BOOST_NO_CXX11_CHAR32_T)
Chris@16 45 //! The function converts one string to the character type of another
Chris@16 46 BOOST_LOG_API void code_convert(const char32_t* str1, std::size_t len, std::string& str2, std::locale const& loc = std::locale());
Chris@16 47 //! The function converts one string to the character type of another
Chris@16 48 BOOST_LOG_API void code_convert(const char* str1, std::size_t len, std::u32string& str2, std::locale const& loc = std::locale());
Chris@16 49 #endif
Chris@16 50
Chris@16 51 //! The function converts one string to the character type of another
Chris@16 52 template< typename CharT, typename SourceTraitsT, typename SourceAllocatorT, typename TargetTraitsT, typename TargetAllocatorT >
Chris@16 53 inline void code_convert(std::basic_string< CharT, SourceTraitsT, SourceAllocatorT > const& str1, std::basic_string< CharT, TargetTraitsT, TargetAllocatorT >& str2, std::locale const& = std::locale())
Chris@16 54 {
Chris@16 55 str2.append(str1.c_str(), str1.size());
Chris@16 56 }
Chris@16 57 //! The function converts one string to the character type of another
Chris@16 58 template< typename CharT, typename TargetTraitsT, typename TargetAllocatorT >
Chris@16 59 inline void code_convert(const CharT* str1, std::size_t len, std::basic_string< CharT, TargetTraitsT, TargetAllocatorT >& str2, std::locale const& = std::locale())
Chris@16 60 {
Chris@16 61 str2.append(str1, len);
Chris@16 62 }
Chris@16 63
Chris@16 64 //! The function converts one string to the character type of another
Chris@16 65 template< typename SourceCharT, typename SourceTraitsT, typename SourceAllocatorT, typename TargetCharT, typename TargetTraitsT, typename TargetAllocatorT >
Chris@16 66 inline void code_convert(std::basic_string< SourceCharT, SourceTraitsT, SourceAllocatorT > const& str1, std::basic_string< TargetCharT, TargetTraitsT, TargetAllocatorT >& str2, std::locale const& loc = std::locale())
Chris@16 67 {
Chris@16 68 aux::code_convert(str1.c_str(), str1.size(), str2, loc);
Chris@16 69 }
Chris@16 70
Chris@16 71 //! The function converts the passed string to the narrow-character encoding
Chris@16 72 inline std::string const& to_narrow(std::string const& str)
Chris@16 73 {
Chris@16 74 return str;
Chris@16 75 }
Chris@16 76
Chris@16 77 //! The function converts the passed string to the narrow-character encoding
Chris@16 78 inline std::string const& to_narrow(std::string const& str, std::locale const&)
Chris@16 79 {
Chris@16 80 return str;
Chris@16 81 }
Chris@16 82
Chris@16 83 //! The function converts the passed string to the narrow-character encoding
Chris@16 84 inline std::string to_narrow(std::wstring const& str, std::locale const& loc = std::locale())
Chris@16 85 {
Chris@16 86 std::string res;
Chris@16 87 aux::code_convert(str, res, loc);
Chris@16 88 return res;
Chris@16 89 }
Chris@16 90
Chris@16 91 //! The function converts the passed string to the wide-character encoding
Chris@16 92 inline std::wstring const& to_wide(std::wstring const& str)
Chris@16 93 {
Chris@16 94 return str;
Chris@16 95 }
Chris@16 96
Chris@16 97 //! The function converts the passed string to the wide-character encoding
Chris@16 98 inline std::wstring const& to_wide(std::wstring const& str, std::locale const&)
Chris@16 99 {
Chris@16 100 return str;
Chris@16 101 }
Chris@16 102
Chris@16 103 //! The function converts the passed string to the wide-character encoding
Chris@16 104 inline std::wstring to_wide(std::string const& str, std::locale const& loc = std::locale())
Chris@16 105 {
Chris@16 106 std::wstring res;
Chris@16 107 aux::code_convert(str, res, loc);
Chris@16 108 return res;
Chris@16 109 }
Chris@16 110
Chris@16 111 } // namespace aux
Chris@16 112
Chris@16 113 BOOST_LOG_CLOSE_NAMESPACE // namespace log
Chris@16 114
Chris@16 115 } // namespace boost
Chris@16 116
Chris@16 117 #include <boost/log/detail/footer.hpp>
Chris@16 118
Chris@16 119 #endif // BOOST_LOG_DETAIL_CODE_CONVERSION_HPP_INCLUDED_