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
Definition: StringUtils.h:14
static int64_t toLong(const String &value, int32_t base)
Return given value as a long integer using base unit.
static void toUpper(String &str)
Convert given string to upper case using current locale.
static int32_t toUnicode(const uint8_t *utf8, int32_t length, CharArray unicode)
Convert uft8 buffer into unicode.
static int32_t hashCode(const String &value)
Compute the hash code from string.
static Collection< String > split(const String &str, const String &delim)
Splits string using given delimiters.
static int32_t toUTF8(const wchar_t *unicode, int32_t length, ByteArray utf8)
Convert unicode buffer into uft8.
static int32_t compareCase(const String &first, const String &second)
Compare two strings ignoring case differences.
static int64_t toLong(const String &value)
Convert the given string to int64_t.
static int32_t toInt(const String &value)
Convert the given string to int32_t.
static String toUnicode(const uint8_t *utf8, int32_t length)
Convert uft8 buffer into unicode.
static int32_t toUnicode(const uint8_t *utf8, int32_t length, const UnicodeResultPtr &unicodeResult)
Convert uft8 buffer into unicode.
static SingleString toUTF8(const wchar_t *unicode, int32_t length)
Convert unicode buffer into uft8.
static String toUnicode(const SingleString &s)
Convert uft8 string into unicode.
static String toString(const TYPE &value)
Convert any given type to a String.
Definition: StringUtils.h:85
static const int32_t MAX_ENCODING_UTF8_SIZE
Maximum length of UTF encoding.
Definition: StringUtils.h:17
static String toLower(const String &str)
Convert given string to lower case using current locale.
static SingleString toUTF8(const String &s)
Convert unicode string into uft8.
static void toLower(String &str)
Convert given string to lower case using current locale.
static int32_t toUTF8(const wchar_t *unicode, int32_t length, const UTF8ResultPtr &utf8Result)
Convert unicode buffer into uft8.
static double toDouble(const String &value)
Convert the given string to double.
static String toUpper(const String &str)
Convert given string to upper case using current locale.
static String toString(int64_t value, int32_t base)
Return given value as a string using base unit.
static const int32_t CHARACTER_MAX_RADIX
Default character radix.
Definition: StringUtils.h:20
Definition: AbstractAllTermDocs.h:12
boost::shared_ptr< UTF8Result > UTF8ResultPtr
Definition: LuceneTypes.h:559
boost::shared_ptr< UnicodeResult > UnicodeResultPtr
Definition: LuceneTypes.h:554

clucene.sourceforge.net