本文整理汇总了C++中Entries::find方法的典型用法代码示例。如果您正苦于以下问题:C++ Entries::find方法的具体用法?C++ Entries::find怎么用?C++ Entries::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entries
的用法示例。
在下文中一共展示了Entries::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
std::string
Dictionary::translate_plural(const Entries& dict, const std::string& msgid, const std::string& msgid_plural, int count)
{
Entries::const_iterator i = dict.find(msgid);
if (i != dict.end())
{
const std::vector<std::string>& msgstrs = i->second;
unsigned int n = 0;
n = plural_forms.get_plural(count);
assert(/*n >= 0 &&*/ n < msgstrs.size());
if (!msgstrs[n].empty())
return msgstrs[n];
else
if (count == 1) // default to english rules
return msgid;
else
return msgid_plural;
}
else
{
log_info << "Couldn't translate: " << msgid << std::endl;
log_info << "Candidates: " << std::endl;
for (i = dict.begin(); i != dict.end(); ++i)
log_info << "'" << i->first << "'" << std::endl;
if (count == 1) // default to english rules
return msgid;
else
return msgid_plural;
}
}
示例2:
std::string
Dictionary::translate(const Entries& dict, const std::string& msgid)
{
Entries::const_iterator i = dict.find(msgid);
if (i != dict.end() && !i->second.empty())
{
return i->second[0];
}
else
{
log_info << "Couldn't translate: " << msgid << std::endl;
return msgid;
}
}
示例3: available
std::string
Dictionary::translate_plural(const Entries& dict, const std::string& msgid, const std::string& msgid_plural, int count) const
{
Entries::const_iterator it = dict.find(msgid);
if (it != dict.end())
{
unsigned int n = plural_forms.get_plural(count);
const std::vector<std::string>& msgstrs = it->second;
if (n >= msgstrs.size())
{
log_error << "Plural translation not available (and not set to empty): '" << msgid << "'" << std::endl;
log_error << "Missing plural form: " << n << std::endl;
return msgid;
}
if (!msgstrs[n].empty())
{
return msgstrs[n];
}
else
if (count == 1) // default to english rules
{
return msgid;
}
else
{
return msgid_plural;
}
}
else
{
log_info << "Couldn't translate: " << msgid << std::endl;
log_info << "Candidates: " << std::endl;
for (it = dict.begin(); it != dict.end(); ++it)
log_info << "'" << it->first << "'" << std::endl;
if (count == 1) // default to english rules
{
return msgid;
}
else
{
return msgid_plural;
}
}
}