本文整理匯總了C++中string_t::at方法的典型用法代碼示例。如果您正苦於以下問題:C++ string_t::at方法的具體用法?C++ string_t::at怎麽用?C++ string_t::at使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類string_t
的用法示例。
在下文中一共展示了string_t::at方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: IsResolution
bool Parser::IsResolution(const string_t& str)
{
// Using a regex such as "\\d{3,4}(p|(x\\d{3,4}))$" would be more elegant,
// but it's much slower (e.g. 2.4ms -> 24.9ms).
// *###x###*
if (str.size() >= 3 + 1 + 3)
{
size_t pos = str.find_first_of(L"xX\u00D7"); // multiplication sign
if (pos != str.npos)
{
for (size_t i = 0; i < str.size(); i++)
if (i != pos && !IsNumericChar(str.at(i)))
return false;
return true;
}
// *###p
}
else if (str.size() >= 3 + 1)
{
if (str.back() == L'p' || str.back() == L'P')
{
for (size_t i = 0; i < str.size() - 1; i++)
if (!IsNumericChar(str.at(i)))
return false;
return true;
}
}
return false;
}
示例2: seed_impl
void seed_impl (string_t keyword, value_t value, size_t depth, Entry & entry)
{
int ch = tolower (keyword.at (depth), mLocale);
typename Entry::childen_t::iterator j = entry.mChildren.find (ch);
if (j == entry.mChildren.end ())
{
entry.mChildren [ch].mValue = /*std::move*/ (value);
entry.mChildren [ch].mKeyword = /*std::move*/ (keyword);
}
else
{
if (j->second.mKeyword.size () > 0)
{
if (keyword == j->second.mKeyword)
throw std::runtime_error ("duplicate keyword inserted");
value_t pushValue = /*std::move*/ (j->second.mValue);
string_t pushKeyword = /*std::move*/ (j->second.mKeyword);
if (depth >= pushKeyword.size ())
throw std::runtime_error ("unexpected");
if (depth+1 < pushKeyword.size())
{
seed_impl (/*std::move*/ (pushKeyword), /*std::move*/ (pushValue), depth+1, j->second);
j->second.mKeyword.clear ();
}
}
if (depth+1 == keyword.size())
j->second.mKeyword = value;
else // depth+1 < keyword.size()
seed_impl (/*std::move*/ (keyword), /*std::move*/ (value), depth+1, j->second);
}
}