本文整理汇总了C++中zstring::rend方法的典型用法代码示例。如果您正苦于以下问题:C++ zstring::rend方法的具体用法?C++ zstring::rend怎么用?C++ zstring::rend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zstring
的用法示例。
在下文中一共展示了zstring::rend方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: format_integer
static void format_integer( xs_integer const &xs_n, picture const &pic,
zstring *dest ) {
picture default_pic;
switch ( pic.primary.type ) {
case picture::one:
//
// XQuery F&O 3.0: 4.6.1: For all format tokens other than [ones that
// consists of decimal digits], there may be implementation-defined lower
// and upper bounds on the range of numbers that can be formatted using
// this format token; indeed, for some numbering sequences there may be
// intrinsic limits. For example, the format token ① (circled
// digit one) has a range of 1 to 20 imposed by the Unicode character
// repertoire.
//
try {
xs_long const n = to_xs_long( xs_n );
int min, max;
if ( get_one_range( pic.primary.one, &min, &max ) &&
n >= min && n <= max ) {
utf8_string<zstring> u_dest( *dest );
u_dest = (unicode::code_point)(pic.primary.one + n - 1);
break;
}
//
// Ibid: Numbers that fall outside this range must be formatted using
// the format token 1.
//
format_integer( xs_n, default_pic, dest );
}
catch ( range_error const& ) {
format_integer( xs_n, default_pic, dest );
}
break;
case picture::arabic: {
xs_integer xs_n2( xs_n );
if ( xs_n2.sign() < 0 )
xs_n2 = -xs_n2;
zstring const s( xs_n2.toString() );
zstring::const_reverse_iterator n_i( s.rbegin() );
zstring::const_reverse_iterator const n_end( s.rend() );
utf8_string<zstring const> const u_pic_format( pic.primary.format );
utf8_string<zstring const>::const_reverse_iterator
pic_i( u_pic_format.rbegin() );
utf8_string<zstring const>::const_reverse_iterator const
pic_end( u_pic_format.rend() );
int digit_pos = 0;
unicode::code_point grouping_cp;
bool just_inserted_grouping_separator = false;
int mandatory_digits = pic.primary.mandatory_digits;
int mandatory_grouping_seps = pic.primary.mandatory_grouping_seps;
utf8_string<zstring> u_dest( *dest );
//
// Step through both the integer and picture from right-to-left.
//
while ( n_i != n_end || pic_i != pic_end ) {
unicode::code_point digit_cp = pic.primary.zero;
if ( n_i != n_end )
digit_cp += *n_i - '0';
if ( pic_i != pic_end ) { // haven't exhausted the picture
if ( !mandatory_digits && !mandatory_grouping_seps && n_i == n_end )
break;
unicode::code_point const pic_cp = *pic_i++;
if ( pic_cp == '#' || unicode::is_Nd( pic_cp ) ) {
u_dest.insert( 0, 1, digit_cp );
if ( n_i != n_end ) ++n_i;
++digit_pos;
if ( pic_cp != '#' )
--mandatory_digits;
} else { // must be a grouping-separator
grouping_cp = pic_cp; // remember for later
u_dest.insert( 0, 1, grouping_cp );
if ( mandatory_grouping_seps )
--mandatory_grouping_seps;
}
} else { // have exhausted the picture
if ( pic.primary.grouping_interval &&
digit_pos % pic.primary.grouping_interval == 0 ) {
if ( just_inserted_grouping_separator )
just_inserted_grouping_separator = false;
else {
u_dest.insert( 0, 1, grouping_cp );
just_inserted_grouping_separator = true;
continue;
}
}
u_dest.insert( 0, 1, digit_cp );
if ( n_i != n_end ) ++n_i;
++digit_pos;
}
} // while
if ( xs_n.sign() < 0 )
dest->insert( (zstring::size_type)0, 1, '-' );
if ( pic.modifier.co == picture::ordinal )
//.........这里部分代码省略.........