Lucene++ - a full-featured, c++ search engine
API Documentation

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
UnicodeUtils.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2011 Alan Wright. All rights reserved.
3 // Distributable under the terms of either the Apache License (Version 2.0)
4 // or the GNU Lesser General Public License.
6
7 #ifndef UNICODEUTILS_H
8 #define UNICODEUTILS_H
9
10 #include "LuceneObject.h"
11
12 namespace Lucene
13 {
14 class LPPAPI UnicodeUtil
15 {
16 public:
17 virtual ~UnicodeUtil();
18
19 public:
21 static bool isAlnum(wchar_t c);
22
24 static bool isAlpha(wchar_t c);
25
27 static bool isDigit(wchar_t c);
28
30 static bool isSpace(wchar_t c);
31
33 static bool isUpper(wchar_t c);
34
36 static bool isLower(wchar_t c);
37
39 static bool isOther(wchar_t c);
40
42 static bool isNonSpacing(wchar_t c);
43
45 static wchar_t toUpper(wchar_t c);
46
48 static wchar_t toLower(wchar_t c);
49 };
50
52 template <typename TYPE>
53 class TranslationResult : public LuceneObject
54 {
55 public:
56 TranslationResult()
57 {
58 result = Array<TYPE>::newInstance(10);
59 length = 0;
60 }
61
62 public:
63 Array<TYPE> result;
64 int32_t length;
65
66 public:
67 void setLength(int32_t length)
68 {
69 if (!result)
70 result = Array<TYPE>::newInstance((int32_t)(1.5 * (double)length));
71 if (result.size() < length)
72 result.resize((int32_t)(1.5 * (double)length));
73 this->length = length;
74 }
75
76 void copyText(const TranslationResult& other)
77 {
78 setLength(other.length);
79 MiscUtils::arrayCopy(other.result.get(), 0, result.get(), 0, other.length);
80 }
81
82 void copyText(boost::shared_ptr< TranslationResult<TYPE> > other)
83 {
84 copyText(*other);
85 }
86 };
87
88 class LPPAPI UTF8Result : public TranslationResult<uint8_t>
89 {
90 public:
91 virtual ~UTF8Result();
92 };
93
94 class LPPAPI UnicodeResult : public TranslationResult<wchar_t>
95 {
96 public:
97 virtual ~UnicodeResult();
98 };
99 }
100
101 #endif

clucene.sourceforge.net