Patch from John Maddock for platforms without wchar_t support, specifically

cygwin.


[SVN r23576]
This commit is contained in:
Vladimir Prus
2004-07-15 11:40:26 +00:00
parent 9133a2e903
commit 6f49b5b999
4 changed files with 30 additions and 4 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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 {