|
Boost Users : |
Subject: [Boost-users] Using boost string algorithm with BOOST_NO_STD_LOCALE
From: Allan Nielsen (a_at_[hidden])
Date: 2012-06-26 14:50:09
Hi,
I'm developing for an embedded environment where we do not have a
complete c++ standard library available, and one of the things missing
is std::locale.
But even without this feature, I would very much like to use the boost
string algorithms ( split, tokenize, etc ). The only problem is that
they depends on std::locale. I have been looking around in the source
code, trying to see how easy it would be to add the needed ifdef's to
make it work without std::locale. Most of the code looks straight
forward to modify, but I'm stuck on this function:
struct is_classifiedF :
public predicate_facade<is_classifiedF>
{
// Boost.ResultOf support
typedef bool result_type;
// Constructor from a locale
is_classifiedF(std::ctype_base::mask Type, std::locale
const & Loc = std::locale()) :
m_Type(Type), m_Locale(Loc) {}
// Operation
template<typename CharT>
bool operator()( CharT Ch ) const
{
return std::use_facet< std::ctype<CharT>
>(m_Locale).is( m_Type, Ch );
}
private:
std::ctype_base::mask m_Type;
std::locale m_Locale;
};
I know what the code does, I just do not know how it does it. This is
without a doubt because I know nothing about locale, facet, etc.
What I would like is another version of this struct which did not
depend on std::locale, but simply assumed that the local used is "C".
Something like this:
struct is_classifiedF :
public predicate_facade<is_classifiedF>
{
typedef bool result_type;
is_classifiedF(std::ctype_base::mask Type) :
m_Type(Type) {}
template<typename CharT>
bool operator()( CharT Ch ) const
{
// Write something here
}
private:
std::ctype_base::mask m_Type;
};
But as I do not understand the meaning/encoding of
std::ctype_base::mask m_Type I found it hard to write the missing
function body.
So I could use some pointers/hints on how to implement this.
Thanks
Allan W. Nielsen
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net