mirror of
https://github.com/boostorg/program_options.git
synced 2026-01-19 16:32:15 +00:00
Patch from John Maddock for platforms without wchar_t support, specifically
cygwin. [SVN r23576]
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
|
||||
#include <boost/program_options/config.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_STD_WSTRING)
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <string>
|
||||
@@ -84,4 +86,22 @@ namespace boost {
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
#include <vector>
|
||||
#include <string>
|
||||
namespace boost{
|
||||
namespace program_options{
|
||||
BOOST_PROGRAM_OPTIONS_DECL std::string to_internal(const std::string&);
|
||||
|
||||
template<class T>
|
||||
std::vector<std::string> to_internal(const std::vector<T>& s)
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
for (unsigned i = 0; i < s.size(); ++i)
|
||||
result.push_back(to_internal(s[i]));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -90,11 +90,12 @@ namespace boost { namespace program_options {
|
||||
bool*,
|
||||
int);
|
||||
|
||||
#if !defined(BOOST_NO_STD_WSTRING)
|
||||
BOOST_PROGRAM_OPTIONS_DECL void validate(boost::any& v,
|
||||
const std::vector<std::wstring>& xs,
|
||||
bool*,
|
||||
int);
|
||||
|
||||
#endif
|
||||
// For some reason, this declaration, which is require by the standard,
|
||||
// cause gcc 3.2 to not generate code to specialization defined in
|
||||
// value_semantic.cpp
|
||||
@@ -107,10 +108,12 @@ namespace boost { namespace program_options {
|
||||
std::string*,
|
||||
int);
|
||||
|
||||
#if !defined(BOOST_NO_STD_WSTRING)
|
||||
BOOST_PROGRAM_OPTIONS_DECL void validate(boost::any& v,
|
||||
const std::vector<std::wstring>& xs,
|
||||
std::string*,
|
||||
int);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** Validates sequences. Allows multiple values per option occurence
|
||||
|
||||
@@ -100,11 +100,12 @@ namespace boost { namespace program_options {
|
||||
const std::vector<std::string>& new_tokens,
|
||||
bool utf8) const;
|
||||
protected: // interface for derived classes.
|
||||
#if !defined(BOOST_NO_STD_WSTRING)
|
||||
virtual void xparse(boost::any& value_store,
|
||||
const std::vector<std::wstring>& new_tokens)
|
||||
const = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
/** Class which specify handling of value for which user did not specified
|
||||
anything. */
|
||||
class BOOST_PROGRAM_OPTIONS_DECL
|
||||
|
||||
@@ -123,6 +123,7 @@ namespace boost { namespace program_options {
|
||||
// since wstring can't be constructed/compared with char*. We'd need to
|
||||
// create auxilliary 'widen' routine to convert from char* into
|
||||
// needed string type, and that's more work.
|
||||
#if !defined(BOOST_NO_STD_WSTRING)
|
||||
BOOST_PROGRAM_OPTIONS_DECL
|
||||
void validate(any& v, const vector<wstring>& xs, bool*, int)
|
||||
{
|
||||
@@ -139,7 +140,7 @@ namespace boost { namespace program_options {
|
||||
else
|
||||
throw validation_error("invalid bool value");
|
||||
}
|
||||
|
||||
#endif
|
||||
BOOST_PROGRAM_OPTIONS_DECL
|
||||
void validate(any& v, const vector<string>& xs, std::string*, int)
|
||||
{
|
||||
@@ -152,6 +153,7 @@ namespace boost { namespace program_options {
|
||||
v = any(s);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_STD_WSTRING)
|
||||
BOOST_PROGRAM_OPTIONS_DECL
|
||||
void validate(any& v, const vector<wstring>& xs, std::string*, int)
|
||||
{
|
||||
@@ -163,7 +165,7 @@ namespace boost { namespace program_options {
|
||||
else
|
||||
v = any(s);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
namespace validators {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user