本文整理汇总了C++中string_type::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ string_type::begin方法的具体用法?C++ string_type::begin怎么用?C++ string_type::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类string_type
的用法示例。
在下文中一共展示了string_type::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: equals
static bool equals(const string_type& str1, const string_type& str2) {
if(str1.size() != str2.size()) {
return false;
} else if(str1.empty() && str2.empty()) {
return true;
} else {
return std::equal(
str1.begin(),
str1.end(),
str2.begin()
);
}
}
示例2: if
template<class manipulator, class parser_type> void set_and_configure(manipulator & manip, const string_type & name, parser_type parser) {
// need to parse string
string_type prev ;
bool parsing_params = false;
string_type params;
string_type stripped_str;
for ( typename string_type::const_iterator b = name.begin(), e = name.end(); b != e; ++b) {
if ( (*b == '(') && !parsing_params) {
if ( parser.has_manipulator_name() ) {
parsing_params = true;
params.clear();
}
}
else if ( (*b == ')') && parsing_params) {
BOOST_ASSERT ( parser.has_manipulator_name() );
manip.configure_inner( parser.get_manipulator_name(), params);
parser.clear();
parsing_params = false;
}
else {
if ( parsing_params)
params += *b;
else {
stripped_str += *b;
parser.add( *b);
}
}
}
manip.string( stripped_str);
}
示例3: tokenize
static std::deque<string_type> tokenize(string_type input, string_type br)
{
typename string_type::iterator a,b,c;
std::deque<string_type> tokens;
// std::cerr << "Tokenising string=" << input << " break=" << br << std::endl;
while ( input.length() )
{
a = input.begin();
c = input.end();
typename string_type::size_type e = input.find(br);
if ( e != string_type::npos )
{
b = a+e;
tokens.push_back(string_type(a,b));
input = string_type(b+br.length(),c);
}
else
{
tokens.push_back(input);
input = string_type();
}
// std::cerr << "Pushed token " << tokens.back() << " input now " << input << std::endl;
}
return tokens;
}
示例4: put_string
void put_string(iter_type& oi, const string_type& s1) const
{
typename string_type::const_iterator si,end;
for (si=s1.begin(), end=s1.end(); si!=end; si++, oi++) {
*oi = *si;
}
}
示例5: while
OutputIterator format
(
OutputIterator out
, const string_type &fmt
, regex_constants::match_flag_type flags = regex_constants::format_default
) const
{
detail::results_traits<char_type> traits;
typename string_type::const_iterator cur = fmt.begin(), end = fmt.end();
if(0 != (regex_constants::format_literal & flags))
{
out = std::copy(cur, end, out);
}
else while(cur != end)
{
if(BOOST_XPR_CHAR_(char_type, '$') != *cur)
{
*out++ = *cur++;
}
else if(++cur == end)
{
*out++ = BOOST_XPR_CHAR_(char_type, '$');
}
else if(BOOST_XPR_CHAR_(char_type, '$') == *cur)
{
*out++ = *cur++;
}
else if(BOOST_XPR_CHAR_(char_type, '&') == *cur) // whole match
{
++cur;
out = std::copy((*this)[ 0 ].first, (*this)[ 0 ].second, out);
}
else if(BOOST_XPR_CHAR_(char_type, '`') == *cur) // prefix
{
++cur;
out = std::copy(this->prefix().first, this->prefix().second, out);
}
else if(BOOST_XPR_CHAR_(char_type, '\'') == *cur) // suffix
{
++cur;
out = std::copy(this->suffix().first, this->suffix().second, out);
}
else if(-1 != traits.value(*cur, 10)) // a sub-match
{
int max = static_cast<int>(this->size() - 1);
int br_nbr = detail::toi(cur, end, traits, 10, max);
detail::ensure(0 != br_nbr, regex_constants::error_subreg, "invalid back-reference");
out = std::copy((*this)[ br_nbr ].first, (*this)[ br_nbr ].second, out);
}
else
{
*out++ = BOOST_XPR_CHAR_(char_type, '$');
*out++ = *cur++;
}
}
return out;
}
示例6: while
//! Converts escape sequences to the corresponding characters
void char_constants< char >::translate_escape_sequences(string_type& str)
{
using namespace std; // to make sure we can use C functions unqualified
string_type::iterator it = str.begin();
while (it != str.end())
{
it = std::find(it, str.end(), '\\');
if (std::distance(it, str.end()) >= 2)
{
it = str.erase(it);
switch (*it)
{
case 'n':
*it = '\n'; break;
case 'r':
*it = '\r'; break;
case 'a':
*it = '\a'; break;
case '\\':
++it; break;
case 't':
*it = '\t'; break;
case 'b':
*it = '\b'; break;
case 'x':
{
string_type::iterator b = it;
if (std::distance(++b, str.end()) >= 2)
{
char_type c1 = *b++, c2 = *b++;
if (isxdigit(c1) && isxdigit(c2))
{
*it++ = char_type((to_number(c1) << 4) | to_number(c2));
it = str.erase(it, b);
}
}
break;
}
default:
{
if (*it >= '0' && *it <= '7')
{
string_type::iterator b = it;
int c = (*b++) - '0';
if (*b >= '0' && *b <= '7')
c = c * 8 + (*b++) - '0';
if (*b >= '0' && *b <= '7')
c = c * 8 + (*b++) - '0';
*it++ = char_type(c);
it = str.erase(it, b);
}
break;
}
}
}
}
}
示例7:
user_string convert<user_string>(const string_type & source,
system::error_code & ec)
{
user_string temp;
for (string_type::const_iterator it = source.begin();
it != source.end(); ++it)
temp += *it - 1;
return temp;
}
示例8: put_string
//! helper function to put the various member string into stream
OutItrT put_string(OutItrT next, const string_type& str) const
{
typename string_type::const_iterator itr = str.begin();
while(itr != str.end()) {
*next = *itr;
++itr;
++next;
}
return next;
}
示例9: operator
//! Applies string replacements starting from the specified position
result_type operator() (string_type& str, typename string_type::size_type start_pos = 0) const
{
base_type::operator() (str, start_pos);
typedef typename string_type::iterator string_iterator;
for (string_iterator it = str.begin() + start_pos, end = str.end(); it != end; ++it)
{
char_type c = *it;
if (c < 0x20 || c > 0x7e)
{
char_type buf[(std::numeric_limits< char_type >::digits + 3) / 4 + 3];
std::size_t n = traits_type::print_escaped(buf, c);
std::size_t pos = it - str.begin();
str.replace(pos, 1, buf, n);
it = str.begin() + n - 1;
end = str.end();
}
}
}
示例10: parse_content_type
mime_content_type parse_content_type ( const string_type &theHeader ) {
tracer t ( __func__ );
mime_content_type retVal;
typename string_type::const_iterator first = theHeader.begin ();
mime_content_type_parser<typename string_type::const_iterator> ct_parser;
bool b = qi::parse ( first, theHeader.end (), ct_parser, retVal );
if (!b)
throw mime_parsing_error ( "Failed to parse the 'Content-Type' header" );
return retVal;
}
示例11: parse_input_line
void parse_input_line(const string_type& s)
{
// set matches back to starting values:
for(int i = 0; i < MAX_MATCHES; ++i)
{
matches[i] = -2;
}
parse_function op;
do_test = false;
regex_grep(op, s.begin(), s.end(), parse_expression);
jm_trace("expression: " << make_narrow(expression).c_str());
jm_trace("search string: " << make_narrow(search_text).c_str());
}
示例12: append_string
/**
@brief appends a string (inserts it at the end)
*/
void append_string(const string_type & str) {
if ( m_reserve_append < str.size()) {
std::size_t new_reserve_append = str.size() + m_grow_size ;
resize_string( m_reserve_prepend, new_reserve_append);
}
BOOST_ASSERT(m_reserve_append >= str.size());
typename string_type::difference_type start_idx = static_cast<typename string_type::difference_type>(m_str.size() - m_reserve_append);
std::copy(str.begin(), str.end(), m_str.begin() + start_idx);
m_reserve_append -= str.size();
m_full_msg_computed = false;
}
示例13: append_string
/**
@brief appends a string (inserts it at the end)
*/
void append_string(const string_type & str) {
if ( m_reserve_append < (int)str.size()) {
int new_reserve_append = (int)str.size() + m_grow_size ;
resize_string( m_reserve_prepend, new_reserve_append);
}
BOOST_ASSERT(m_reserve_append >= (int)str.size() );
int start_idx = (int)m_str.size() - m_reserve_append;
std::copy(str.begin(), str.end(), m_str.begin() + start_idx);
m_reserve_append -= (int)str.size();
m_full_msg_computed = false;
}
示例14: parse
bool parse(scanner_t& scanner, skip_t& ) const
{
scanner.save();
for (typename string_type::const_iterator itor = literal.begin();
itor != literal.end(); ++itor)
{
const int val = scanner.read();
if (val == -1 ||
traits_type::to_char_type(val) != *itor)
{
scanner.rollback();
return false;
}
}
scanner.commit();
return true;
}
示例15: decode_bbox
DecodedBBox decode_bbox(const string_type & _hash_string)
{
// Copy of the string down-cased
// Wish this was ruby, then it would be simple: _hash_string.downcase();
string_type hash_string(_hash_string);
std::transform(
_hash_string.begin(),
_hash_string.end(),
hash_string.begin(),
::tolower);
DecodedBBox output;
output.maxlat = 90;
output.maxlon = 180;
output.minlat = -90;
output.minlon = -180;
bool islon = true;
for(int i = 0, max = hash_string.length(); i < max; i++) {
int char_index = base32_codes_index_of(hash_string[i]);
for (int bits = 4; bits >= 0; --bits) {
int bit = (char_index >> bits) & 1;
if (islon) {
double mid = (output.maxlon + output.minlon) / 2;
if(bit == 1) {
output.minlon = mid;
} else {
output.maxlon = mid;
}
} else {
double mid = (output.maxlat + output.minlat) / 2;
if(bit == 1) {
output.minlat = mid;
} else {
output.maxlat = mid;
}
}
islon = !islon;
}
}
return output;
}