X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=blobdiff_plain;f=pv%2Futil.cpp;h=c5f9c832ef44be87034826df96fa7d79f42e9e03;hp=4a32147d80d1501a5401ee52744ad2911ae661ff;hb=6f925ba9d6faf1077b73c5a5808259576081716a;hpb=3ccf0f7f5b1b31ac628a983a2becee6f4c4c1507 diff --git a/pv/util.cpp b/pv/util.cpp index 4a32147..c5f9c83 100644 --- a/pv/util.cpp +++ b/pv/util.cpp @@ -14,22 +14,28 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * along with this program; if not, see . */ #include "util.hpp" #include -#include - +#include #include #include #include #include +using std::fixed; +using std::max; +using std::ostringstream; +using std::setfill; +using std::setprecision; +using std::showpos; +using std::string; + using namespace Qt; namespace pv { @@ -84,24 +90,18 @@ static QTextStream& operator<<(QTextStream& stream, const Timestamp& t) int precision = stream.realNumberPrecision(); - std::ostringstream ss; - ss << std::fixed; + ostringstream ss; + ss << fixed; - if (stream.numberFlags() & QTextStream::ForceSign) { - ss << std::showpos; - } + if (stream.numberFlags() & QTextStream::ForceSign) + ss << showpos; - if (0 == precision) { - ss - << std::setprecision(1) - << round(t); - } else { - ss - << std::setprecision(precision) - << t; - } + if (0 == precision) + ss << setprecision(1) << round(t); + else + ss << setprecision(precision) << t; - std::string str(ss.str()); + string str(ss.str()); if (0 == precision) { // remove the separator and the unwanted decimal place str.resize(str.size() - 2); @@ -165,7 +165,7 @@ QString format_time_si_adjusted( const unsigned int relative_prec = (prefix >= SIPrefix::none) ? precision : - std::max((int)(precision - prefix_order), 0); + max((int)(precision - prefix_order), 0); return format_time_si(t, prefix, relative_prec, unit, sign); } @@ -220,13 +220,9 @@ QString format_time_minutes(const Timestamp& t, signed precision, bool sign) const Timestamp fraction = fabs(t) - whole_seconds; - std::ostringstream ss; - ss - << std::fixed - << std::setprecision(precision) - << std::setfill('0') - << fraction; - std::string fs = ss.str(); + ostringstream ss; + ss << fixed << setprecision(precision) << setfill('0') << fraction; + string fs = ss.str(); // Copy all digits, inserting spaces as unit separators for (int i = 1; i <= precision; i++) {