'\" t
.\"     Title: unicode::linebreak
.\"    Author: Sam Varshavchik
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\"      Date: 11/25/2020
.\"    Manual: Courier Unicode Library
.\"    Source: Courier Unicode Library
.\"  Language: English
.\"
.TH "UNICODE::LINEBREAK" "3" "11/25/2020" "Courier Unicode Library" "Courier Unicode Library"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
unicode::linebreak_callback_base, unicode::linebreak_callback_save_buf, unicode::linebreakc_callback_base, unicode::linebreak_iter, unicode::linebreakc_iter \- unicode line\-breaking rules
.SH "SYNOPSIS"
.sp
.nf
#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));
.fi
.SH "DESCRIPTION"
.PP
unicode::linebreak_callback_base
is a C++ binding for the unicode line\-breaking rule implementation described in
\fBunicode_line_break\fR(3)\&.
.PP
Subclass
unicode::linebreak_callback_base
and implement
callback() that\*(Aqs 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\&.
.PP
callback() should return 0\&. A non\-zero return reports an error, that stops the line\-breaking algorithm\&. See
\fBunicode_line_break\fR(3)
for more information\&.
.PP
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\&.
.PP
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\&.
.PP
set_opts
sets line\-breaking options (see
unicode_lb_set_opts() for more information)\&.
.PP
unicode::linebreak_callback_save_buf
is a subclass that implements
callback() by saving the linebreaks codes into a
std::list\&.
.PP
The
linebreak_iter
template implements an input iterator over
ints\&. The template parameter is an input iterator over
unicode
chars\&. The constructor\*(Aqs 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\&.
.PP
The iterator implements a
set_opts() methods that sets the options for the line\-breaking algorithm\&.
.PP
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\&.
.SH "SEE ALSO"
.PP
\fBcourier-unicode\fR(7),
\fBunicode_line_break\fR(3)\&.
.SH "AUTHOR"
.PP
\fBSam Varshavchik\fR
.RS 4
Author
.RE