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


C++ Entries::find方法代码示例

本文整理汇总了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;
  }
}
开发者ID:BlueMustache,项目名称:Unvanquished,代码行数:33,代码来源:dictionary.cpp

示例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;
  } 
}
开发者ID:BlueMustache,项目名称:Unvanquished,代码行数:14,代码来源:dictionary.cpp

示例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;
		}
	}
}
开发者ID:dustinduse,项目名称:etlegacy,代码行数:46,代码来源:dictionary.cpp


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