14 #ifndef BOOST_FORMAT_FEED_ARGS_HPP 15 #define BOOST_FORMAT_FEED_ARGS_HPP 29 template<
class Ch,
class Tr,
class Alloc>
32 typename std::basic_string<Ch,Tr,Alloc>::size_type
size,
35 std::ios_base::fmtflags
f,
36 const Ch prefix_space,
41 typedef typename std::basic_string<Ch,Tr,Alloc>::size_type size_type;
43 if(w<=0 || static_cast<size_type>(w) <=size) {
45 res.reserve(size + !!prefix_space);
47 res.append(1, prefix_space);
49 res.append(beg, size);
52 std::streamsize
n=
static_cast<std::streamsize
>(w-size-!!prefix_space);
53 std::streamsize n_after = 0, n_before = 0;
54 res.reserve(static_cast<size_type>(w));
56 n_after = n/2, n_before = n - n_after;
63 if(n_before) res.append(static_cast<size_type>(n_before), fill_char);
65 res.append(1, prefix_space);
67 res.append(beg, size);
68 if(n_after) res.append(static_cast<size_type>(n_after), fill_char);
73 #if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) 77 template<
class Ch,
class Tr,
class T>
inline 81 template<
class Ch,
class Tr,
class T>
inline 88 template<
class Ch,
class Tr,
class T>
inline 92 template<
class Ch,
class Tr,
class T>
inline 97 template<
class Ch,
class Tr,
class T>
inline 102 template<
class Ch,
class Tr,
class T>
inline 107 #ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST 108 template<
class Ch,
class Tr,
class T>
inline 112 template<
class Ch,
class Tr,
class T>
inline 117 #endif // -__DECCXX workaround 119 template<
class Ch,
class Tr,
class T>
124 template<
class Ch,
class Tr,
class T>
129 template<
class Ch,
class Tr>
142 template<
class Ch,
class Tr>
inline 147 template<
class Ch,
class Tr>
inline 153 template<
class Ch,
class Tr,
class Alloc,
class T>
164 #pragma warning(push) 165 #pragma warning(disable:4267) 172 typedef typename string_type::size_type size_type;
182 const std::ios_base::fmtflags fl=oss.flags();
183 const bool internal = (fl & std::ios_base::internal) != 0;
184 const std::streamsize
w = oss.width();
185 const bool two_stepped_padding=
internal && (w!=0);
188 if(! two_stepped_padding) {
192 const Ch * res_beg = buf.pbase();
196 (res_beg[0] !=oss.widen(
'+') && res_beg[0] !=oss.widen(
'-') ))
197 prefix_space = oss.widen(
' ');
199 static_cast<size_type>(specs.
truncate_ - !!prefix_space),
201 mk_str(res, res_beg, res_size, w, oss.fill(), fl,
202 prefix_space, (specs.
pad_scheme_ & format_item_t::centered) !=0 );
209 const Ch * res_beg = buf.pbase();
210 size_type res_size = buf.
pcount();
211 bool prefix_space=
false;
214 (res_beg[0] !=oss.widen(
'+') && res_beg[0] !=oss.widen(
'-') ))
216 if(res_size == static_cast<size_type>(w) && w<=specs.
truncate_ && !prefix_space) {
218 res.assign(res_beg, res_size);
224 res.assign(res_beg, res_size);
242 const Ch * tmp_beg = buf.pbase();
247 if(static_cast<size_type>(w) <= tmp_size) {
249 res.assign(tmp_beg, tmp_size);
253 size_type sz = (
std::min)(res_size + (prefix_space ? 1 : 0), tmp_size);
254 size_type
i = prefix_space;
255 for(; i<sz && tmp_beg[
i] == res[i - (prefix_space ? 1 : 0)]; ++
i) {}
256 if(i>=tmp_size) i=prefix_space;
257 res.assign(tmp_beg, i);
258 std::streamsize
d = w -
static_cast<std::streamsize
>(tmp_size);
260 res.append(static_cast<size_type>( d ), oss2.fill());
261 res.append(tmp_beg+i, tmp_size-i);
262 BOOST_ASSERT(i+(tmp_size-i)+(std::max)(d,(std::streamsize)0)
263 == static_cast<size_type>(w));
275 template<
class Ch,
class Tr,
class Alloc,
class T>
278 if(
self.cur_arg_ >=
self.num_args_) {
283 for(
unsigned long i=0;
i <
self.items_.size(); ++
i) {
284 if(
self.items_[
i].argN_ ==
self.cur_arg_) {
285 put<Ch, Tr, Alloc, T> (
x,
self.items_[
i],
self.items_[
i].res_,
291 template<
class Ch,
class Tr,
class Alloc,
class T>
294 if(
self.dumped_)
self.clear();
295 distribute<Ch, Tr, Alloc, T> (
self,
x);
297 if(
self.bound_.size() != 0) {
298 while(
self.cur_arg_ <
self.num_args_ &&
self.bound_[
self.cur_arg_] )
304 template<
class Ch,
class Tr,
class Alloc,
class T>
inline 315 #endif // BOOST_FORMAT_FEED_ARGS_HPP
group1< T2 > group_last(group2< T1, T2 > const &x)
BOOST_DEDUCED_TYPENAME optional< T >::pointer_const_type get_pointer(optional< T > const &opt)
basic_format< Ch, Tr, Alloc > & feed(basic_format< Ch, Tr, Alloc > &self, T x)
typedef void(APIENTRY *GLDEBUGPROC)(GLenum source
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
void put_last(BOOST_IO_STD basic_ostream< Ch, Tr > &os, const T &x)
void call_put_head(BOOST_IO_STD basic_ostream< Ch, Tr > &os, const void *x)
BOOST_NORETURN void throw_exception(E const &e)
GLdouble GLdouble GLdouble w
GLenum GLuint GLenum GLsizei const GLchar * buf
void put(T x, const format_item< Ch, Tr, Alloc > &specs, typename basic_format< Ch, Tr, Alloc >::string_type &res, typename basic_format< Ch, Tr, Alloc >::internal_streambuf_t &buf, io::detail::locale_t *loc_p=NULL)
group1< T1 > group_head(group2< T1, T2 > const &x)
void put_head(BOOST_IO_STD basic_ostream< Ch, Tr > &os, const put_holder< Ch, Tr > &t)
void(* put_head)(BOOST_IO_STD basic_ostream< Ch, Tr > &os, const void *x)
basic_format< Ch, Tr, Alloc > & feed_impl(basic_format< Ch, Tr, Alloc > &self, T x)
void distribute(basic_format< Ch, Tr, Alloc > &self, T x)
void(* put_last)(BOOST_IO_STD basic_ostream< Ch, Tr > &os, const void *x)
void put_last(BOOST_IO_STD basic_ostream< Ch, Tr > &os, const put_holder< Ch, Tr > &t)
void mk_str(std::basic_string< Ch, Tr, Alloc > &res, const Ch *beg, typename std::basic_string< Ch, Tr, Alloc >::size_type size, std::streamsize w, const Ch fill_char, std::ios_base::fmtflags f, const Ch prefix_space, bool center)
BOOST_IO_STD locale locale_t
void put_head(BOOST_IO_STD basic_ostream< Ch, Tr > &, const T &)
void call_put_last(BOOST_IO_STD basic_ostream< Ch, Tr > &os, const void *x)
#define BOOST_ASSERT(expr)