本文整理汇总了C++中pal::string_t::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ string_t::erase方法的具体用法?C++ string_t::erase怎么用?C++ string_t::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pal::string_t
的用法示例。
在下文中一共展示了string_t::erase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trim_quotes
pal::string_t trim_quotes(pal::string_t stringToCleanup)
{
pal::char_t quote_array[2] = {'\"', '\''};
for(int index = 0; index < sizeof(quote_array)/sizeof(quote_array[0]); index++)
{
size_t pos = stringToCleanup.find(quote_array[index]);
while(pos != std::string::npos)
{
stringToCleanup = stringToCleanup.erase(pos, 1);
pos = stringToCleanup.find(quote_array[index]);
}
}
return stringToCleanup;
}
示例2: normalize_linux_rid
// For some distros, we don't want to use the full version from VERSION_ID. One example is
// Red Hat Enterprise Linux, which includes a minor version in their VERSION_ID but minor
// versions are backwards compatable.
//
// In this case, we'll normalized RIDs like 'rhel.7.2' and 'rhel.7.3' to a generic
// 'rhel.7'. This brings RHEL in line with other distros like CentOS or Debian which
// don't put minor version numbers in their VERSION_ID fields because all minor versions
// are backwards compatible.
static
pal::string_t normalize_linux_rid(pal::string_t rid)
{
pal::string_t rhelPrefix(_X("rhel."));
if (rid.compare(0, rhelPrefix.length(), rhelPrefix) == 0)
{
size_t minorVersionSeparatorIndex = rid.find(_X("."), rhelPrefix.length());
if (minorVersionSeparatorIndex != std::string::npos)
{
rid.erase(minorVersionSeparatorIndex, rid.length() - minorVersionSeparatorIndex);
}
}
return rid;
}