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

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

- File List
- Globals

UnicodeUtils.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2014 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 public:
16 virtual ~UnicodeUtil();
17
18 public:
20 static bool isAlnum(wchar_t c);
21
23 static bool isAlpha(wchar_t c);
24
26 static bool isDigit(wchar_t c);
27
29 static bool isSpace(wchar_t c);
30
32 static bool isUpper(wchar_t c);
33
35 static bool isLower(wchar_t c);
36
38 static bool isOther(wchar_t c);
39
41 static bool isNonSpacing(wchar_t c);
42
44 static wchar_t toUpper(wchar_t c);
45
47 static wchar_t toLower(wchar_t c);
48 };
49
51 template <typename TYPE>
52 class TranslationResult : public LuceneObject {
53 public:
54 TranslationResult() {
55 result = Array<TYPE>::newInstance(10);
56 length = 0;
57 }
58
59 public:
60 Array<TYPE> result;
61 int32_t length;
62
63 public:
64 void setLength(int32_t length) {
65 if (!result) {
66 result = Array<TYPE>::newInstance((int32_t)(1.5 * (double)length));
67 }
68 if (result.size() < length) {
69 result.resize((int32_t)(1.5 * (double)length));
70 }
71 this->length = length;
72 }
73
74 void copyText(const TranslationResult& other) {
75 setLength(other.length);
76 MiscUtils::arrayCopy(other.result.get(), 0, result.get(), 0, other.length);
77 }
78
79 void copyText(boost::shared_ptr< TranslationResult<TYPE> > other) {
80 copyText(*other);
81 }
82 };
83
84 class LPPAPI UTF8Result : public TranslationResult<uint8_t> {
85 public:
86 virtual ~UTF8Result();
87 };
88
89 class LPPAPI UnicodeResult : public TranslationResult<wchar_t> {
90 public:
91 virtual ~UnicodeResult();
92 };
93
94 }
95
96 #endif
Lucene::Array::size
int32_t size() const
Definition: Array.h:87
Lucene::TranslationResult::length
int32_t length
Definition: UnicodeUtils.h:61
Lucene::UTF8Result
Definition: UnicodeUtils.h:84
Lucene::UnicodeUtil
Definition: UnicodeUtils.h:14
Lucene::TranslationResult::result
Array< TYPE > result
Definition: UnicodeUtils.h:60
Lucene::Array::newInstance
static this_type newInstance(int32_t size)
Definition: Array.h:61
Lucene::Array
Utility template class to handle sharable arrays of simple data types.
Definition: Array.h:47
Lucene::TranslationResult::TranslationResult
TranslationResult()
Definition: UnicodeUtils.h:54
Lucene::TranslationResult::copyText
void copyText(boost::shared_ptr< TranslationResult< TYPE > > other)
Definition: UnicodeUtils.h:79
Lucene::MiscUtils::arrayCopy
static void arrayCopy(SOURCE source, int32_t sourceOffset, DEST dest, int32_t destOffset, int32_t length)
Copy elements from on buffer to another.
Definition: MiscUtils.h:79
LuceneObject.h
Lucene::TranslationResult::copyText
void copyText(const TranslationResult &other)
Definition: UnicodeUtils.h:74
Lucene::TranslationResult::setLength
void setLength(int32_t length)
Definition: UnicodeUtils.h:64
Lucene::Array::resize
void resize(int32_t size)
Definition: Array.h:72
Lucene::LuceneObject
Base class for all Lucene classes.
Definition: LuceneObject.h:31
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::Array::get
TYPE * get() const
Definition: Array.h:83
Lucene::TranslationResult
Utility class that contains utf8 and unicode translations.
Definition: UnicodeUtils.h:52
Lucene::UnicodeResult
Definition: UnicodeUtils.h:89

clucene.sourceforge.net