highlighter application  1.1
HCE project utils : highlighter
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
IcuPlugin.cpp
Go to the documentation of this file.
1 
4 
5 
6 
7 #include <iostream>
8 
9 #include "IcuPlugin.hpp"
10 
11 namespace HCE
12 {
13 
14 namespace component
15 {
16 
17 
21  #define ICU_DISPLAY(string) char charBuf[1000]; \
22  UnicodeString s1( (CHAR_TYPE*)(string.c_str()) ); \
23  s1.extract(0, s1.length(), charBuf, sizeof(charBuf)-1, 0); \
24  charBuf[sizeof(charBuf)-1] = 0; \
25  std::cout << charBuf << std::endl;
26 
27 
29 {
30  ProcessInfo processInfo;
32  _exported.push_back( processInfo );
33 }
34 
35 
37 
38 
40 {
41  _status = U_ZERO_ERROR;
42  _boundary = BreakIterator::createWordInstance( Locale::getUS(), _status );
43  UnicodeString ustr( (/*UChar* */CHAR_TYPE*)lCData._content.c_str(), lCData._content.size() );
44  _boundary->setText( ustr );
45 
46  int32_t start = _boundary->first();
47  for (int32_t end = _boundary->next();
48  end != BreakIterator::DONE;
49  start = end, end = _boundary->next())
50  {
54  //CharacterIterator *strIter = _boundary->getText().clone();
55  //UnicodeString s;
56  //strIter->getText(s);
57  size_t len = end - start;
58  UnicodeString str( ustr/*.getBuffer()*/, start, len );
59  SSTRING token;
60  str.toUTF8String( token );
61  lCData._tokens.push_back( token );
62 
66  lCData._mapOffsets[start] = len;
67  lCData._mapTokens[start] = token;
68 
69  #ifdef _DEBUG_
70  //ICU_DISPLAY( str )
71  std::cout << token << std::endl;
72  #endif
73  }
74 #ifdef _DEBUG_
75  std::cout << "Tokens: " << lCData._tokens.size() << std::endl;
76 #endif
77 }
78 
79 
80 } /* namespace component */
81 
82 } /* namespace HCE */