cprintf_formats.hh (10360:919c02740209) | cprintf_formats.hh (10375:b1bc989611da) |
---|---|
1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 74 unchanged lines hidden (view full) --- 83} 84 85template <typename T> 86inline void 87_format_integer(std::ostream &out, const T &data, Format &fmt) 88{ 89 using namespace std; 90 | 1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 74 unchanged lines hidden (view full) --- 83} 84 85template <typename T> 86inline void 87_format_integer(std::ostream &out, const T &data, Format &fmt) 88{ 89 using namespace std; 90 |
91 ios::fmtflags flags(out.flags()); 92 |
|
91 switch (fmt.base) { 92 case Format::hex: 93 out.setf(std::ios::hex, std::ios::basefield); 94 break; 95 96 case Format::oct: 97 out.setf(std::ios::oct, std::ios::basefield); 98 break; --- 33 unchanged lines hidden (view full) --- 132 133 if (fmt.print_sign) 134 out.setf(std::ios::showpos); 135 136 if (fmt.uppercase) 137 out.setf(std::ios::uppercase); 138 139 out << data; | 93 switch (fmt.base) { 94 case Format::hex: 95 out.setf(std::ios::hex, std::ios::basefield); 96 break; 97 98 case Format::oct: 99 out.setf(std::ios::oct, std::ios::basefield); 100 break; --- 33 unchanged lines hidden (view full) --- 134 135 if (fmt.print_sign) 136 out.setf(std::ios::showpos); 137 138 if (fmt.uppercase) 139 out.setf(std::ios::uppercase); 140 141 out << data; |
142 143 out.flags(flags); |
|
140} 141 142template <typename T> 143inline void 144_format_float(std::ostream &out, const T &data, Format &fmt) 145{ 146 using namespace std; 147 | 144} 145 146template <typename T> 147inline void 148_format_float(std::ostream &out, const T &data, Format &fmt) 149{ 150 using namespace std; 151 |
152 ios::fmtflags flags(out.flags()); 153 |
|
148 switch (fmt.float_format) { 149 case Format::scientific: 150 if (fmt.precision != -1) { 151 if (fmt.width > 0) 152 out.width(fmt.width); 153 154 if (fmt.precision == 0) 155 fmt.precision = 1; --- 28 unchanged lines hidden (view full) --- 184 185 if (fmt.width > 0) 186 out.width(fmt.width); 187 188 break; 189 } 190 191 out << data; | 154 switch (fmt.float_format) { 155 case Format::scientific: 156 if (fmt.precision != -1) { 157 if (fmt.width > 0) 158 out.width(fmt.width); 159 160 if (fmt.precision == 0) 161 fmt.precision = 1; --- 28 unchanged lines hidden (view full) --- 190 191 if (fmt.width > 0) 192 out.width(fmt.width); 193 194 break; 195 } 196 197 out << data; |
198 199 out.flags(flags); |
|
192} 193 194template <typename T> 195inline void 196_format_string(std::ostream &out, const T &data, Format &fmt) 197{ 198 using namespace std; 199 --- 162 unchanged lines hidden --- | 200} 201 202template <typename T> 203inline void 204_format_string(std::ostream &out, const T &data, Format &fmt) 205{ 206 using namespace std; 207 --- 162 unchanged lines hidden --- |