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


 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-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>
53 public:
56  length = 0;
57  }
58 
59 public:
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
int32_t size() const
Definition: Array.h:87
int32_t length
Definition: UnicodeUtils.h:61
Definition: UnicodeUtils.h:84
Definition: UnicodeUtils.h:14
Array< TYPE > result
Definition: UnicodeUtils.h:60
static this_type newInstance(int32_t size)
Definition: Array.h:61
Utility template class to handle sharable arrays of simple data types.
Definition: Array.h:47
TranslationResult()
Definition: UnicodeUtils.h:54
void copyText(boost::shared_ptr< TranslationResult< TYPE > > other)
Definition: UnicodeUtils.h:79
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
void copyText(const TranslationResult &other)
Definition: UnicodeUtils.h:74
void setLength(int32_t length)
Definition: UnicodeUtils.h:64
void resize(int32_t size)
Definition: Array.h:72
Base class for all Lucene classes.
Definition: LuceneObject.h:31
Definition: AbstractAllTermDocs.h:12
TYPE * get() const
Definition: Array.h:83
Utility class that contains utf8 and unicode translations.
Definition: UnicodeUtils.h:52
Definition: UnicodeUtils.h:89

clucene.sourceforge.net