Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / locale / doc / html / boundary_8cpp-example.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5 <meta http-equiv="X-UA-Compatible" content="IE=9"/>
6 <title>Boost.Locale: boundary.cpp</title>
7
8 <link href="tabs.css" rel="stylesheet" type="text/css"/>
9 <link href="doxygen.css" rel="stylesheet" type="text/css" />
10 <link href="navtree.css" rel="stylesheet" type="text/css"/>
11 <script type="text/javascript" src="jquery.js"></script>
12 <script type="text/javascript" src="resize.js"></script>
13 <script type="text/javascript" src="navtree.js"></script>
14 <script type="text/javascript">
15   $(document).ready(initResizable);
16 </script>
17
18
19 </head>
20 <body>
21 <div id="top"><!-- do not remove this div! -->
22
23
24 <div id="titlearea">
25 <table cellspacing="0" cellpadding="0">
26  <tbody>
27  <tr style="height: 56px;">
28   
29   <td id="projectlogo"><img alt="Logo" src="boost-small.png"/></td>
30   
31   
32   <td style="padding-left: 0.5em;">
33    <div id="projectname">Boost.Locale
34    
35    </div>
36    
37   </td>
38   
39   
40   
41  </tr>
42  </tbody>
43 </table>
44 </div>
45
46 <!-- Generated by Doxygen 1.7.6.1 -->
47   <div id="navrow1" class="tabs">
48     <ul class="tablist">
49       <li><a href="index.html"><span>Main&#160;Page</span></a></li>
50       <li><a href="modules.html"><span>Modules</span></a></li>
51       <li><a href="namespaces.html"><span>Namespaces</span></a></li>
52       <li><a href="annotated.html"><span>Classes</span></a></li>
53       <li><a href="files.html"><span>Files</span></a></li>
54       <li><a href="examples.html"><span>Examples</span></a></li>
55     </ul>
56   </div>
57 </div>
58 <div id="side-nav" class="ui-resizable side-nav-resizable">
59   <div id="nav-tree">
60     <div id="nav-tree-contents">
61     </div>
62   </div>
63   <div id="splitbar" style="-moz-user-select:none;" 
64        class="ui-resizable-handle">
65   </div>
66 </div>
67 <script type="text/javascript">
68   initNavTree('boundary_8cpp-example.html','');
69 </script>
70 <div id="doc-content">
71 <div class="header">
72   <div class="headertitle">
73 <div class="title">boundary.cpp</div>  </div>
74 </div><!--header-->
75 <div class="contents">
76 <p>Example of using segment_index</p>
77 <div class="fragment"><pre class="fragment"><span class="comment">//</span>
78 <span class="comment">//  Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)</span>
79 <span class="comment">//</span>
80 <span class="comment">//  Distributed under the Boost Software License, Version 1.0. (See</span>
81 <span class="comment">//  accompanying file LICENSE_1_0.txt or copy at</span>
82 <span class="comment">//  http://www.boost.org/LICENSE_1_0.txt)</span>
83 <span class="comment">//</span>
84 <span class="preprocessor">#include &lt;boost/locale.hpp&gt;</span>
85 <span class="preprocessor">#include &lt;iostream&gt;</span>
86 <span class="preprocessor">#include &lt;cassert&gt;</span>
87 <span class="preprocessor">#include &lt;ctime&gt;</span>
88
89 <span class="keywordtype">int</span> main()
90 {
91     <span class="keyword">using namespace </span>boost::locale;
92     <span class="keyword">using namespace </span>std;
93
94     <a name="_a0"></a><a class="code" href="classboost_1_1locale_1_1generator.html" title="the major class used for locale generation">generator</a> gen;
95     <span class="comment">// Make system default locale global</span>
96     std::locale loc = gen(<span class="stringliteral">&quot;&quot;</span>);
97     locale::global(loc); 
98     cout.imbue(loc);
99     
100
101     <span class="keywordtype">string</span> text=<span class="stringliteral">&quot;Hello World! あにま! Linux2.6 and Windows7 is word and number. שָלוֹם עוֹלָם!&quot;</span>;
102
103     cout&lt;&lt;text&lt;&lt;endl;
104
105     <a name="_a1"></a><a class="code" href="classboost_1_1locale_1_1boundary_1_1segment__index.html" title="This class holds an index of segments in the text range and allows to iterate over them...">boundary::ssegment_index</a> index(<a name="a2"></a><a class="code" href="group__boundary.html#gga15de9963ce9bb6037c8525901dfbf641a99aad8b8a5e25baa9f695abe5e574bb6" title="Analyse the text for word boundaries.">boundary::word</a>,text.begin(),text.end());
106     <a class="code" href="group__boundary.html#gaf7a775e77dbbca3495e11d646df96fd2">boundary::ssegment_index::iterator</a> p,e;
107
108     <span class="keywordflow">for</span>(p=index.begin(),e=index.end();p!=e;++p) {
109         cout&lt;&lt;<span class="stringliteral">&quot;Part [&quot;</span>&lt;&lt;*p&lt;&lt;<span class="stringliteral">&quot;] has &quot;</span>;
110         <span class="keywordflow">if</span>(p-&gt;rule() &amp; <a name="a3"></a><a class="code" href="group__boundary.html#gaac78a3a6b9e671e253a2591cb56a479b" title="Word that appear to be a number.">boundary::word_number</a>)
111             cout&lt;&lt;<span class="stringliteral">&quot;number(s) &quot;</span>;
112         <span class="keywordflow">if</span>(p-&gt;rule() &amp; <a name="a4"></a><a class="code" href="group__boundary.html#ga8b7e6ce2fcb185845fa85a1a4c42b3c4" title="Word that contains letters, excluding kana and ideographic characters.">boundary::word_letter</a>)
113             cout&lt;&lt;<span class="stringliteral">&quot;letter(s) &quot;</span>;
114         <span class="keywordflow">if</span>(p-&gt;rule() &amp; <a name="a5"></a><a class="code" href="group__boundary.html#ga52d8c63e1f3f8c898c645352206a78ef" title="Word that contains kana characters.">boundary::word_kana</a>)
115             cout&lt;&lt;<span class="stringliteral">&quot;kana character(s) &quot;</span>;
116         <span class="keywordflow">if</span>(p-&gt;rule() &amp; <a name="a6"></a><a class="code" href="group__boundary.html#ga705ab96f9e62810c8ed977c90d404ef8" title="Word that contains ideographic characters.">boundary::word_ideo</a>)
117             cout&lt;&lt;<span class="stringliteral">&quot;ideographic character(s) &quot;</span>;
118         <span class="keywordflow">if</span>(p-&gt;rule() &amp; <a name="a7"></a><a class="code" href="group__boundary.html#ga90cf4f01b95658f659685377226677e7" title="Not a word, like white space or punctuation mark.">boundary::word_none</a>)
119             cout&lt;&lt;<span class="stringliteral">&quot;no word characters&quot;</span>;
120         cout&lt;&lt;endl;
121     }
122
123     index.<a name="a8"></a><a class="code" href="group__boundary.html#gafa2a756b10d3522743204b45b794bb3e">map</a>(<a name="a9"></a><a class="code" href="group__boundary.html#gga15de9963ce9bb6037c8525901dfbf641ae80c964112541d88af9b875dafb6605d" title="Analyse the text for character boundaries.">boundary::character</a>,text.begin(),text.end());
124
125     <span class="keywordflow">for</span>(p=index.begin(),e=index.end();p!=e;++p) {
126         cout&lt;&lt;<span class="stringliteral">&quot;|&quot;</span> &lt;&lt;*p ;
127     }
128     cout&lt;&lt;<span class="stringliteral">&quot;|\n\n&quot;</span>;
129
130     index.map(<a name="a10"></a><a class="code" href="group__boundary.html#gga15de9963ce9bb6037c8525901dfbf641a72895419fdd7219b3695cf0abd602ea4" title="Analyse the text for positions suitable for line breaks.">boundary::line</a>,text.begin(),text.end());
131
132     <span class="keywordflow">for</span>(p=index.begin(),e=index.end();p!=e;++p) {
133         cout&lt;&lt;<span class="stringliteral">&quot;|&quot;</span> &lt;&lt;*p ;
134     }
135     cout&lt;&lt;<span class="stringliteral">&quot;|\n\n&quot;</span>;
136
137     index.map(<a name="a11"></a><a class="code" href="group__boundary.html#gga15de9963ce9bb6037c8525901dfbf641a88aa1509eace7589f5df87d4694871e9" title="Analyse the text for Find sentence boundaries.">boundary::sentence</a>,text.begin(),text.end());
138
139     <span class="keywordflow">for</span>(p=index.begin(),e=index.end();p!=e;++p) {
140         cout&lt;&lt;<span class="stringliteral">&quot;|&quot;</span> &lt;&lt;*p ;
141     }
142     cout&lt;&lt;<span class="stringliteral">&quot;|\n\n&quot;</span>;
143     
144 }
145
146 <span class="comment">// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4</span>
147
148 <span class="comment">// boostinspect:noascii</span>
149 </pre></div> </div><!-- contents -->
150 </div><!-- contents -->
151 </div>
152   <div id="nav-path" class="navpath">
153     <ul>
154
155     <li class="footer">
156 &copy; Copyright 2009-2012 Artyom Beilis,  Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License</a>, Version 1.0.
157     </li>
158    </ul>
159  </div>
160
161
162 </body>
163 </html>