Skip to content

Commit 3daaaa3

Browse files
committed
build: use local Boost.Nowide if system Boost is too old
1 parent 620dc47 commit 3daaaa3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+9319
-0
lines changed

boost_1_74_0/LICENSE_1_0.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Boost Software License - Version 1.0 - August 17th, 2003
2+
3+
Permission is hereby granted, free of charge, to any person or organization
4+
obtaining a copy of the software and accompanying documentation covered by
5+
this license (the "Software") to use, reproduce, display, distribute,
6+
execute, and transmit the Software, and to prepare derivative works of the
7+
Software, and to permit third-parties to whom the Software is furnished to
8+
do so, all subject to the following:
9+
10+
The copyright notices in the Software and this entire statement, including
11+
the above license grant, this restriction and the following disclaimer,
12+
must be included in all copies of the Software, in whole or in part, and
13+
all derivative works of the Software, unless such copies or derivative
14+
works are solely in the form of machine-executable object code generated by
15+
a source language processor.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20+
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21+
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
DEALINGS IN THE SOFTWARE.

boost_1_74_0/boost/nowide/config.hpp

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
//
2+
// Copyright (c) 2012 Artyom Beilis (Tonkikh)
3+
// Copyright (c) 2019 - 2020 Alexander Grund
4+
//
5+
// Distributed under the Boost Software License, Version 1.0. (See
6+
// accompanying file LICENSE or copy at
7+
// http://www.boost.org/LICENSE_1_0.txt)
8+
//
9+
#ifndef BOOST_NOWIDE_CONFIG_HPP_INCLUDED
10+
#define BOOST_NOWIDE_CONFIG_HPP_INCLUDED
11+
12+
/// @file
13+
14+
#include <boost/config.hpp>
15+
#include <boost/nowide/replacement.hpp>
16+
#include <boost/version.hpp>
17+
18+
//! @cond Doxygen_Suppress
19+
20+
// MinGW32 requires a __MSVCRT_VERSION__ defined to make some functions available, e.g. _stat64
21+
// Hence define this here to target MSVC 7.0 which has the required functions and do it as early as possible
22+
// as including a system header might default this to 0x0600 which is to low
23+
#if defined(__MINGW32__) && !defined(__MSVCRT_VERSION__)
24+
#define __MSVCRT_VERSION__ 0x0700
25+
#endif
26+
27+
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_NOWIDE_DYN_LINK)
28+
#ifdef BOOST_NOWIDE_SOURCE
29+
#define BOOST_NOWIDE_DECL BOOST_SYMBOL_EXPORT
30+
#else
31+
#define BOOST_NOWIDE_DECL BOOST_SYMBOL_IMPORT
32+
#endif // BOOST_NOWIDE_SOURCE
33+
#else
34+
#define BOOST_NOWIDE_DECL
35+
#endif // BOOST_NOWIDE_DYN_LINK
36+
37+
//
38+
// Automatically link to the correct build variant where possible.
39+
//
40+
#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_NOWIDE_NO_LIB) && !defined(BOOST_NOWIDE_SOURCE)
41+
//
42+
// Set the name of our library, this will get undef'ed by auto_link.hpp
43+
// once it's done with it:
44+
//
45+
#define BOOST_LIB_NAME boost_nowide
46+
//
47+
// If we're importing code from a dll, then tell auto_link.hpp about it:
48+
//
49+
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_NOWIDE_DYN_LINK)
50+
#define BOOST_DYN_LINK
51+
#endif
52+
//
53+
// And include the header that does the work:
54+
//
55+
#include <boost/config/auto_link.hpp>
56+
#endif // auto-linking disabled
57+
58+
//! @endcond
59+
60+
/// @def BOOST_NOWIDE_USE_WCHAR_OVERLOADS
61+
/// @brief Whether to use the wchar_t* overloads in fstream/filebuf
62+
/// Enabled on Windows and Cygwin as the latter may use wchar_t in filesystem::path
63+
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
64+
#define BOOST_NOWIDE_USE_WCHAR_OVERLOADS 1
65+
#else
66+
#define BOOST_NOWIDE_USE_WCHAR_OVERLOADS 0
67+
#endif
68+
69+
/// @def BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT
70+
/// @brief Define to 1 to use internal class from filebuf.hpp
71+
///
72+
/// - On Non-Windows platforms: Define to 1 to use the same class from header <filebuf.hpp>
73+
/// that is used on Windows.
74+
/// - On Windows: No effect, always overwritten to 1
75+
///
76+
/// Affects boost::nowide::basic_filebuf,
77+
/// boost::nowide::basic_ofstream, boost::nowide::basic_ifstream, boost::nowide::basic_fstream
78+
#if defined(BOOST_WINDOWS) || BOOST_NOWIDE_USE_WCHAR_OVERLOADS
79+
#ifdef BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT
80+
#undef BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT
81+
#endif
82+
#define BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT 1
83+
#elif !defined(BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT)
84+
#define BOOST_NOWIDE_USE_FILEBUF_REPLACEMENT 0
85+
#endif
86+
87+
//! @cond Doxygen_Suppress
88+
89+
#if BOOST_VERSION < 106500 && defined(BOOST_GCC) && __GNUC__ >= 7
90+
#define BOOST_NOWIDE_FALLTHROUGH __attribute__((fallthrough))
91+
#else
92+
#define BOOST_NOWIDE_FALLTHROUGH BOOST_FALLTHROUGH
93+
#endif
94+
95+
//! @endcond
96+
97+
namespace boost {
98+
///
99+
/// \brief This namespace includes implementations of the standard library functions and
100+
/// classes such that they accept UTF-8 strings on Windows.
101+
/// On other platforms (i.e. not on Windows) those functions and classes are just aliases
102+
/// of the corresponding ones from the std namespace or behave like them.
103+
///
104+
namespace nowide {}
105+
} // namespace boost
106+
107+
#endif // boost/nowide/config.hpp
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// Copyright (c) 2018 Artyom Beilis (Tonkikh)
3+
//
4+
// Distributed under the Boost Software License, Version 1.0. (See
5+
// accompanying file LICENSE or copy at
6+
// http://www.boost.org/LICENSE_1_0.txt)
7+
//
8+
#ifndef BOOST_NOWIDE_REPLACEMENT_HPP_INCLUDED
9+
#define BOOST_NOWIDE_REPLACEMENT_HPP_INCLUDED
10+
11+
/// @file
12+
13+
/// \def BOOST_NOWIDE_REPLACEMENT_CHARACTER
14+
/// Unicode character to be used to replace invalid UTF-8 sequences
15+
#ifndef BOOST_NOWIDE_REPLACEMENT_CHARACTER
16+
#define BOOST_NOWIDE_REPLACEMENT_CHARACTER 0xFFFD
17+
#endif
18+
19+
#endif // boost/nowide/replacement.hpp
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
//
2+
// Copyright (c) 2012 Artyom Beilis (Tonkikh)
3+
//
4+
// Distributed under the Boost Software License, Version 1.0. (See
5+
// accompanying file LICENSE or copy at
6+
// http://www.boost.org/LICENSE_1_0.txt)
7+
//
8+
#ifndef BOOST_NOWIDE_UTF_CONVERT_HPP_INCLUDED
9+
#define BOOST_NOWIDE_UTF_CONVERT_HPP_INCLUDED
10+
11+
#include <boost/nowide/replacement.hpp>
12+
#include <boost/nowide/utf/utf.hpp>
13+
#include <iterator>
14+
#include <string>
15+
16+
namespace boost {
17+
namespace nowide {
18+
namespace utf {
19+
///
20+
/// Convert a buffer of UTF sequences in the range [source_begin, source_end)
21+
/// from \tparam CharIn to \tparam CharOut to the output \a buffer of size \a buffer_size.
22+
///
23+
/// \return original buffer containing the NULL terminated string or NULL
24+
///
25+
/// If there is not enough room in the buffer NULL is returned, and the content of the buffer is undefined.
26+
/// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER
27+
///
28+
template<typename CharOut, typename CharIn>
29+
CharOut*
30+
convert_buffer(CharOut* buffer, size_t buffer_size, const CharIn* source_begin, const CharIn* source_end)
31+
{
32+
CharOut* rv = buffer;
33+
if(buffer_size == 0)
34+
return 0;
35+
buffer_size--;
36+
while(source_begin != source_end)
37+
{
38+
code_point c = utf_traits<CharIn>::template decode(source_begin, source_end);
39+
if(c == illegal || c == incomplete)
40+
{
41+
c = BOOST_NOWIDE_REPLACEMENT_CHARACTER;
42+
}
43+
size_t width = utf_traits<CharOut>::width(c);
44+
if(buffer_size < width)
45+
{
46+
rv = NULL;
47+
break;
48+
}
49+
buffer = utf_traits<CharOut>::template encode(c, buffer);
50+
buffer_size -= width;
51+
}
52+
*buffer++ = 0;
53+
return rv;
54+
}
55+
56+
///
57+
/// Convert the UTF sequences in range [begin, end) from \tparam CharIn to \tparam CharOut
58+
/// and return it as a string
59+
///
60+
/// Any illegal sequences are replaced with the replacement character, see #BOOST_NOWIDE_REPLACEMENT_CHARACTER
61+
///
62+
template<typename CharOut, typename CharIn>
63+
std::basic_string<CharOut> convert_string(const CharIn* begin, const CharIn* end)
64+
{
65+
std::basic_string<CharOut> result;
66+
result.reserve(end - begin);
67+
typedef std::back_insert_iterator<std::basic_string<CharOut> > inserter_type;
68+
inserter_type inserter(result);
69+
code_point c;
70+
while(begin != end)
71+
{
72+
c = utf_traits<CharIn>::template decode(begin, end);
73+
if(c == illegal || c == incomplete)
74+
{
75+
c = BOOST_NOWIDE_REPLACEMENT_CHARACTER;
76+
}
77+
utf_traits<CharOut>::template encode(c, inserter);
78+
}
79+
return result;
80+
}
81+
82+
/// Return the length of the given string in code units.
83+
/// That is the number of elements of type Char until the first NULL character
84+
/// Equivalent to `std::strlen(s)` but can handle wide-strings
85+
template<typename Char>
86+
size_t strlen(const Char* s)
87+
{
88+
const Char* end = s;
89+
while(*end)
90+
end++;
91+
return end - s;
92+
}
93+
94+
} // namespace utf
95+
} // namespace nowide
96+
} // namespace boost
97+
98+
#endif

0 commit comments

Comments
 (0)