liuxiaolong
2021-07-20 58d904a328c0d849769b483e901a0be9426b8209
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//
//  Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
//
//  Distributed under the Boost Software License, Version 1.0. (See
//  accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_LOCALE_BOUNDARY_TYPES_HPP_INCLUDED
#define BOOST_LOCALE_BOUNDARY_TYPES_HPP_INCLUDED
 
#include <boost/locale/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/assert.hpp>
#ifdef BOOST_MSVC
#  pragma warning(push)
#  pragma warning(disable : 4275 4251 4231 4660)
#endif
 
 
namespace boost {
 
    namespace locale {
        
        ///
        /// \brief This namespase contains all operations required for boundary analysis of text
        ///
        namespace boundary {
            ///
            /// \defgroup boundary Boundary Analysis
            ///
            /// This module contains all operations required for boundary analysis of text: character, word, like and sentence boundaries
            ///
            /// @{
            ///
 
            ///
            /// This type describes a possible boundary analysis alternatives.
            ///
            enum boundary_type {
                character,  ///< Analyse the text for character boundaries
                word,       ///< Analyse the text for word boundaries
                sentence,   ///< Analyse the text for Find sentence boundaries
                line        ///< Analyse the text for positions suitable for line breaks
            };
 
            ///
            /// \brief Flags used with word boundary analysis -- the type of the word, line or sentence boundary found.
            ///
            /// It is a bit-mask that represents various combinations of rules used to select this specific boundary.
            ///
            typedef uint32_t rule_type;
 
            ///
            /// \anchor bl_boundary_word_rules 
            /// \name Flags that describe a type of word selected
            /// @{
            static const rule_type
                word_none       =  0x0000F,   ///< Not a word, like white space or punctuation mark
                word_number     =  0x000F0,   ///< Word that appear to be a number
                word_letter     =  0x00F00,   ///< Word that contains letters, excluding kana and ideographic characters 
                word_kana       =  0x0F000,   ///< Word that contains kana characters
                word_ideo       =  0xF0000,   ///< Word that contains ideographic characters
                word_any        =  0xFFFF0,   ///< Any word including numbers, 0 is special flag, equivalent to 15
                word_letters    =  0xFFF00,   ///< Any word, excluding numbers but including letters, kana and ideograms.
                word_kana_ideo  =  0xFF000,   ///< Word that includes kana or ideographic characters
                word_mask       =  0xFFFFF;   ///< Full word mask - select all possible variants
            /// @}
 
            ///
            /// \anchor bl_boundary_line_rules 
            /// \name Flags that describe a type of line break
            /// @{
            static const rule_type 
                line_soft       =  0x0F,   ///< Soft line break: optional but not required
                line_hard       =  0xF0,   ///< Hard line break: like break is required (as per CR/LF)
                line_any        =  0xFF,   ///< Soft or Hard line break
                line_mask       =  0xFF;   ///< Select all types of line breaks
            
            /// @}
            
            ///
            /// \anchor bl_boundary_sentence_rules 
            /// \name Flags that describe a type of sentence break
            ///
            /// @{
            static const rule_type
                sentence_term   =  0x0F,    ///< \brief The sentence was terminated with a sentence terminator 
                                            ///  like ".", "!" possible followed by hard separator like CR, LF, PS
                sentence_sep    =  0xF0,    ///< \brief The sentence does not contain terminator like ".", "!" but ended with hard separator
                                            ///  like CR, LF, PS or end of input.
                sentence_any    =  0xFF,    ///< Either first or second sentence break type;.
                sentence_mask   =  0xFF;    ///< Select all sentence breaking points
 
            ///@}
 
            ///
            /// \name  Flags that describe a type of character break.
            ///
            /// At this point break iterator does not distinguish different
            /// kinds of characters so it is used for consistency.
            ///@{
            static const rule_type
                character_any   =  0xF,     ///< Not in use, just for consistency
                character_mask  =  0xF;     ///< Select all character breaking points
 
            ///@}
 
            ///
            /// This function returns the mask that covers all variants for specific boundary type
            ///
            inline rule_type boundary_rule(boundary_type t)
            {
                switch(t) {
                case character: return character_mask;
                case word:      return word_mask;
                case sentence:  return sentence_mask;
                case line:      return line_mask;
                default:        return 0;
                }
            }
 
            ///
            ///@}
            ///
 
        } // boundary
    } // locale
} // boost
            
 
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
 
#endif
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4