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