本文整理汇总了C++中std::wstring::rend方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::rend方法的具体用法?C++ wstring::rend怎么用?C++ wstring::rend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::wstring
的用法示例。
在下文中一共展示了wstring::rend方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//theSingleNode is only valid if numNodes is 1.
void
ConvertNodesString(const std::wstring & includedNodes, boost::uint64_t & converted, int & numNodes, int & theSingleNode)
{
if (includedNodes.size() != static_cast<size_t>(NUM_NODES))
{
throw Dob::Typesystem::ConfigurationErrorException
(L"Length of IncludedNodes string must be 64",__WFILE__,__LINE__);
}
converted = 0;
numNodes = 0;
for (std::wstring::const_reverse_iterator it = includedNodes.rbegin(); it!= includedNodes.rend();++it)
{
if (*it == '-')
{
converted = converted << 1; //add a 0 to the end
}
else if (*it == '+')
{
converted = converted << 1 | 0x1; //add a 1 to the end
theSingleNode = static_cast<int>(std::distance(it,includedNodes.rend()) - 1);
++numNodes;
}
else
{
throw Dob::Typesystem::ConfigurationErrorException(L"Illegal character in IncludedNodes string (can only be + or -)",__WFILE__,__LINE__);
}
}
}
示例2: RvFindRegex
vFindRegex::vFindRegex(std::wstring patternInput, bool recursive)
{
if (recursive)
state = new RvFindRegex();
else
state = new NRvFindRegex();
if (globalOptions::expandRegex && std::find(patternInput.begin(), patternInput.end(), L'\\') != patternInput.end())
{
DWORD len = GetLongPathName(patternInput.c_str(), NULL, NULL);
wchar_t *tempExpandedPath = new wchar_t[len];
GetLongPathName(patternInput.c_str(), tempExpandedPath, len);
patternInput = tempExpandedPath;
delete [] tempExpandedPath;
}
std::wstring::const_iterator middle(std::find(patternInput.rbegin(), patternInput.rend(), L'\\').base());
if (middle == patternInput.begin())
{
regex = patternInput;
} else
{
regex = std::wstring(middle, patternInput.end());
pathRoot = std::wstring(patternInput.begin(), middle);
}
if (!fpattern_isvalid(regex.c_str()))
throw L"There is an error in the syntax of your VFIND regular expression.";
stripEscapes(pathRoot);
}
示例3: wideShorten
std::wstring wideShorten(const std::wstring &ws, size_t max_length)
{
std::wstring result;
if (wideLength(ws) > max_length)
{
const size_t half_max = max_length/2 - 1;
size_t len = 0;
// get beginning of string
for (auto it = ws.begin(); it != ws.end(); ++it)
{
len += wcwidth(*it);
if (len > half_max)
break;
result += *it;
}
len = 0;
std::wstring end;
// get end of string in reverse order
for (auto it = ws.rbegin(); it != ws.rend(); ++it)
{
len += wcwidth(*it);
if (len > half_max)
break;
end += *it;
}
// apply end of string to its beginning
result += L"..";
result.append(end.rbegin(), end.rend());
}
else
result = ws;
return result;
}
示例4: trim_string
/**
* Trims the front/back of the string of whitespace
*/
static void trim_string(std::wstring& str)
{
str.erase(str.begin(), std::find_if(str.begin(), str.end(), [](int ch) {
return !std::isspace(ch);
}));
str.erase(std::find_if(str.rbegin(), str.rend(), [](int ch) {
return !std::isspace(ch);
}).base(), str.end());
}
示例5: wstring
inline std::wstring trim(const std::wstring& str)
{
std::wstring::const_iterator begin = std::find_if(str.begin(), str.end(), std::not1(std::ptr_fun(_istspace)));
if (begin == str.end())
begin = str.begin();
std::wstring::const_reverse_iterator end = std::find_if(str.rbegin(), str.rend(), std::not1(std::ptr_fun(_istspace)));
return std::wstring(begin, end.base());
}
示例6:
const std::wstring tolower_and_del_delims(const std::wstring& str, const bool reverse)
{
std::wstring ret_str;
if(reverse) {
remove_copy_if(str.rbegin(), str.rend(), std::back_inserter(ret_str), is_delim);
} else {
remove_copy_if(str.begin(), str.end(), std::back_inserter(ret_str), is_delim);
}
std::transform(ret_str.begin(), ret_str.end(), ret_str.begin(), std::towlower);
return ret_str;
}
示例7: Highlight
void SyntaxHighlighter::Highlight(const std::wstring& s, SyntaxHighlighter::CallbackType highlight)
{
if (s.empty())
return;
const int length = int(s.length());
for (auto i = s.begin(); i != s.end(); ++i)
{
if (!u_isblank(*i))
{
int wlen = int(i - s.begin());
if (wlen)
highlight(0, wlen, LeadingWhitespace);
break;
}
}
for (auto i = s.rbegin(); i != s.rend(); ++i)
{
if (!u_isblank(*i))
{
int wlen = int(i - s.rbegin());
if (wlen)
highlight(length - wlen, length, LeadingWhitespace);
break;
}
}
for (auto i = s.begin(); i != s.end(); ++i)
{
if (*i == '\\')
{
int pos = int(i - s.begin());
if (++i == s.end())
break;
// TODO: highlight full syntax, incl. octals: http://en.cppreference.com/w/cpp/language/escape
switch (*i)
{
case '0':
case 'n':
case 'r':
case 't':
case '"':
case '\\':
highlight(pos, pos + 2, Escape);
break;
default:
break;
}
}
}
}
示例8: right_trim_string
/**
* Trims the specified character from the back of the string
*/
static void right_trim_string(std::wstring& str, wchar_t c)
{
str.erase(std::find_if(str.rbegin(), str.rend(), [c](const wchar_t& ch) {
return ch != c;
}).base(), str.end());
}
示例9: TrimEnd
std::wstring TrimEnd(std::wstring s)
{
s.erase(std::find_if(s.rbegin(), s.rend(),
std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
return s;
}