本文整理汇总了C++中std::basic_string::end方法的典型用法代码示例。如果您正苦于以下问题:C++ basic_string::end方法的具体用法?C++ basic_string::end怎么用?C++ basic_string::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::basic_string
的用法示例。
在下文中一共展示了basic_string::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print_if_failed
void print_if_failed(char const* func, bool result
, std::basic_string<Char> const& generated, T const& expected)
{
if (!result)
std::cerr << "in " << func << ": result is false" << std::endl;
else if (generated != expected)
std::cerr << "in " << func << ": generated \""
<< std::string(generated.begin(), generated.end())
<< "\"" << std::endl;
}
示例2: i
std::basic_string<charT> regex_replace(const std::basic_string<charT>& s,
const basic_regex<charT, traits>& e,
Formatter fmt,
match_flag_type flags = match_default)
{
std::basic_string<charT> result;
re_detail::string_out_iterator<std::basic_string<charT> > i(result);
regex_replace(i, s.begin(), s.end(), e, fmt, flags);
return result;
}
示例3: IsPrintable
template< class CharT > bool IsPrintable( const std::basic_string< CharT >& str )
{
const std::ctype< CharT > *pct = 0, &ct = tss::GetFacet( std::locale(), pct );
for( std::basic_string< CharT >::const_iterator at = str.begin(); at != str.end(); at++ )
{
if( ! ct.is( std::ctype_base::print, *at ) ) // if not printable
return false;
}
return true;
}
示例4: result
std::basic_string <CharType, TraitsType, AllocType>
lowercase( const std::basic_string <CharType, TraitsType, AllocType> & s )
{
std::basic_string <CharType, TraitsType, AllocType> result( s.length(), '\0' );
std::transform(
s.begin(),
s.end(),
result.begin(),
std::ptr_fun <int, int> ( std::tolower )
);
return result;
}
示例5: countUnique
int countUnique(const std::basic_string<T>& s) {
using std::basic_string;
basic_string<T> chars;
for (typename basic_string<T>::const_iterator p = s.begin( );
p != s.end( ); ++p) {
if (chars.find(*p) == basic_string<T>::npos)
chars += *p;
}
return(chars.length( ));
}
示例6:
inline std::basic_string<Char> regex_replace
(
std::basic_string<Char> const &str
, basic_regex<typename std::basic_string<Char>::const_iterator> const &re
, std::basic_string<Char> const &fmt
, regex_constants::match_flag_type flags = regex_constants::match_default
)
{
std::basic_string<Char> result;
result.reserve(fmt.length() * 2);
regex_replace(std::back_inserter(result), str.begin(), str.end(), re, fmt, flags);
return result;
}
示例7: move
std::basic_string < Elem, Traits > cell_encode(std::basic_string < Elem, Traits > Str, Elem Sep_, Elem Esc){
if(Str.find(Sep_) < Str.size() || Str.find(Esc) < Str.size()){
for(auto itr = Str.begin(); itr != Str.end(); ++itr){
if(*itr == Esc){
itr = Str.insert(++itr, Esc);
}
}
Str.insert(Str.begin(), Esc);
Str.push_back(Esc);
}
return std::move(Str);
}
示例8: trim
std::basic_string<Ch> trim(const std::basic_string<Ch> &s,
const std::locale &loc = std::locale())
{
typename std::basic_string<Ch>::const_iterator first = s.begin();
typename std::basic_string<Ch>::const_iterator end = s.end();
while (first != end && std::isspace(*first, loc))
++first;
if (first == end)
return std::basic_string<Ch>();
typename std::basic_string<Ch>::const_iterator last = end;
do --last; while (std::isspace(*last, loc));
if (first != s.begin() || last + 1 != end)
return std::basic_string<Ch>(first, last + 1);
else
return s;
}
示例9: Ch
std::basic_string<Ch> encode_char_entities(const std::basic_string<Ch> &s)
{
typedef typename std::basic_string<Ch> Str;
Str r;
typename Str::const_iterator end = s.end();
for (typename Str::const_iterator it = s.begin(); it != end; ++it)
{
switch (*it)
{
case Ch('<'): r += detail::widen<Ch>("<"); break;
case Ch('>'): r += detail::widen<Ch>(">"); break;
case Ch('&'): r += detail::widen<Ch>("&"); break;
default: r += *it; break;
}
}
return r;
}
示例10: main
int main()
{
std::locale l = std::locale::classic();
const std::basic_string<F::extern_type> from("some text");
const std::basic_string<F::intern_type> expected(from.begin(), from.end());
std::basic_string<F::intern_type> to(from.size(), F::intern_type());
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs = {};
const F::extern_type* from_next = 0;
F::intern_type* to_next = 0;
F::result r = f.in(mbs, from.data(), from.data() + from.size(), from_next,
&to[0], &to[0] + to.size(), to_next);
assert(r == F::ok);
assert(from_next - from.data() == from.size());
assert(to_next - to.data() == expected.size());
assert(to_next - to.data() == expected.size());
assert(to == expected);
}
示例11: condense
std::basic_string<Ch> condense(const std::basic_string<Ch> &s)
{
std::basic_string<Ch> r;
std::locale loc;
bool space = false;
typename std::basic_string<Ch>::const_iterator end = s.end();
for (typename std::basic_string<Ch>::const_iterator it = s.begin();
it != end; ++it)
{
if (isspace(*it, loc) || *it == Ch('\n'))
{
if (!space)
r += Ch(' '), space = true;
}
else
r += *it, space = false;
}
return r;
}
示例12: if
std::basic_string<Ch> create_escapes(const std::basic_string<Ch> &s)
{
std::basic_string<Ch> result;
typename std::basic_string<Ch>::const_iterator b = s.begin();
typename std::basic_string<Ch>::const_iterator e = s.end();
while (b != e)
{
// This assumes an ASCII superset. But so does everything in PTree.
// We escape everything outside ASCII, because this code can't
// handle high unicode characters.
if (*b == 0x20 || *b == 0x21 || (*b >= 0x23 && *b <= 0x2E) ||
(*b >= 0x30 && *b <= 0x5B) || (*b >= 0x5D && *b <= 0xFF) ||
(*b >= -0x80 && *b < 0)) // PATCH!!! Patched by the "iCardClient" developing team, this will pass UTF-8 signed chars.
result += *b;
else if (*b == Ch('\b')) result += Ch('\\'), result += Ch('b');
else if (*b == Ch('\f')) result += Ch('\\'), result += Ch('f');
else if (*b == Ch('\n')) result += Ch('\\'), result += Ch('n');
else if (*b == Ch('\r')) result += Ch('\\'), result += Ch('r');
else if (*b == Ch('\t')) result += Ch('\\'), result += Ch('t');
else if (*b == Ch('/')) result += Ch('\\'), result += Ch('/');
else if (*b == Ch('"')) result += Ch('\\'), result += Ch('"');
else if (*b == Ch('\\')) result += Ch('\\'), result += Ch('\\');
else
{
const char *hexdigits = "0123456789ABCDEF";
typedef typename make_unsigned<Ch>::type UCh;
unsigned long u = (std::min)(static_cast<unsigned long>(
static_cast<UCh>(*b)),
0xFFFFul);
int d1 = u / 4096; u -= d1 * 4096;
int d2 = u / 256; u -= d2 * 256;
int d3 = u / 16; u -= d3 * 16;
int d4 = u;
result += Ch('\\'); result += Ch('u');
result += Ch(hexdigits[d1]); result += Ch(hexdigits[d2]);
result += Ch(hexdigits[d3]); result += Ch(hexdigits[d4]);
result += *b;
}
++b;
}
return result;
}
示例13: TrimLeft
void IO::TrimLeft(std::basic_string<charType> & str, const char* chars2remove)
{
if (!str.empty()) //trim the characters in chars2remove from the left
{
std::string::size_type pos = 0;
if (chars2remove != NULL)
{
pos = str.find_first_not_of(chars2remove);
if (pos != std::string::npos)
str.erase(0,pos);
else
str.erase( str.begin() , str.end() ); // make empty
}
else //trim space
{
pos = std::string::npos; //pos = -1
for (size_t i = 0; i < str.size(); ++i)
{
if (!isspace(str[i]))
{
pos = i;
break;
}
}
if (pos != std::string::npos)
{
if (pos > 0)
{
size_t length = str.size() - pos;
for (size_t i = 0; i < length; ++i) str[i] = str[i+pos];
str.resize(length);
}
}
else
{
str.clear();
}
}
}
}
示例14: tok
std::vector<std::basic_string<charT> >
split_unix(
const std::basic_string<charT>& cmdline,
const std::basic_string<charT>& seperator,
const std::basic_string<charT>& quote,
const std::basic_string<charT>& escape)
{
typedef boost::tokenizer< boost::escaped_list_separator<charT>,
typename std::basic_string<charT>::const_iterator,
std::basic_string<charT> > tokenizerT;
tokenizerT tok(cmdline.begin(), cmdline.end(),
boost::escaped_list_separator< charT >(escape, seperator, quote));
std::vector< std::basic_string<charT> > result;
for (typename tokenizerT::iterator cur_token(tok.begin()), end_token(tok.end()); cur_token != end_token; ++cur_token) {
if (!cur_token->empty())
result.push_back(*cur_token);
}
return result;
}
示例15: if
std::string utf32_to_utf8(const std::basic_string<unsigned int> &s)
{
std::string result;
result.reserve(s.size()); // at least that long
for(std::basic_string<unsigned int>::const_iterator
it=s.begin();
it!=s.end();
it++)
{
register unsigned int c=*it;
if(c<=0x7f)
result+=char(c);
else if(c<=0x7ff)
{
result+=char((c >> 6) | 0xc0);
result+=char((c & 0x3f) | 0x80);
}
else if(c<=0xffff)