Ticket #6439: boost_po_compile_w_NO_STD_LOCALE_v2.patch

File boost_po_compile_w_NO_STD_LOCALE_v2.patch, 2.6 KB (added by leutloff@…, 11 years ago)

Reworked patch

  • boost/program_options/detail/convert.hpp

     
    88
    99#include <boost/program_options/config.hpp>
    1010
    11 #if !defined(BOOST_NO_STD_WSTRING)
     11#if !defined(BOOST_NO_STD_WSTRING) && !defined(BOOST_NO_STD_LOCALE)
    1212
    1313#include <boost/detail/workaround.hpp>
    1414
     
    9090#include <vector>
    9191#include <string>
    9292namespace boost{
     93
     94#ifndef BOOST_NO_STD_WSTRING
     95    BOOST_PROGRAM_OPTIONS_DECL std::string
     96    to_utf8(const std::wstring& s);
     97
     98    BOOST_PROGRAM_OPTIONS_DECL std::wstring
     99    from_utf8(const std::string& s);
     100
     101    BOOST_PROGRAM_OPTIONS_DECL std::string
     102    to_local_8_bit(const std::wstring& s);
     103
     104    BOOST_PROGRAM_OPTIONS_DECL std::wstring
     105    from_local_8_bit(const std::string& s);
     106#endif
     107
    93108   namespace program_options{
    94109        BOOST_PROGRAM_OPTIONS_DECL std::string to_internal(const std::string&);
     110#ifndef BOOST_NO_STD_WSTRING
     111        BOOST_PROGRAM_OPTIONS_DECL std::string to_internal(const std::wstring& s);
     112#endif
    95113
    96114        template<class T>
    97115        std::vector<std::string> to_internal(const std::vector<T>& s)
  • libs/program_options/src/convert.cpp

     
    8484
    8585namespace boost {
    8686
    87 #ifndef BOOST_NO_STD_WSTRING
     87#if !defined(BOOST_NO_STD_WSTRING) && !defined(BOOST_NO_STD_LOCALE)
    8888    BOOST_PROGRAM_OPTIONS_DECL std::wstring
    8989    from_8_bit(const std::string& s,
    9090               const std::codecvt<wchar_t, char, std::mbstate_t>& cvt)
     
    142142    }
    143143#endif
    144144
     145#ifdef BOOST_NO_STD_LOCALE
     146    // these methods are NOT converting character sets!
     147    BOOST_PROGRAM_OPTIONS_DECL std::string
     148    to_utf8(const std::wstring& s)
     149    {
     150        return std::string(s.begin(), s.end());
     151    }
     152
     153    BOOST_PROGRAM_OPTIONS_DECL std::wstring
     154    from_utf8(const std::string& s)
     155    {
     156        return std::wstring(s.begin(), s.end());
     157    }
     158
     159    BOOST_PROGRAM_OPTIONS_DECL std::string
     160    to_local_8_bit(const std::wstring& s)
     161    {
     162        return std::string(s.begin(), s.end());
     163    }
     164
     165    BOOST_PROGRAM_OPTIONS_DECL std::wstring
     166    from_local_8_bit(const std::string& s)
     167    {
     168        return std::wstring(s.begin(), s.end());
     169    }
     170#endif
     171
    145172    namespace program_options
    146173    {
    147174        BOOST_PROGRAM_OPTIONS_DECL std::string to_internal(const std::string& s)