tlx
word_wrap.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * tlx/string/word_wrap.hpp
3  *
4  * Part of tlx - http://panthema.net/tlx
5  *
6  * Copyright (C) 2016-2017 Timo Bingmann <tb@panthema.net>
7  *
8  * All rights reserved. Published under the Boost Software License, Version 1.0
9  ******************************************************************************/
10 
11 #ifndef TLX_STRING_WORD_WRAP_HEADER
12 #define TLX_STRING_WORD_WRAP_HEADER
13 
14 #include <string>
15 
16 namespace tlx {
17 
18 //! \addtogroup tlx_string
19 //! \{
20 
21 /*!
22  * Try to wrap a string to 80 columns without split words. All newlines are
23  * kept, new newline characters are inserted only at spaces, hence, words are
24  * never split. If words longer than 80 columns occur they are NOT broken.
25  */
26 std::string word_wrap(const std::string& str, unsigned int wrap = 80);
27 
28 //! \}
29 
30 } // namespace tlx
31 
32 #endif // !TLX_STRING_WORD_WRAP_HEADER
33 
34 /******************************************************************************/
std::string word_wrap(const std::string &str, unsigned int wrap)
Try to wrap a string to 80 columns without split words.
Definition: word_wrap.cpp:22