#include <wordwrap.h>
wibble::text::Wrap takes a string and splits it in lines of the give length with proper word wrapping.
Example:
WordWrap ww("The quick brown fox jumps over the lazy dog"); ww.get(5); // Returns "The" ww.get(14); // Returns "quick brown" ww.get(3); // Returns "fox" // A line always gets some text, to avoid looping indefinitely in case of // words that are too long. Words that are too long are split crudely. ww.get(2); // Returns "ju" ww.get(90); // Returns "mps over the lazy dog"
Public Member Functions | |
| WordWrap (const std::string &s) | |
| Creates a new word wrapper that takes data from the given string. | |
| void | restart () |
| Rewind the word wrapper, restarting the output from the beginning of the string. | |
| bool | hasData () const |
| Returns true if there is still data to be read in the string. | |
| std::string | get (unsigned int width) |
Get a line of text from the string, wrapped to a maximum of width characters. | |
| wibble::text::WordWrap::WordWrap | ( | const std::string & | s | ) | [inline] |
Creates a new word wrapper that takes data from the given string.
| void wibble::text::WordWrap::restart | ( | ) | [inline] |
Rewind the word wrapper, restarting the output from the beginning of the string.
| bool wibble::text::WordWrap::hasData | ( | ) | const [inline] |
Returns true if there is still data to be read in the string.
| string wibble::text::WordWrap::get | ( | unsigned int | width | ) |
Get a line of text from the string, wrapped to a maximum of width characters.
1.5.6