E-MailRelay
gstringwrap.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2024 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file gstringwrap.h
19///
20
21#ifndef G_STRING_WRAP_H
22#define G_STRING_WRAP_H
23
24#include "gdef.h"
25#include "gstringview.h"
26#include <string>
27
28namespace G
29{
30 class StringWrap ;
31}
32
33//| \class G::StringWrap
34/// A word-wrap class.
35///
37{
38public:
39 static std::string wrap( const std::string & text ,
40 const std::string & prefix_first , const std::string & prefix_other ,
41 std::size_t width_first = 70U , std::size_t width_other = 0U ,
42 bool preserve_spaces = false ) ;
43 ///< Does word-wrapping of UTF-8 text. The return value is a string
44 ///< with embedded newlines. If 'preserve_spaces' is true then all
45 ///< space characters between input words that end up in the middle
46 ///< of an output line are preserved. There is no special handling
47 ///< of tabs or carriage returns. The 'first/other' parameters
48 ///< distinguish between the first output line and the rest.
49
50 static std::size_t wordsize( const std::string & ) ;
51 ///< Returns the number of characters in UTF-8 text.
52
53public:
54 StringWrap() = delete ;
55} ;
56
57#endif
A word-wrap class.
Definition: gstringwrap.h:37
static std::size_t wordsize(const std::string &)
Returns the number of characters in UTF-8 text.
static std::string wrap(const std::string &text, const std::string &prefix_first, const std::string &prefix_other, std::size_t width_first=70U, std::size_t width_other=0U, bool preserve_spaces=false)
Does word-wrapping of UTF-8 text.
Low-level classes.
Definition: garg.h:36