Boost.Locale
types.hpp
1//
2// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
3//
4// Distributed under the Boost Software License, Version 1.0.
5// https://www.boost.org/LICENSE_1_0.txt
6
7#ifndef BOOST_LOCALE_BOUNDARY_TYPES_HPP_INCLUDED
8#define BOOST_LOCALE_BOUNDARY_TYPES_HPP_INCLUDED
9
10#include <boost/locale/config.hpp>
11#include <cstdint>
12
13#ifdef BOOST_MSVC
14# pragma warning(push)
15# pragma warning(disable : 4275 4251 4231 4660)
16#endif
17
18namespace boost { namespace locale {
19
21 namespace boundary {
28
34 line
35 };
36
40 typedef uint32_t rule_type;
41
45 constexpr rule_type word_none = 0x0000F,
46 word_number = 0x000F0,
47 word_letter = 0x00F00,
48 word_kana = 0x0F000,
49 word_ideo = 0xF0000,
50 word_any = 0xFFFF0,
51 word_letters = 0xFFF00,
52 word_kana_ideo = 0xFF000,
53 word_mask = 0xFFFFF;
55
59 constexpr rule_type line_soft = 0x0F,
60 line_hard = 0xF0,
61 line_any = 0xFF,
62 line_mask = 0xFF;
63
65
70 constexpr rule_type sentence_term = 0x0F,
73 0xF0,
75 sentence_any = 0xFF,
77
79
85 constexpr rule_type character_any = 0xF,
87
89
92 {
93 switch(t) {
94 case character: return character_mask;
95 case word: return word_mask;
96 case sentence: return sentence_mask;
97 case line: return line_mask;
98 }
99 return 0;
100 }
101
103 } // namespace boundary
104}} // namespace boost::locale
105
106#ifdef BOOST_MSVC
107# pragma warning(pop)
108#endif
109
110#endif
constexpr rule_type word_kana
Word that contains kana characters.
Definition: types.hpp:48
boundary_type
This type describes a possible boundary analysis alternatives.
Definition: types.hpp:30
constexpr rule_type line_hard
Hard line break: like break is required (as per CR/LF)
Definition: types.hpp:60
constexpr rule_type word_letters
Any word, excluding numbers but including letters, kana and ideograms.
Definition: types.hpp:51
constexpr rule_type line_soft
Soft line break: optional but not required.
Definition: types.hpp:59
uint32_t rule_type
Flags used with word boundary analysis – the type of the word, line or sentence boundary found.
Definition: types.hpp:40
constexpr rule_type character_mask
Select all character breaking points.
Definition: types.hpp:86
constexpr rule_type word_mask
Full word mask - select all possible variants.
Definition: types.hpp:53
constexpr rule_type word_any
Any word including numbers, 0 is special flag, equivalent to 15.
Definition: types.hpp:50
constexpr rule_type sentence_mask
Select all sentence breaking points.
Definition: types.hpp:76
constexpr rule_type word_none
Not a word, like white space or punctuation mark.
Definition: types.hpp:45
constexpr rule_type character_any
Not in use, just for consistency.
Definition: types.hpp:85
rule_type boundary_rule(boundary_type t)
This function returns the mask that covers all variants for specific boundary type.
Definition: types.hpp:91
constexpr rule_type word_letter
Word that contains letters, excluding kana and ideographic characters.
Definition: types.hpp:47
constexpr rule_type sentence_any
Either first or second sentence break type;.
Definition: types.hpp:75
constexpr rule_type word_kana_ideo
Word that includes kana or ideographic characters.
Definition: types.hpp:52
constexpr rule_type word_number
Word that appear to be a number.
Definition: types.hpp:46
constexpr rule_type line_any
Soft or Hard line break.
Definition: types.hpp:61
constexpr rule_type word_ideo
Word that contains ideographic characters.
Definition: types.hpp:49
constexpr rule_type sentence_term
The sentence was terminated with a sentence terminator like ".", "!" possible followed by hard separa...
Definition: types.hpp:70
constexpr rule_type line_mask
Select all types of line breaks.
Definition: types.hpp:62
constexpr rule_type sentence_sep
The sentence does not contain terminator like ".", "!" but ended with hard separator like CR,...
Definition: types.hpp:72
@ line
Analyse the text for positions suitable for line breaks.
Definition: types.hpp:34
@ sentence
Analyse the text for Find sentence boundaries.
Definition: types.hpp:33
@ word
Analyse the text for word boundaries.
Definition: types.hpp:32
@ character
Analyse the text for character boundaries.
Definition: types.hpp:31
@ boundary
Generate boundary analysis facet.