E-MailRelay

Classes | Static Public Member Functions | List of all members
G::StringWrap Class Reference

A word-wrap class. More...

`#include <gstringwrap.h>`

## Classes
struct | Config
| Private implementation structure for G::StringWrap. More...
class | WordWrapper
| Private implementation structure for G::StringWrap. More...

## Static Public Member Functions
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, const std::locale &=defaultLocale())
| Does word-wrapping. More...
static std::locale | defaultLocale ()
| Returns a locale with at least the CTYPE and codecvt facets initialised according to the C locale's CTYPE. More...
static std::size_t | wordsize (const std::string &mbcs, const std::locale &)
| Returns the number of wide characters after converting the input string using the locale's codecvt facet. More...

## Detailed Description

A word-wrap class.

Definition at line 36 of file gstringwrap.h.

## Member Function Documentation

## ◆ defaultLocale()

std::locale G::StringWrap::defaultLocale | ( |  | ) |
| static

Returns a locale with at least the CTYPE and codecvt facets initialised according to the C locale's CTYPE.

Returns the classic locale on error.

A motivating use-case is where the gettext() library has been initialised by setting the C locale's CTYPE and MESSAGES facets, meaning that all gettext() strings are automatically converted to the relevant character encoding. If the strings from gettext() are to be word-wrapped accurately then the word-wrapper's CTYPE and codecvt facets need to match the C locale's CTYPE.

Definition at line 180 of file gstringwrap.cpp.

## ◆ wordsize()

std::size_t G::StringWrap::wordsize | ( | const std::string & | mbcs,
|  | const std::locale & | loc
| ) |  |
| static

Returns the number of wide characters after converting the input string using the locale's codecvt facet.

Conversion errors are ignored.

Definition at line 193 of file gstringwrap.cpp.

## ◆ wrap()

std::string G::StringWrap::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`,
|  | const std::locale & | loc = `defaultLocale()`
| ) |  |
| static

Does word-wrapping.

The return value is a string with embedded newlines. If 'preserve_spaces' is true then all space characters between input words that end up in the middle of an output line are preserved. There is no special handling of tabs or carriage returns. The 'first/other' parameters distinguish between the first output line and the rest.

Definition at line 114 of file gstringwrap.cpp.

The documentation for this class was generated from the following files:

- /usr/src/slapt-src-x86_64/network/emailrelay/emailrelay-2.3/src/glib/gstringwrap.h
- /usr/src/slapt-src-x86_64/network/emailrelay/emailrelay-2.3/src/glib/gstringwrap.cpp