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
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
LuceneObject.h
Lucene::Array
Utility template class to handle sharable arrays of simple data types.
Definition Array.h:47
Lucene::Array::newInstance
static this_type newInstance(int32_t size)
Definition Array.h:61
Lucene::LuceneObject::LuceneObject
LuceneObject()
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
Lucene::TranslationResult::TranslationResult
TranslationResult()
Definition UnicodeUtils.h:54
Lucene::TranslationResult::setLength
void setLength(int32_t length)
Definition UnicodeUtils.h:64
Lucene::TranslationResult::length
int32_t length
Definition UnicodeUtils.h:61
Lucene::TranslationResult::copyText
void copyText(boost::shared_ptr< TranslationResult< TYPE > > other)
Definition UnicodeUtils.h:79
Lucene::TranslationResult::copyText
void copyText(const TranslationResult &other)
Definition UnicodeUtils.h:74
Lucene::TranslationResult::result
Array< TYPE > result
Definition UnicodeUtils.h:60
Lucene::UTF8Result
Definition UnicodeUtils.h:84
Lucene::UTF8Result::~UTF8Result
virtual ~UTF8Result()
Lucene::UnicodeResult
Definition UnicodeUtils.h:89
Lucene::UnicodeResult::~UnicodeResult
virtual ~UnicodeResult()
Lucene::UnicodeUtil
Definition UnicodeUtils.h:14
Lucene::UnicodeUtil::isAlpha
static bool isAlpha(wchar_t c)
Return true if supplied character is alphabetic.
Lucene::UnicodeUtil::isAlnum
static bool isAlnum(wchar_t c)
Return true if supplied character is alpha-numeric.
Lucene::UnicodeUtil::isOther
static bool isOther(wchar_t c)
Return true if supplied character is other type of letter.
Lucene::UnicodeUtil::isNonSpacing
static bool isNonSpacing(wchar_t c)
Return true if supplied character is non-spacing.
Lucene::UnicodeUtil::~UnicodeUtil
virtual ~UnicodeUtil()
Lucene::UnicodeUtil::isLower
static bool isLower(wchar_t c)
Return true if supplied character is lowercase.
Lucene::UnicodeUtil::isSpace
static bool isSpace(wchar_t c)
Return true if supplied character is a space.
Lucene::UnicodeUtil::isDigit
static bool isDigit(wchar_t c)
Return true if supplied character is numeric.
Lucene::UnicodeUtil::toLower
static wchar_t toLower(wchar_t c)
Return lowercase representation of a given character.
Lucene::UnicodeUtil::isUpper
static bool isUpper(wchar_t c)
Return true if supplied character is uppercase.
Lucene::UnicodeUtil::toUpper
static wchar_t toUpper(wchar_t c)
Return uppercase representation of a given character.
Lucene
Definition AbstractAllTermDocs.h:12

clucene.sourceforge.net