Esempio n. 1
0
 line_start_finder(Traits const &traits)
 {
     char_class_type newline = lookup_classname(traits, "newline");
     for(int j = 0; j < 256; ++j)
     {
         this->bits_[j] = traits.isctype(static_cast<char_type>(static_cast<unsigned char>(j)), newline);
     }
 }
Esempio n. 2
0
inline void merge_charset
(
    basic_chset<Char> &basic
  , compound_charset<Traits> const &compound
  , Traits const &tr
)
{
    detail::ignore_unused(tr);
    if(0 != compound.posix_yes())
    {
        typename Traits::char_class_type mask = compound.posix_yes();
        for(int i = 0; i <= static_cast<int>(UCHAR_MAX); ++i)
        {
            if(tr.isctype((Char)i, mask))
            {
                basic.set((Char)i);
            }
        }
    }

    if(!compound.posix_no().empty())
    {
        for(std::size_t j = 0; j < compound.posix_no().size(); ++j)
        {
            typename Traits::char_class_type mask = compound.posix_no()[j];
            for(int i = 0; i <= static_cast<int>(UCHAR_MAX); ++i)
            {
                if(!tr.isctype((Char)i, mask))
                {
                    basic.set((Char)i);
                }
            }
        }
    }

    if(compound.is_inverted())
    {
        basic.inverse();
    }
}
 void set_class(typename Traits::char_class_type char_class, bool no, Traits const &traits)
 {
     if(1 != sizeof(char_type))
     {
         // wide character set, no efficient way of filling in the bitset, so set them all to 1
         this->set_all();
     }
     else
     {
         for(std::size_t i = 0; i <= UCHAR_MAX; ++i)
         {
             char_type ch = std::char_traits<char_type>::to_char_type(static_cast<int_type>(i));
             if(no != traits.isctype(ch, char_class))
             {
                 this->bset_.set(i);
             }
         }
     }
 }
 bool is_word(Traits const &tr, char_type ch) const
 {
     detail::ignore_unused(tr);
     return tr.isctype(tr.translate(ch), this->word_);
 }
Esempio n. 5
0
 ///////////////////////////////////////////////////////////////////////////////
 // test_posix
 bool test_posix(char_type ch, Traits const &tr) const
 {
     not_posix_pred const pred = {ch, &tr};
     return tr.isctype(ch, this->posix_yes_)
            || any(this->posix_no_.begin(), this->posix_no_.end(), pred);
 }