10 void wrapAndPrintLine(std::ostream& os,
std::string const&
text,
size_t indent,
size_t suggestedWidth) {
11 char oldFill = os.fill();
13 size_t length =
text.size();
16 size_t startLine = 0
U;
19 size_t startNextSearch = 0
U;
25 if ((length - startLine) <= suggestedWidth) {
26 os << std::setfill(
' ') << std::setw(
indent) <<
"";
30 os <<
text.substr(startLine);
36 size_t pos =
text.find_first_of(
' ', startNextSearch);
39 if (
pos == std::string::npos) {
44 if (startNextSearch != startLine) {
45 os << std::setfill(
' ') << std::setw(
indent) <<
"";
46 os <<
text.substr(startLine, startNextSearch - startLine);
48 startLine = startNextSearch;
50 os << std::setfill(
' ') << std::setw(
indent) <<
"";
51 os <<
text.substr(startLine);
56 if ((
pos + 1
U - startLine) > suggestedWidth) {
61 if (startNextSearch != startLine) {
62 os << std::setfill(
' ') << std::setw(
indent) <<
"";
63 os <<
text.substr(startLine, startNextSearch - startLine);
65 startLine = startNextSearch;
67 if ((
pos + 1
U - startLine) > suggestedWidth) {
68 os << std::setfill(
' ') << std::setw(
indent) <<
"";
69 os <<
text.substr(startLine,
pos + 1
U - startLine);
74 startNextSearch =
pos + 1
U;
100 size_t suggestedWidth) {
101 size_t pos =
text.find_first_of(
'\n');
102 if (
pos == std::string::npos) {
104 wrapAndPrintLine(os,
text,
indent, suggestedWidth);
107 wrapAndPrintLine(os,
text.substr(0,
pos),
indent, suggestedWidth);
134 char oldFill = os.fill();
135 os << std::setfill(
' ') << std::setw(
indentation_) <<
"";
140 char oldFill = os.fill();