当前位置: 首页>>代码示例>>C++>>正文


C++ Traits::translate方法代码示例

本文整理汇总了C++中Traits::translate方法的典型用法代码示例。如果您正苦于以下问题:C++ Traits::translate方法的具体用法?C++ Traits::translate怎么用?C++ Traits::translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Traits的用法示例。


在下文中一共展示了Traits::translate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: find_

    // case-sensitive Boyer-Moore search
    BidiIter find_(BidiIter begin, BidiIter end, Traits const &traits) const
    {
        typedef typename boost::iterator_difference<BidiIter>::type diff_type;
        diff_type const endpos = std::distance(begin, end);
        diff_type offset = static_cast<diff_type>(this->length_);

        for(diff_type curpos = offset; curpos < endpos; curpos += offset)
        {
            std::advance(begin, offset);

            char_type const *pat_tmp = this->last_;
            BidiIter str_tmp = begin;

            for(; traits.translate(*str_tmp) == *pat_tmp; --pat_tmp, --str_tmp)
            {
                if(pat_tmp == this->begin_)
                {
                    return str_tmp;
                }
            }

            offset = this->offsets_[traits.hash(traits.translate(*begin))];
        }

        return end;
    }
开发者ID:rogerclark,项目名称:grumble,代码行数:27,代码来源:boyer_moore.hpp

示例2: set_char

 void set_char(char_type ch, bool icase, Traits const &traits)
 {
     if(this->test_icase_(icase))
     {
         ch = icase ? traits.translate_nocase(ch) : traits.translate(ch);
         this->bset_.set(traits.hash(ch));
     }
 }
开发者ID:venkatarajasekhar,项目名称:viper,代码行数:8,代码来源:hash_peek_bitset.hpp

示例3: set_range

 void set_range(char_type from, char_type to, bool no, bool icase, Traits const &traits)
 {
     int_type ifrom = std::char_traits<char_type>::to_int_type(from);
     int_type ito = std::char_traits<char_type>::to_int_type(to);
     BOOST_ASSERT(ifrom <= ito);
     // bound the computational complexity. BUGBUG could set the inverse range
     if(no || 256 < (ito - ifrom))
     {
         this->set_all();
     }
     else if(this->test_icase_(icase))
     {
         for(int_type i = ifrom; i <= ito; ++i)
         {
             char_type ch = std::char_traits<char_type>::to_char_type(i);
             ch = icase ? traits.translate_nocase(ch) : traits.translate(ch);
             this->bset_.set(traits.hash(ch));
         }
     }
 }
开发者ID:venkatarajasekhar,项目名称:viper,代码行数:20,代码来源:hash_peek_bitset.hpp

示例4: expected

 std::string expected(void) const
 {
     std::string result;
     auto i = this->subparsers.begin(), e = this->subparsers.end();
     while(i != e)
     {
         result.append((*i)->expected());
         ++i;
         if(i != e)
         {
             result.append(" ");
             result.append(traits.translate(
                               shared_data,
                               "OR"
                           ));
             result.append(" ");
         }
     }
     return result;
 }
开发者ID:teotwaki,项目名称:firestarter,代码行数:20,代码来源:manager.hpp

示例5: is_word

 bool is_word(Traits const &tr, char_type ch) const
 {
     detail::ignore_unused(tr);
     return tr.isctype(tr.translate(ch), this->word_);
 }
开发者ID:03050903,项目名称:turbulenz_engine,代码行数:5,代码来源:assert_word_matcher.hpp

示例6: translate

 inline Char translate(Char ch, Traits const &tr, mpl::false_) // case-sensitive
 {
     return tr.translate(ch);
 }
开发者ID:03050903,项目名称:turbulenz_engine,代码行数:4,代码来源:traits_utils.hpp

示例7: in_set

 bool in_set(Traits const &traits, char_type ch) const
 {
     char_type const *begin = &this->set_[0], *end = begin + Size;
     ch = this->icase_ ? traits.translate_nocase(ch) : traits.translate(ch);
     return end != std::find(begin, end, ch);
 }
开发者ID:rogerclark,项目名称:grumble,代码行数:6,代码来源:set_matcher.hpp

示例8: test

 bool test(char_type ch, Traits const &traits, mpl::false_) const
 {
     BOOST_ASSERT(!this->icase_);
     return this->bset_.test(traits.hash(traits.translate(ch)));
 }
开发者ID:venkatarajasekhar,项目名称:viper,代码行数:5,代码来源:hash_peek_bitset.hpp

示例9: index

 int index(void) const
 {
     // if we have exactly one constructor index
     if(match_indices.size() == 1)
     {
         // then return it
         return match_indices.front();
     }
     // if we have nothing
     if(match_indices.empty())
     {
         throw std::runtime_error(
             traits.translate(
                 shared_data,
                 "No matching constructor for input"
             ) + " '" + input_string + "'. " +
             traits.translate(
                 shared_data,
                 "Expecting:"
             ) + " " + this->expected() + "."
         );
     }
     // if we have multiple matching constructors
     if(match_indices.size() > 1)
     {
         std::string msg;
         msg.append(traits.translate(
                        shared_data,
                        "Ambiguous input."
                    ));
         msg.append(" ");
         msg.append(traits.translate(
                        shared_data,
                        "Candidates are:"
                    ));
         msg.append(" ");
         auto i = match_indices.begin(), e = match_indices.end();
         while(i != e)
         {
             msg.append(this->subparsers[*i]->expected());
             ++i;
             if(i != e)
             {
                 msg.append(" ");
                 msg.append(traits.translate(
                                shared_data,
                                "OR"
                            ));
                 msg.append(" ");
             }
         }
         msg.append(". ");
         msg.append(traits.translate(
                        shared_data,
                        "You may need to add explicit casts "
                        "to disambiguate."
                    ));
         throw std::runtime_error(msg);
     }
     assert(!"Never should get here!");
     return 0;
 }
开发者ID:teotwaki,项目名称:firestarter,代码行数:62,代码来源:manager.hpp


注:本文中的Traits::translate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。