10 void wrapAndPrintLine(std::ostream& os,
std::string const&
text,
size_t indent,
size_t suggestedWidth) {
12 char oldFill = os.fill();
14 size_t length = text.size();
17 size_t startLine = 0U;
20 size_t startNextSearch = 0U;
27 if ((length - startLine) <= suggestedWidth) {
28 os << std::setfill(
' ') << std::setw(indent) <<
"";
29 if (startLine == 0) os <<
text;
30 else 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 + 1U - startLine) > suggestedWidth) {
62 if (startNextSearch != startLine) {
63 os << std::setfill(
' ') << std::setw(indent) <<
"";
64 os << text.substr(startLine, startNextSearch - startLine);
66 startLine = startNextSearch;
68 if ((pos + 1U - startLine) > suggestedWidth) {
69 os << std::setfill(
' ') << std::setw(indent) <<
"";
70 os << text.substr(startLine, pos + 1U - startLine);
75 startNextSearch = pos + 1U;
101 size_t suggestedWidth) {
103 size_t pos = text.find_first_of(
'\n');
104 if (pos == std::string::npos) {
106 wrapAndPrintLine(os, text, indent, suggestedWidth);
109 wrapAndPrintLine(os, text.substr(0, pos),
indent, suggestedWidth);
137 char oldFill = os.fill();
138 os << std::setfill(
' ') << std::setw(
indentation_) <<
"";
143 char oldFill = os.fill();