1UNICODE::LINEBREAK(3)       Courier Unicode Library      UNICODE::LINEBREAK(3)
2
3
4

NAME

6       unicode::linebreak_callback_base, unicode::linebreak_callback_save_buf,
7       unicode::linebreakc_callback_base, unicode::linebreak_iter,
8       unicode::linebreakc_iter - unicode line-breaking rules
9

SYNOPSIS

11       #include <courier-unicode.h>
12
13       class linebreak : public unicode::linebreak_callback_base {
14
15       public:
16
17           using unicode::linebreak_callback_base::operator<<;
18           using unicode::linebreak_callback_base::operator();
19           int callback(int linebreak_code)
20           {
21               // ...
22           }
23       };
24
25       char32_t c;
26       std::u32string buf;
27
28       linebreak compute_linebreak;
29
30       compute_linebreak.set_opts(UNICODE_LB_OPT_SYBREAK);
31       compute_linebreak << c;
32
33       compute_linebreak(buf);
34       compute_linebreak(buf.begin(), buf.end());
35
36       compute_linebreak.finish();
37
38       // ...
39
40       unicode::linebreak_callback_save_buf linebreaks;
41
42       std::list<int> lb=linebreaks.lb_buf;
43
44       class linebreakc : public unicode::linebreakc_callback_base {
45
46       public:
47
48           using unicode::linebreak_callback_base::operator<<;
49           using unicode::linebreak_callback_base::operator();
50           int callback(int linebreak_code, char32_t ch)
51           {
52               // ...
53           }
54       };
55
56       // ...
57
58       std::u32string buf;
59
60       typedef unicode::linebreak_iter<std::u32string::const_iterator> iter_t;
61
62       iter_t beg_iter(buf.begin(), buf.end()), end_iter;
63
64       beg_iter.set_opts(UNICODE_LB_OPT_SYBREAK);
65
66       std::vector<int> linebreaks;
67
68       std::copy(beg_iter, end_iter, std::back_insert_iterator<std::vector<int>>(linebreaks));
69
70       // ...
71
72       typedef unicode::linebreakc_iter<std::u32string::const_iterator> iter_t;
73
74       iter_t beg_iter(buf.begin(), buf.end()), end_iter;
75
76       beg_iter.set_opts(UNICODE_LB_OPT_SYBREAK);
77
78       std::vector<std::pair<int, char32_t>> linebreaks;
79
80       std::copy(beg_iter, end_iter, std::back_insert_iterator<std::vector<int>>(linebreaks));
81

DESCRIPTION

83       unicode::linebreak_callback_base is a C++ binding for the unicode
84       line-breaking rule implementation described in unicode_line_break(3).
85
86       Subclass unicode::linebreak_callback_base and implement callback()
87       that's virtually inherited from unicode::linebreak_callback_base. The
88       callback() callback function receives the output values from the
89       line-breaking algorithm, the UNICODE_LB_MANDATORY, UNICODE_LB_NONE, or
90       the UNICODE_LB_ALLOWED value, for each unicode character.
91
92       callback() should return 0. A non-zero return reports an error, that
93       stops the line-breaking algorithm. See unicode_line_break(3) for more
94       information.
95
96       The alternate unicode::linebreakc_callback_base interface uses a
97       virtually inherited callback() that receives two parameters, the
98       line-break code value, and the corresponding unicode character.
99
100       The input unicode characters for the line-breaking algorithm are
101       provided by the << operator, one unicode character at a time; or by the
102       () operator, passing either a container, or a beginning and an ending
103       iterator value for an input sequence of unicode characters.  finish()
104       indicates the end of the unicode character sequence.
105
106       set_opts sets line-breaking options (see unicode_lb_set_opts() for more
107       information).
108
109       unicode::linebreak_callback_save_buf is a subclass that implements
110       callback() by saving the linebreaks codes into a std::list.
111
112       The linebreak_iter template implements an input iterator over ints. The
113       template parameter is an input iterator over unicode chars. The
114       constructor's parameters are a beginning and an ending iterator value
115       for a sequence of char32_t. This constructs the beginning iterator
116       value for a sequence of ints consisting of line-break values
117       (UNICODE_LB_MANDATORY, UNICODE_LB_NONE, or UNICODE_LB_ALLOWED)
118       corresponding to each char32_t in the underlying sequence. The default
119       constructor creates the ending iterator value for the sequence.
120
121       The iterator implements a set_opts() methods that sets the options for
122       the line-breaking algorithm.
123
124       The linebreakc_iter template implements a similar input iterator, with
125       the difference that it ends up iterating over a std::pair of
126       line-breaking values and the corresponding char32_t from the underlying
127       input sequence.
128

SEE ALSO

130       courier-unicode(7), unicode_line_break(3).
131

AUTHOR

133       Sam Varshavchik
134           Author
135
136
137
138Courier Unicode Library           05/31/2022             UNICODE::LINEBREAK(3)
Impressum