1 /* __gmp_doprnt_integer_ios -- integer formatted output to an ostream.
3 THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST
4 CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
5 FUTURE GNU MP RELEASES.
7 Copyright 2001 Free Software Foundation, Inc.
9 This file is part of the GNU MP Library.
11 The GNU MP Library is free software; you can redistribute it and/or modify
12 it under the terms of the GNU Lesser General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or (at your
14 option) any later version.
16 The GNU MP Library is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19 License for more details.
21 You should have received a copy of the GNU Lesser General Public License
22 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
25 #include <cstdarg> /* for va_list and hence doprnt_funs_t */
26 #include <cstring> /* for strlen */
34 /* The gmp_asprintf support routines never give an error, so
35 __gmp_doprnt_integer shouldn't fail and it's return can just be checked
39 __gmp_doprnt_integer_ostream (ostream &o, struct doprnt_params_t *p,
42 struct gmp_asprintf_t d;
46 /* don't show leading zeros the way printf does */
49 GMP_ASPRINTF_T_INIT (d, &result);
50 ret = __gmp_doprnt_integer (&__gmp_asprintf_funs_noformat, &d, p, s);
52 __gmp_asprintf_final (&d);
53 (*__gmp_free_func) (s, strlen(s)+1);
55 gmp_allocated_string t (result);
56 return o.write (t.str, t.len);