update boost on linux
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include <boost/format/detail/compat_workarounds.hpp>
|
||||
#include <boost/utility/base_from_member.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -62,7 +63,7 @@ namespace boost {
|
||||
= ::std::ios_base::in | ::std::ios_base::out)
|
||||
: putend_(NULL), is_allocated_(false), mode_(mode)
|
||||
{ dealloc(); str(s); }
|
||||
virtual ~basic_altstringbuf()
|
||||
virtual ~basic_altstringbuf() BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{ dealloc(); }
|
||||
using streambuf_t::pbase;
|
||||
using streambuf_t::pptr;
|
||||
@@ -137,13 +138,13 @@ namespace boost {
|
||||
public:
|
||||
typedef Alloc allocator_type;
|
||||
basic_oaltstringstream()
|
||||
: pbase_type(new stringbuf_t), stream_t(rdbuf())
|
||||
: pbase_type(new stringbuf_t), stream_t(pbase_type::member.get())
|
||||
{ }
|
||||
basic_oaltstringstream(::boost::shared_ptr<stringbuf_t> buf)
|
||||
: pbase_type(buf), stream_t(rdbuf())
|
||||
: pbase_type(buf), stream_t(pbase_type::member.get())
|
||||
{ }
|
||||
basic_oaltstringstream(stringbuf_t * buf)
|
||||
: pbase_type(buf, No_Op() ), stream_t(rdbuf())
|
||||
: pbase_type(buf, No_Op() ), stream_t(pbase_type::member.get())
|
||||
{ }
|
||||
stringbuf_t * rdbuf() const
|
||||
{ return pbase_type::member.get(); }
|
||||
|
||||
@@ -118,12 +118,12 @@ namespace detail {
|
||||
|
||||
template< class Ch, class Tr, class T>
|
||||
void call_put_head(BOOST_IO_STD basic_ostream<Ch, Tr> & os, const void* x) {
|
||||
put_head(os, *(typename ::boost::remove_reference<T>::type*)x);
|
||||
put_head(os, *(static_cast<T const *>(x)));
|
||||
}
|
||||
|
||||
template< class Ch, class Tr, class T>
|
||||
void call_put_last(BOOST_IO_STD basic_ostream<Ch, Tr> & os, const void* x) {
|
||||
put_last(os, *(T*)x);
|
||||
put_last(os, *(static_cast<T const *>(x)));
|
||||
}
|
||||
|
||||
template< class Ch, class Tr>
|
||||
@@ -173,9 +173,11 @@ namespace detail {
|
||||
|
||||
basic_oaltstringstream<Ch, Tr, Alloc> oss( &buf);
|
||||
|
||||
#if !defined(BOOST_NO_STD_LOCALE)
|
||||
if(loc_p != NULL)
|
||||
oss.imbue(*loc_p);
|
||||
|
||||
#endif
|
||||
|
||||
specs.fmtstate_.apply_on(oss, loc_p);
|
||||
|
||||
// the stream format state can be modified by manipulators in the argument :
|
||||
@@ -200,7 +202,7 @@ namespace detail {
|
||||
(res_beg[0] !=oss.widen('+') && res_beg[0] !=oss.widen('-') ))
|
||||
prefix_space = oss.widen(' ');
|
||||
size_type res_size = (std::min)(
|
||||
static_cast<size_type>(specs.truncate_ - !!prefix_space),
|
||||
(static_cast<size_type>((specs.truncate_ & (std::numeric_limits<size_type>::max)())) - !!prefix_space),
|
||||
buf.pcount() );
|
||||
mk_str(res, res_beg, res_size, w, oss.fill(), fl,
|
||||
prefix_space, (specs.pad_scheme_ & format_item_t::centered) !=0 );
|
||||
@@ -244,9 +246,9 @@ namespace detail {
|
||||
}
|
||||
// we now have the minimal-length output
|
||||
const Ch * tmp_beg = buf.pbase();
|
||||
size_type tmp_size = (std::min)(static_cast<size_type>(specs.truncate_),
|
||||
buf.pcount() );
|
||||
|
||||
size_type tmp_size = (std::min)(
|
||||
(static_cast<size_type>(specs.truncate_ & (std::numeric_limits<size_type>::max)())),
|
||||
buf.pcount());
|
||||
|
||||
if(static_cast<size_type>(w) <= tmp_size) {
|
||||
// minimal length is already >= w, so no padding (cool!)
|
||||
|
||||
@@ -68,6 +68,18 @@ namespace boost {
|
||||
{ return io::detail::feed<CharT, Tr, Alloc, T&>(*this,x); }
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
basic_format& operator%(volatile const T& x)
|
||||
{ /* make a non-volatile copy */ const T v(x);
|
||||
/* pass the copy along */ return io::detail::feed<CharT, Tr, Alloc, const T&>(*this, v); }
|
||||
|
||||
#ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST
|
||||
template<class T>
|
||||
basic_format& operator%(volatile T& x)
|
||||
{ /* make a non-volatile copy */ T v(x);
|
||||
/* pass the copy along */ return io::detail::feed<CharT, Tr, Alloc, T&>(*this, v); }
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
// GCC can't handle anonymous enums without some help
|
||||
// ** arguments passing ** //
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/format/detail/compat_workarounds.hpp>
|
||||
@@ -111,7 +112,7 @@ namespace detail {
|
||||
else if(loc_default)
|
||||
os.imbue(*loc_default);
|
||||
#else
|
||||
(void) loc_default; // keep compiler quiet if we don't support locales
|
||||
ignore_unused(loc_default);
|
||||
#endif
|
||||
// set the state of this stream according to our params
|
||||
if(width_ != -1)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace io {
|
||||
@@ -29,12 +29,12 @@ namespace detail {
|
||||
#if defined(BOOST_NO_STD_LOCALE)
|
||||
// streams will be used for narrow / widen. but these methods are not const
|
||||
template<class T>
|
||||
T& const_or_not(const T& x) {
|
||||
T& const_or_not(const T& x) {
|
||||
return const_cast<T&> (x);
|
||||
}
|
||||
#else
|
||||
template<class T>
|
||||
const T& const_or_not(const T& x) {
|
||||
const T& const_or_not(const T& x) {
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
@@ -49,13 +49,13 @@ namespace detail {
|
||||
#if ! defined( BOOST_NO_LOCALE_ISDIGIT )
|
||||
return fac.is(std::ctype<Ch>::digit, c);
|
||||
# else
|
||||
(void) fac; // remove "unused parameter" warning
|
||||
ignore_unused(fac);
|
||||
using namespace std;
|
||||
return isdigit(c) != 0;
|
||||
#endif
|
||||
return isdigit(c) != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class Iter, class Facet>
|
||||
|
||||
template<class Iter, class Facet>
|
||||
Iter wrap_scan_notdigit(const Facet & fac, Iter beg, Iter end) {
|
||||
using namespace std;
|
||||
for( ; beg!=end && wrap_isdigit(fac, *beg); ++beg) ;
|
||||
@@ -68,8 +68,8 @@ namespace detail {
|
||||
// Effects : read sequence and convert digits into integral n, of type Res
|
||||
// Returns : n
|
||||
template<class Res, class Iter, class Facet>
|
||||
Iter str2int (const Iter & start, const Iter & last, Res & res,
|
||||
const Facet& fac)
|
||||
Iter str2int (const Iter & start, const Iter & last, Res & res,
|
||||
const Facet& fac)
|
||||
{
|
||||
using namespace std;
|
||||
Iter it;
|
||||
@@ -82,33 +82,16 @@ namespace detail {
|
||||
return it;
|
||||
}
|
||||
|
||||
// skip printf's "asterisk-fields" directives in the format-string buf
|
||||
// Input : char string, with starting index *pos_p
|
||||
// a Facet merely to use its widen/narrow member function
|
||||
// Effects : advance *pos_p by skipping printf's asterisk fields.
|
||||
// Returns : nothing
|
||||
template<class Iter, class Facet>
|
||||
Iter skip_asterisk(Iter start, Iter last, const Facet& fac)
|
||||
{
|
||||
using namespace std;
|
||||
++ start;
|
||||
start = wrap_scan_notdigit(fac, start, last);
|
||||
if(start!=last && *start== const_or_not(fac).widen( '$') )
|
||||
++start;
|
||||
return start;
|
||||
}
|
||||
|
||||
|
||||
// auxiliary func called by parse_printf_directive
|
||||
// for centralising error handling
|
||||
// it either throws if user sets the corresponding flag, or does nothing.
|
||||
inline void maybe_throw_exception(unsigned char exceptions,
|
||||
inline void maybe_throw_exception(unsigned char exceptions,
|
||||
std::size_t pos, std::size_t size)
|
||||
{
|
||||
if(exceptions & io::bad_format_string_bit)
|
||||
boost::throw_exception(io::bad_format_string(pos, size) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Input: the position of a printf-directive in the format-string
|
||||
// a basic_ios& merely to use its widen/narrow member function
|
||||
@@ -121,7 +104,7 @@ namespace detail {
|
||||
// this directive
|
||||
// *fpar is set with the parameters read in the directive
|
||||
template<class Ch, class Tr, class Alloc, class Iter, class Facet>
|
||||
bool parse_printf_directive(Iter & start, const Iter& last,
|
||||
bool parse_printf_directive(Iter & start, const Iter& last,
|
||||
detail::format_item<Ch, Tr, Alloc> * fpar,
|
||||
const Facet& fac,
|
||||
std::size_t offset, unsigned char exceptions)
|
||||
@@ -133,12 +116,13 @@ namespace detail {
|
||||
bool in_brackets=false;
|
||||
Iter start0 = start;
|
||||
std::size_t fstring_size = last-start0+offset;
|
||||
char mssiz = 0;
|
||||
|
||||
if(start>= last) { // empty directive : this is a trailing %
|
||||
maybe_throw_exception(exceptions, start-start0 + offset, fstring_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(*start== const_or_not(fac).widen( '|')) {
|
||||
in_brackets=true;
|
||||
if( ++start >= last ) {
|
||||
@@ -148,7 +132,7 @@ namespace detail {
|
||||
}
|
||||
|
||||
// the flag '0' would be picked as a digit for argument order, but here it's a flag :
|
||||
if(*start== const_or_not(fac).widen( '0'))
|
||||
if(*start== const_or_not(fac).widen( '0'))
|
||||
goto parse_flags;
|
||||
|
||||
// handle argument order (%2$d) or possibly width specification: %2d
|
||||
@@ -159,82 +143,77 @@ namespace detail {
|
||||
maybe_throw_exception(exceptions, start-start0+offset, fstring_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// %N% case : this is already the end of the directive
|
||||
if( *start == const_or_not(fac).widen( '%') ) {
|
||||
fpar->argN_ = n-1;
|
||||
++start;
|
||||
if( in_brackets)
|
||||
maybe_throw_exception(exceptions, start-start0+offset, fstring_size);
|
||||
// but don't return. maybe "%" was used in lieu of '$', so we go on.
|
||||
else
|
||||
return true;
|
||||
if( in_brackets)
|
||||
maybe_throw_exception(exceptions, start-start0+offset, fstring_size);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( *start== const_or_not(fac).widen( '$') ) {
|
||||
fpar->argN_ = n-1;
|
||||
++start;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// non-positionnal directive
|
||||
// non-positional directive
|
||||
fpar->fmtstate_.width_ = n;
|
||||
fpar->argN_ = format_item_t::argN_no_posit;
|
||||
goto parse_precision;
|
||||
}
|
||||
}
|
||||
|
||||
parse_flags:
|
||||
|
||||
parse_flags:
|
||||
// handle flags
|
||||
while ( start != last) { // as long as char is one of + - = _ # 0 l h or ' '
|
||||
// misc switches
|
||||
while (start != last) { // as long as char is one of + - = _ # 0 or ' '
|
||||
switch ( wrap_narrow(fac, *start, 0)) {
|
||||
case '\'' : break; // no effect yet. (painful to implement)
|
||||
case 'l':
|
||||
case 'h': // short/long modifier : for printf-comaptibility (no action needed)
|
||||
break;
|
||||
case '-':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::left;
|
||||
break;
|
||||
case '=':
|
||||
fpar->pad_scheme_ |= format_item_t::centered;
|
||||
break;
|
||||
case '_':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::internal;
|
||||
break;
|
||||
case ' ':
|
||||
fpar->pad_scheme_ |= format_item_t::spacepad;
|
||||
break;
|
||||
case '+':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::showpos;
|
||||
break;
|
||||
case '0':
|
||||
fpar->pad_scheme_ |= format_item_t::zeropad;
|
||||
// need to know alignment before really setting flags,
|
||||
// so just add 'zeropad' flag for now, it will be processed later.
|
||||
break;
|
||||
case '#':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::showpoint | std::ios_base::showbase;
|
||||
break;
|
||||
default:
|
||||
goto parse_width;
|
||||
case '\'':
|
||||
break; // no effect yet. (painful to implement)
|
||||
case '-':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::left;
|
||||
break;
|
||||
case '=':
|
||||
fpar->pad_scheme_ |= format_item_t::centered;
|
||||
break;
|
||||
case '_':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::internal;
|
||||
break;
|
||||
case ' ':
|
||||
fpar->pad_scheme_ |= format_item_t::spacepad;
|
||||
break;
|
||||
case '+':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::showpos;
|
||||
break;
|
||||
case '0':
|
||||
fpar->pad_scheme_ |= format_item_t::zeropad;
|
||||
// need to know alignment before really setting flags,
|
||||
// so just add 'zeropad' flag for now, it will be processed later.
|
||||
break;
|
||||
case '#':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::showpoint | std::ios_base::showbase;
|
||||
break;
|
||||
default:
|
||||
goto parse_width;
|
||||
}
|
||||
++start;
|
||||
} // loop on flag.
|
||||
|
||||
if( start>=last) {
|
||||
maybe_throw_exception(exceptions, start-start0+offset, fstring_size);
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// first skip 'asterisk fields' : * or num (length)
|
||||
parse_width:
|
||||
// handle width spec
|
||||
// first skip 'asterisk fields' : *, or *N$
|
||||
if(*start == const_or_not(fac).widen( '*') )
|
||||
start = skip_asterisk(start, last, fac);
|
||||
if(start!=last && wrap_isdigit(fac, *start))
|
||||
++start;
|
||||
else if(start!=last && wrap_isdigit(fac, *start))
|
||||
start = str2int(start, last, fpar->fmtstate_.width_, fac);
|
||||
|
||||
parse_precision:
|
||||
if( start>= last) {
|
||||
if( start>= last) {
|
||||
maybe_throw_exception(exceptions, start-start0+offset, fstring_size);
|
||||
return true;
|
||||
}
|
||||
@@ -242,22 +221,79 @@ namespace detail {
|
||||
if (*start== const_or_not(fac).widen( '.')) {
|
||||
++start;
|
||||
if(start != last && *start == const_or_not(fac).widen( '*') )
|
||||
start = skip_asterisk(start, last, fac);
|
||||
if(start != last && wrap_isdigit(fac, *start)) {
|
||||
++start;
|
||||
else if(start != last && wrap_isdigit(fac, *start)) {
|
||||
start = str2int(start, last, fpar->fmtstate_.precision_, fac);
|
||||
precision_set = true;
|
||||
}
|
||||
else
|
||||
fpar->fmtstate_.precision_ =0;
|
||||
}
|
||||
|
||||
// handle formatting-type flags :
|
||||
while( start != last && ( *start== const_or_not(fac).widen( 'l')
|
||||
|| *start== const_or_not(fac).widen( 'L')
|
||||
|| *start== const_or_not(fac).widen( 'h')) )
|
||||
|
||||
// argument type modifiers
|
||||
while (start != last) {
|
||||
switch (wrap_narrow(fac, *start, 0)) {
|
||||
case 'h':
|
||||
case 'l':
|
||||
case 'j':
|
||||
case 'z':
|
||||
case 'L':
|
||||
// boost::format ignores argument type modifiers as it relies on
|
||||
// the type of the argument fed into it by operator %
|
||||
break;
|
||||
|
||||
// Note that the ptrdiff_t argument type 't' from C++11 is not honored
|
||||
// because it was already in use as the tabulation specifier in boost::format
|
||||
// case 't':
|
||||
|
||||
// Microsoft extensions:
|
||||
// https://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx
|
||||
|
||||
case 'w':
|
||||
break;
|
||||
case 'I':
|
||||
mssiz = 'I';
|
||||
break;
|
||||
case '3':
|
||||
if (mssiz != 'I') {
|
||||
maybe_throw_exception(exceptions, start - start0 + offset, fstring_size);
|
||||
return true;
|
||||
}
|
||||
mssiz = '3';
|
||||
break;
|
||||
case '2':
|
||||
if (mssiz != '3') {
|
||||
maybe_throw_exception(exceptions, start - start0 + offset, fstring_size);
|
||||
return true;
|
||||
}
|
||||
mssiz = 0x00;
|
||||
break;
|
||||
case '6':
|
||||
if (mssiz != 'I') {
|
||||
maybe_throw_exception(exceptions, start - start0 + offset, fstring_size);
|
||||
return true;
|
||||
}
|
||||
mssiz = '6';
|
||||
break;
|
||||
case '4':
|
||||
if (mssiz != '6') {
|
||||
maybe_throw_exception(exceptions, start - start0 + offset, fstring_size);
|
||||
return true;
|
||||
}
|
||||
mssiz = 0x00;
|
||||
break;
|
||||
default:
|
||||
if (mssiz && mssiz == 'I') {
|
||||
mssiz = 0;
|
||||
}
|
||||
goto parse_conversion_specification;
|
||||
}
|
||||
++start;
|
||||
if( start>=last) {
|
||||
maybe_throw_exception(exceptions, start-start0+offset, fstring_size);
|
||||
} // loop on argument type modifiers to pick up 'hh', 'll', and the more complex microsoft ones
|
||||
|
||||
parse_conversion_specification:
|
||||
if (start >= last || mssiz) {
|
||||
maybe_throw_exception(exceptions, start - start0 + offset, fstring_size);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -265,84 +301,107 @@ namespace detail {
|
||||
++start;
|
||||
return true;
|
||||
}
|
||||
switch ( wrap_narrow(fac, *start, 0) ) {
|
||||
case 'X':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::uppercase;
|
||||
BOOST_FALLTHROUGH;
|
||||
case 'p': // pointer => set hex.
|
||||
case 'x':
|
||||
fpar->fmtstate_.flags_ &= ~std::ios_base::basefield;
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::hex;
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
fpar->fmtstate_.flags_ &= ~std::ios_base::basefield;
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::oct;
|
||||
break;
|
||||
// The default flags are "dec" and "skipws"
|
||||
// so if changing the base, need to unset basefield first
|
||||
|
||||
case 'E':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::uppercase;
|
||||
BOOST_FALLTHROUGH;
|
||||
case 'e':
|
||||
fpar->fmtstate_.flags_ &= ~std::ios_base::floatfield;
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::scientific;
|
||||
switch (wrap_narrow(fac, *start, 0))
|
||||
{
|
||||
// Boolean
|
||||
case 'b':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::boolalpha;
|
||||
break;
|
||||
|
||||
fpar->fmtstate_.flags_ &= ~std::ios_base::basefield;
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::dec;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
fpar->fmtstate_.flags_ &= ~std::ios_base::floatfield;
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::fixed;
|
||||
BOOST_FALLTHROUGH;
|
||||
case 'u':
|
||||
case 'd':
|
||||
case 'i':
|
||||
fpar->fmtstate_.flags_ &= ~std::ios_base::basefield;
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::dec;
|
||||
break;
|
||||
// Decimal
|
||||
case 'u':
|
||||
case 'd':
|
||||
case 'i':
|
||||
// Defaults are sufficient
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
++start;
|
||||
if( start >= last)
|
||||
// Hex
|
||||
case 'X':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::uppercase;
|
||||
BOOST_FALLTHROUGH;
|
||||
case 'x':
|
||||
case 'p': // pointer => set hex.
|
||||
fpar->fmtstate_.flags_ &= ~std::ios_base::basefield;
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::hex;
|
||||
break;
|
||||
|
||||
// Octal
|
||||
case 'o':
|
||||
fpar->fmtstate_.flags_ &= ~std::ios_base::basefield;
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::oct;
|
||||
break;
|
||||
|
||||
// Floating
|
||||
case 'A':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::uppercase;
|
||||
BOOST_FALLTHROUGH;
|
||||
case 'a':
|
||||
fpar->fmtstate_.flags_ &= ~std::ios_base::basefield;
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::fixed;
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::scientific;
|
||||
break;
|
||||
case 'E':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::uppercase;
|
||||
BOOST_FALLTHROUGH;
|
||||
case 'e':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::scientific;
|
||||
break;
|
||||
case 'F':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::uppercase;
|
||||
BOOST_FALLTHROUGH;
|
||||
case 'f':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::fixed;
|
||||
break;
|
||||
case 'G':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::uppercase;
|
||||
BOOST_FALLTHROUGH;
|
||||
case 'g':
|
||||
// default flags are correct here
|
||||
break;
|
||||
|
||||
// Tabulation (a boost::format extension)
|
||||
case 'T':
|
||||
++start;
|
||||
if( start >= last) {
|
||||
maybe_throw_exception(exceptions, start-start0+offset, fstring_size);
|
||||
return false;
|
||||
} else {
|
||||
fpar->fmtstate_.fill_ = *start;
|
||||
}
|
||||
fpar->pad_scheme_ |= format_item_t::tabulation;
|
||||
fpar->argN_ = format_item_t::argN_tabulation;
|
||||
break;
|
||||
case 't':
|
||||
fpar->fmtstate_.fill_ = const_or_not(fac).widen( ' ');
|
||||
fpar->pad_scheme_ |= format_item_t::tabulation;
|
||||
fpar->argN_ = format_item_t::argN_tabulation;
|
||||
break;
|
||||
|
||||
// Character
|
||||
case 'C':
|
||||
case 'c':
|
||||
fpar->truncate_ = 1;
|
||||
break;
|
||||
|
||||
// String
|
||||
case 'S':
|
||||
case 's':
|
||||
if(precision_set) // handle truncation manually, with own parameter.
|
||||
fpar->truncate_ = fpar->fmtstate_.precision_;
|
||||
fpar->fmtstate_.precision_ = 6; // default stream precision.
|
||||
break;
|
||||
|
||||
// %n is insecure and ignored by boost::format
|
||||
case 'n' :
|
||||
fpar->argN_ = format_item_t::argN_ignored;
|
||||
break;
|
||||
|
||||
default:
|
||||
maybe_throw_exception(exceptions, start-start0+offset, fstring_size);
|
||||
else
|
||||
fpar->fmtstate_.fill_ = *start;
|
||||
fpar->pad_scheme_ |= format_item_t::tabulation;
|
||||
fpar->argN_ = format_item_t::argN_tabulation;
|
||||
break;
|
||||
case 't':
|
||||
fpar->fmtstate_.fill_ = const_or_not(fac).widen( ' ');
|
||||
fpar->pad_scheme_ |= format_item_t::tabulation;
|
||||
fpar->argN_ = format_item_t::argN_tabulation;
|
||||
break;
|
||||
|
||||
case 'G':
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::uppercase;
|
||||
break;
|
||||
case 'g': // 'g' conversion is default for floats.
|
||||
fpar->fmtstate_.flags_ &= ~std::ios_base::basefield;
|
||||
fpar->fmtstate_.flags_ |= std::ios_base::dec;
|
||||
|
||||
// CLEAR all floatield flags, so stream will CHOOSE
|
||||
fpar->fmtstate_.flags_ &= ~std::ios_base::floatfield;
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
case 'c':
|
||||
fpar->truncate_ = 1;
|
||||
break;
|
||||
case 'S':
|
||||
case 's':
|
||||
if(precision_set) // handle truncation manually, with own parameter.
|
||||
fpar->truncate_ = fpar->fmtstate_.precision_;
|
||||
fpar->fmtstate_.precision_ = 6; // default stream precision.
|
||||
break;
|
||||
case 'n' :
|
||||
fpar->argN_ = format_item_t::argN_ignored;
|
||||
break;
|
||||
default:
|
||||
maybe_throw_exception(exceptions, start-start0+offset, fstring_size);
|
||||
}
|
||||
++start;
|
||||
|
||||
@@ -358,10 +417,10 @@ namespace detail {
|
||||
// -end parse_printf_directive()
|
||||
|
||||
template<class String, class Facet>
|
||||
int upper_bound_from_fstring(const String& buf,
|
||||
int upper_bound_from_fstring(const String& buf,
|
||||
const typename String::value_type arg_mark,
|
||||
const Facet& fac,
|
||||
unsigned char exceptions)
|
||||
const Facet& fac,
|
||||
unsigned char exceptions)
|
||||
{
|
||||
// quick-parsing of the format-string to count arguments mark (arg_mark, '%')
|
||||
// returns : upper bound on the number of format items in the format strings
|
||||
@@ -378,7 +437,7 @@ namespace detail {
|
||||
}
|
||||
}
|
||||
if(buf[i1+1] == buf[i1] ) {// escaped "%%"
|
||||
i1+=2; continue;
|
||||
i1+=2; continue;
|
||||
}
|
||||
|
||||
++i1;
|
||||
@@ -391,8 +450,8 @@ namespace detail {
|
||||
return num_items;
|
||||
}
|
||||
template<class String> inline
|
||||
void append_string(String& dst, const String& src,
|
||||
const typename String::size_type beg,
|
||||
void append_string(String& dst, const String& src,
|
||||
const typename String::size_type beg,
|
||||
const typename String::size_type end) {
|
||||
dst.append(src.begin()+beg, src.begin()+end);
|
||||
}
|
||||
@@ -406,19 +465,19 @@ namespace detail {
|
||||
// format :: parse(..)
|
||||
|
||||
template<class Ch, class Tr, class Alloc>
|
||||
basic_format<Ch, Tr, Alloc>& basic_format<Ch, Tr, Alloc>::
|
||||
basic_format<Ch, Tr, Alloc>& basic_format<Ch, Tr, Alloc>::
|
||||
parse (const string_type& buf) {
|
||||
// parse the format-string
|
||||
// parse the format-string
|
||||
using namespace std;
|
||||
#if !defined(BOOST_NO_STD_LOCALE)
|
||||
const std::ctype<Ch> & fac = BOOST_USE_FACET( std::ctype<Ch>, getloc());
|
||||
#else
|
||||
io::basic_oaltstringstream<Ch, Tr, Alloc> fac;
|
||||
io::basic_oaltstringstream<Ch, Tr, Alloc> fac;
|
||||
//has widen and narrow even on compilers without locale
|
||||
#endif
|
||||
|
||||
const Ch arg_mark = io::detail::const_or_not(fac).widen( '%');
|
||||
bool ordered_args=true;
|
||||
bool ordered_args=true;
|
||||
int max_argN=-1;
|
||||
|
||||
// A: find upper_bound on num_items and allocates arrays
|
||||
@@ -433,10 +492,10 @@ namespace detail {
|
||||
int cur_item=0;
|
||||
while( (i1=buf.find(arg_mark,i1)) != string_type::npos ) {
|
||||
string_type & piece = (cur_item==0) ? prefix_ : items_[cur_item-1].appendix_;
|
||||
if( buf[i1+1] == buf[i1] ) { // escaped mark, '%%'
|
||||
if( buf[i1+1] == buf[i1] ) { // escaped mark, '%%'
|
||||
io::detail::append_string(piece, buf, i0, i1+1);
|
||||
i1+=2; i0=i1;
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
BOOST_ASSERT( static_cast<unsigned int>(cur_item) < items_.size() || cur_item==0);
|
||||
|
||||
@@ -450,7 +509,7 @@ namespace detail {
|
||||
it, buf.end(), &items_[cur_item], fac, i1, exceptions());
|
||||
i1 = it - buf.begin();
|
||||
if( ! parse_ok ) // the directive will be printed verbatim
|
||||
continue;
|
||||
continue;
|
||||
i0=i1;
|
||||
items_[cur_item].compute_states(); // process complex options, like zeropad, into params
|
||||
|
||||
@@ -465,13 +524,13 @@ namespace detail {
|
||||
++cur_item;
|
||||
} // loop on %'s
|
||||
BOOST_ASSERT(cur_item == num_items);
|
||||
|
||||
|
||||
// store the final piece of string
|
||||
{
|
||||
string_type & piece = (cur_item==0) ? prefix_ : items_[cur_item-1].appendix_;
|
||||
io::detail::append_string(piece, buf, i0, buf.size());
|
||||
}
|
||||
|
||||
|
||||
if( !ordered_args) {
|
||||
if(max_argN >= 0 ) { // dont mix positional with non-positionnal directives
|
||||
if(exceptions() & io::bad_format_string_bit)
|
||||
@@ -488,7 +547,7 @@ namespace detail {
|
||||
}
|
||||
max_argN = non_ordered_items-1;
|
||||
}
|
||||
|
||||
|
||||
// C: set some member data :
|
||||
items_.resize(num_items, format_item_t(io::detail::const_or_not(fac).widen( ' ')) );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user