cmake: supernova - missing include_directories() for Jack
[supercollider.git] / external_libraries / boost / libs / filesystem / v3 / src / windows_file_codecvt.cpp
blob85de59eee1cc68c7956f1a0531f59291570f6e30
1 // filesystem windows_file_codecvt.cpp -----------------------------------------//
3 // Copyright Beman Dawes 2009
5 // Distributed under the Boost Software License, Version 1.0.
6 // See http://www.boost.org/LICENSE_1_0.txt
8 // Library home page: http://www.boost.org/libs/filesystem
10 //--------------------------------------------------------------------------------------//
12 #include <boost/config.hpp>
13 #if !defined( BOOST_NO_STD_WSTRING )
14 // Boost.Filesystem V3 and later requires std::wstring support.
15 // During the transition to V3, libraries are compiled with both V2 and V3 sources.
16 // On old compilers that don't support V3 anyhow, we just skip everything so the compile
17 // will succeed and the library can be built.
19 // define BOOST_FILESYSTEM_SOURCE so that <boost/system/config.hpp> knows
20 // the library is being built (possibly exporting rather than importing code)
21 #define BOOST_FILESYSTEM_SOURCE
23 #ifndef BOOST_SYSTEM_NO_DEPRECATED
24 # define BOOST_SYSTEM_NO_DEPRECATED
25 #endif
27 #include <boost/filesystem/v3/config.hpp>
28 #include <cwchar> // for mbstate_t
30 #ifdef BOOST_WINDOWS_API
32 #include "windows_file_codecvt.hpp"
34 // Versions of MinGW prior to GCC 4.6 requires this
35 #ifndef WINVER
36 # define WINVER 0x0500
37 #endif
39 #include <windows.h>
41 std::codecvt_base::result windows_file_codecvt::do_in(
42 std::mbstate_t &,
43 const char* from, const char* from_end, const char*& from_next,
44 wchar_t* to, wchar_t* to_end, wchar_t*& to_next) const
46 UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
48 int count;
49 if ((count = ::MultiByteToWideChar(codepage, MB_PRECOMPOSED, from,
50 from_end - from, to, to_end - to)) == 0)
52 return error; // conversion failed
55 from_next = from_end;
56 to_next = to + count;
57 *to_next = L'\0';
58 return ok;
61 std::codecvt_base::result windows_file_codecvt::do_out(
62 std::mbstate_t &,
63 const wchar_t* from, const wchar_t* from_end, const wchar_t* & from_next,
64 char* to, char* to_end, char* & to_next) const
66 UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
68 int count;
69 if ((count = ::WideCharToMultiByte(codepage, WC_NO_BEST_FIT_CHARS, from,
70 from_end - from, to, to_end - to, 0, 0)) == 0)
72 return error; // conversion failed
75 from_next = from_end;
76 to_next = to + count;
77 *to_next = '\0';
78 return ok;
81 # endif // BOOST_WINDOWS_API
83 #endif // no wide character support