本文整理汇总了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;
}
示例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));
}
}
示例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));
}
}
}
示例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;
}
示例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_);
}
示例6: translate
inline Char translate(Char ch, Traits const &tr, mpl::false_) // case-sensitive
{
return tr.translate(ch);
}
示例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);
}
示例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)));
}
示例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;
}