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

StringUtils.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 STRINGUTILS_H
8 #define STRINGUTILS_H
9
10 #include "Lucene.h"
11
12 namespace Lucene {
13
14 class LPPAPI StringUtils {
15 public:
17 static const int32_t MAX_ENCODING_UTF8_SIZE;
18
20 static const int32_t CHARACTER_MAX_RADIX;
21
22 public:
24 static int32_t toUnicode(const uint8_t* utf8, int32_t length, CharArray unicode);
25
27 static int32_t toUnicode(const uint8_t* utf8, int32_t length, const UnicodeResultPtr& unicodeResult);
28
30 static String toUnicode(const uint8_t* utf8, int32_t length);
31
33 static String toUnicode(const SingleString& s);
34
36 static int32_t toUTF8(const wchar_t* unicode, int32_t length, ByteArray utf8);
37
39 static int32_t toUTF8(const wchar_t* unicode, int32_t length, const UTF8ResultPtr& utf8Result);
40
42 static SingleString toUTF8(const wchar_t* unicode, int32_t length);
43
45 static SingleString toUTF8(const String& s);
46
48 static void toLower(String& str);
49
51 static String toLower(const String& str);
52
54 static void toUpper(String& str);
55
57 static String toUpper(const String& str);
58
60 static int32_t compareCase(const String& first, const String& second);
61
63 static Collection<String> split(const String& str, const String& delim);
64
66 static int32_t toInt(const String& value);
67
69 static int64_t toLong(const String& value);
70
72 static int64_t toLong(const String& value, int32_t base);
73
75 static double toDouble(const String& value);
76
78 static int32_t hashCode(const String& value);
79
81 static String toString(int64_t value, int32_t base);
82
84 template <class TYPE>
85 static String toString(const TYPE& value) {
86 StringStream os;
87 os << value;
88 return os.str();
89 }
90 };
91
92 #define UTF8_TO_STRING(utf8) StringUtils::toUnicode(utf8, SIZEOF_ARRAY(utf8))
93 }
94
95 #endif
Lucene::Collection< String >
Lucene::StringUtils::CHARACTER_MAX_RADIX
static const int32_t CHARACTER_MAX_RADIX
Default character radix.
Definition: StringUtils.h:20
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::StringUtils::toString
static String toString(const TYPE &value)
Convert any given type to a String.
Definition: StringUtils.h:85
Lucene::UnicodeResultPtr
boost::shared_ptr< UnicodeResult > UnicodeResultPtr
Definition: LuceneTypes.h:554
Lucene::StringUtils
Definition: StringUtils.h:14
Lucene::StringUtils::MAX_ENCODING_UTF8_SIZE
static const int32_t MAX_ENCODING_UTF8_SIZE
Maximum length of UTF encoding.
Definition: StringUtils.h:17
Lucene::UTF8ResultPtr
boost::shared_ptr< UTF8Result > UTF8ResultPtr
Definition: LuceneTypes.h:559

clucene.sourceforge.net