---
name: "unicode::linebreak_callback_base"
section: "3"
platform: "linux"
package: "libcourier-unicode-dev"
version: "2.3.2-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/unicode::linebreak_callback_base"
---

# unicode::linebreak\_callback\_base(3)

unicode line-breaking rules

## NAME

unicode::linebreak\_callback\_base, unicode::linebreak\_callback\_save\_buf, unicode::linebreakc\_callback\_base, unicode::linebreak\_iter, unicode::linebreakc\_iter - unicode line-breaking rules

## SYNOPSIS

```
#include <courier-unicode.h>
class linebreak : public unicode::linebreak_callback_base {
public:
    using unicode::linebreak_callback_base::operator<<;
    using unicode::linebreak_callback_base::operator();
    int callback(int linebreak_code)
    {
        // ...
    }
};
char32_t c;
std::u32string buf;
linebreak compute_linebreak;
compute_linebreak.set_opts(UNICODE_LB_OPT_SYBREAK);
compute_linebreak << c;
compute_linebreak(buf);
compute_linebreak(buf.begin(), buf.end());
compute_linebreak.finish();
// ...
unicode::linebreak_callback_save_buf linebreaks;
std::list<int> lb=linebreaks.lb_buf;
class linebreakc : public unicode::linebreakc_callback_base {
public:
    using unicode::linebreak_callback_base::operator<<;
    using unicode::linebreak_callback_base::operator();
    int callback(int linebreak_code, char32_t ch)
    {
        // ...
    }
};
// ...
std::u32string buf;
typedef unicode::linebreak_iter<std::u32string::const_iterator> iter_t;
iter_t beg_iter(buf.begin(), buf.end()), end_iter;
beg_iter.set_opts(UNICODE_LB_OPT_SYBREAK);
std::vector<int> linebreaks;
std::copy(beg_iter, end_iter, std::back_insert_iterator<std::vector<int>>(linebreaks));
// ...
typedef unicode::linebreakc_iter<std::u32string::const_iterator> iter_t;
iter_t beg_iter(buf.begin(), buf.end()), end_iter;
beg_iter.set_opts(UNICODE_LB_OPT_SYBREAK);
std::vector<std::pair<int, char32_t>> linebreaks;
std::copy(beg_iter, end_iter, std::back_insert_iterator<std::vector<int>>(linebreaks));
```

## DESCRIPTION

unicode::linebreak\_callback\_base is a C++ binding for the unicode line-breaking rule implementation described in [**unicode\_line\_break**(3)](/unicode_line_break/3.md).

Subclass unicode::linebreak\_callback\_base and implement callback() that's virtually inherited from unicode::linebreak\_callback\_base. The callback() callback function receives the output values from the line-breaking algorithm, the UNICODE\_LB\_MANDATORY, UNICODE\_LB\_NONE, or the UNICODE\_LB\_ALLOWED value, for each unicode character.

callback() should return 0. A non-zero return reports an error, that stops the line-breaking algorithm. See [**unicode\_line\_break**(3)](/unicode_line_break/3.md) for more information.

The alternate unicode::linebreakc\_callback\_base interface uses a virtually inherited callback() that receives two parameters, the line-break code value, and the corresponding unicode character.

The input unicode characters for the line-breaking algorithm are provided by the \<\< operator, one unicode character at a time; or by the () operator, passing either a container, or a beginning and an ending iterator value for an input sequence of unicode characters. finish() indicates the end of the unicode character sequence.

set\_opts sets line-breaking options (see unicode\_lb\_set\_opts() for more information).

unicode::linebreak\_callback\_save\_buf is a subclass that implements callback() by saving the linebreaks codes into a std::list.

The linebreak\_iter template implements an input iterator over ints. The template parameter is an input iterator over unicode chars. The constructor's parameters are a beginning and an ending iterator value for a sequence of char32\_t. This constructs the beginning iterator value for a sequence of ints consisting of line-break values (UNICODE\_LB\_MANDATORY, UNICODE\_LB\_NONE, or UNICODE\_LB\_ALLOWED) corresponding to each char32\_t in the underlying sequence. The default constructor creates the ending iterator value for the sequence.

The iterator implements a set\_opts() methods that sets the options for the line-breaking algorithm.

The linebreakc\_iter template implements a similar input iterator, with the difference that it ends up iterating over a std::pair of line-breaking values and the corresponding char32\_t from the underlying input sequence.

## SEE ALSO

[**courier-unicode**(7)](/courier-unicode/7.md), [**unicode\_line\_break**(3)](/unicode_line_break/3.md).

## AUTHOR

**Sam Varshavchik**

Author
