From aa5928a79ca13945f33c49f83bf9d4df0a0843b7 Mon Sep 17 00:00:00 2001 From: prill Date: Thu, 12 Oct 2006 15:51:16 +0000 Subject: [PATCH] Made whitespace character a default delimiter for utility function break_text_into_lines() which can also be changed to other delimiters. git-svn-id: https://svn.dealii.org/trunk@13994 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/utilities.h | 12 +++++++----- deal.II/base/source/utilities.cc | 11 ++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/deal.II/base/include/base/utilities.h b/deal.II/base/include/base/utilities.h index 791ab2f51b..f32f9cb710 100644 --- a/deal.II/base/include/base/utilities.h +++ b/deal.II/base/include/base/utilities.h @@ -89,14 +89,16 @@ namespace Utilities * something, and try to break it into * individual lines of text at most @p * width characters wide, by breaking at - * spaces in the text. If this is not - * possible, return the shortest lines than - * are longer than @p width. + * positions marked by @p delimiter in the text. + * If this is not possible, return the shortest + * lines than are longer than @p width. + * The default value of the delimiter is a + * space character. */ std::vector break_text_into_lines (const std::string &original_text, - const unsigned int width); - + const unsigned int width, + const char delimiter = ' '); /** * Teturn true if the given pattern diff --git a/deal.II/base/source/utilities.cc b/deal.II/base/source/utilities.cc index c59741c668..6f467c250c 100644 --- a/deal.II/base/source/utilities.cc +++ b/deal.II/base/source/utilities.cc @@ -180,13 +180,14 @@ namespace Utilities std::vector break_text_into_lines (const std::string &original_text, - const unsigned int width) + const unsigned int width, + const char delimiter) { std::string text = original_text; std::vector lines; // remove trailing spaces - while ((text.length() != 0) && (text[text.length()-1] == ' ')) + while ((text.length() != 0) && (text[text.length()-1] == delimiter)) text.erase(text.length()-1,1); // then split the text into lines @@ -194,7 +195,7 @@ namespace Utilities { // in each iteration, first remove // leading spaces - while ((text.length() != 0) && (text[0] == ' ')) + while ((text.length() != 0) && (text[0] == delimiter)) text.erase(0, 1); // if we can fit everything into one @@ -212,7 +213,7 @@ namespace Utilities // that we can break around there int location = std::min(width,text.length()-1); for (; location>=0; --location) - if (text[location] == ' ') + if (text[location] == delimiter) break; // if there are no spaces, then try if @@ -221,7 +222,7 @@ namespace Utilities for (location = std::min(width,text.length()-1); location(text.length()); ++location) - if (text[location] == ' ') + if (text[location] == delimiter) break; // now take the text up to the found -- 2.39.5