unicode::linebreak_iter(3) unicode line-breaking rules

Other Alias

unicode::linebreak_callback_base, unicode::linebreak_callback_save_buf, unicode::linebreakc_callback_base, unicode::linebreakc_iter

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)
{
// ...
}
};
unicode_char c;
std::vector<unicode_char> 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, unicode_char ch)
{
// ...
}
};
// ...
std::vector<unicode_char> buf;
typedef unicode::linebreak_iter<std::vector<unicode_char>::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::vector<unicode_char>::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, unicode_char>> 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).

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) 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 unicode_char. 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 unicode_char 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 unicode_char from the underlying input sequence.

AUTHOR

Sam Varshavchik

Author