From: bangerth Date: Thu, 3 Aug 2006 00:34:29 +0000 (+0000) Subject: Second argument to Utilities::int_to_string can now be omitted, leading to no padding... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c5312181a341ffddf7696bea3868da2b26c2eb7;p=dealii-svn.git Second argument to Utilities::int_to_string can now be omitted, leading to no padding at all. git-svn-id: https://svn.dealii.org/trunk@13580 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/utilities.h b/deal.II/base/include/base/utilities.h index aaec1d9c42..791ab2f51b 100644 --- a/deal.II/base/include/base/utilities.h +++ b/deal.II/base/include/base/utilities.h @@ -43,7 +43,7 @@ namespace Utilities */ std::string int_to_string (const unsigned int i, - const unsigned int digits); + const unsigned int digits = deal_II_numbers::invalid_unsigned_int); /** * Determine how many digits are needed to diff --git a/deal.II/base/source/utilities.cc b/deal.II/base/source/utilities.cc index 310d5106e4..c59741c668 100644 --- a/deal.II/base/source/utilities.cc +++ b/deal.II/base/source/utilities.cc @@ -54,6 +54,12 @@ namespace Utilities int_to_string (const unsigned int i, const unsigned int digits) { + // if second argument is invalid, then do + // not pad the resulting string at all + if (digits == deal_II_numbers::invalid_unsigned_int) + return int_to_string (i, needed_digits(i)); + + AssertThrow ( ! ((digits==1 && i>=10) || (digits==2 && i>=100) || (digits==3 && i>=1000) || diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html index 2090901be2..020989711b 100644 --- a/deal.II/doc/news/changes.html +++ b/deal.II/doc/news/changes.html @@ -343,6 +343,12 @@ inconvenience this causes.

base

    +
  1. New: The second argument to Utilities::int_to_string + can now be omitted, leading to a string that isn't zero padded at all. +
    + (WB 2006/08/02) +

    +
  2. Changed: When there is still a SmartPointer object pointing to another object at the time it is destroyed, this would cause the program to be aborted. However, there are cases where this is not diff --git a/tests/base/utilities_01.cc b/tests/base/utilities_01.cc index cd6556527f..724682a118 100644 --- a/tests/base/utilities_01.cc +++ b/tests/base/utilities_01.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2005 by the deal.II authors +// Copyright (C) 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -25,6 +25,7 @@ void test () { deallog << Utilities::int_to_string (42,4) << std::endl; + deallog << Utilities::int_to_string (42) << std::endl; deallog << Utilities::needed_digits (424) << std::endl; deallog << Utilities::string_to_int (" 413 ") << std::endl; diff --git a/tests/base/utilities_01/cmp/generic b/tests/base/utilities_01/cmp/generic index 5e6f720109..ec35899b28 100644 --- a/tests/base/utilities_01/cmp/generic +++ b/tests/base/utilities_01/cmp/generic @@ -1,5 +1,6 @@ DEAL::0042 +DEAL::42 DEAL::3 DEAL::413 DEAL::1