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


Loading...
Searching...
No Matches
UnicodeUtils.h
Go to the documentation of this file.
1
2// 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
12namespace Lucene {
13
14class LPPAPI UnicodeUtil {
15public:
16 virtual ~UnicodeUtil();
17
18public:
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
51template <typename TYPE>
53public:
58
59public:
61 int32_t length;
62
63public:
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
84class LPPAPI UTF8Result : public TranslationResult<uint8_t> {
85public:
86 virtual ~UTF8Result();
87};
88
89class LPPAPI UnicodeResult : public TranslationResult<wchar_t> {
90public:
91 virtual ~UnicodeResult();
92};
93
94}
95
96#endif
Utility template class to handle sharable arrays of simple data types.
Definition Array.h:47
static this_type newInstance(int32_t size)
Definition Array.h:61
Base class for all Lucene classes.
Definition LuceneObject.h:31
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
Utility class that contains utf8 and unicode translations.
Definition UnicodeUtils.h:52
TranslationResult()
Definition UnicodeUtils.h:54
void setLength(int32_t length)
Definition UnicodeUtils.h:64
int32_t length
Definition UnicodeUtils.h:61
void copyText(boost::shared_ptr< TranslationResult< TYPE > > other)
Definition UnicodeUtils.h:79
void copyText(const TranslationResult &other)
Definition UnicodeUtils.h:74
Array< TYPE > result
Definition UnicodeUtils.h:60
Definition UnicodeUtils.h:84
virtual ~UTF8Result()
Definition UnicodeUtils.h:89
Definition UnicodeUtils.h:14
static bool isAlpha(wchar_t c)
Return true if supplied character is alphabetic.
static bool isAlnum(wchar_t c)
Return true if supplied character is alpha-numeric.
static bool isOther(wchar_t c)
Return true if supplied character is other type of letter.
static bool isNonSpacing(wchar_t c)
Return true if supplied character is non-spacing.
virtual ~UnicodeUtil()
static bool isLower(wchar_t c)
Return true if supplied character is lowercase.
static bool isSpace(wchar_t c)
Return true if supplied character is a space.
static bool isDigit(wchar_t c)
Return true if supplied character is numeric.
static wchar_t toLower(wchar_t c)
Return lowercase representation of a given character.
static bool isUpper(wchar_t c)
Return true if supplied character is uppercase.
static wchar_t toUpper(wchar_t c)
Return uppercase representation of a given character.
Definition AbstractAllTermDocs.h:12

clucene.sourceforge.net