12 #ifndef MLPACK_CORE_UTIL_HYPHENATE_STRING_HPP 13 #define MLPACK_CORE_UTIL_HYPHENATE_STRING_HPP 27 size_t margin = 80 - padding;
28 if (str.length() < margin)
33 while (pos < str.length())
37 splitpos = str.find(
'\n', pos);
38 if (splitpos == std::string::npos || splitpos > (pos + margin))
41 if (str.length() - pos < margin)
43 splitpos = str.length();
47 splitpos = str.rfind(
' ', margin + pos);
48 if (splitpos <= pos || splitpos == std::string::npos)
49 splitpos = pos + margin;
52 out += str.substr(pos, (splitpos - pos));
53 if (splitpos < str.length())
56 out += std::string(padding,
' ');
60 if (str[pos] ==
' ' || str[pos] ==
'\n')
std::string HyphenateString(const std::string &str, int padding)
* Hyphenate a string or split it onto multiple 80-character lines, with some * amount of padding on...