Lucene 源码分析集------- StringUtils

StringUtils主要提供编码类型转换,字符串转整型,浮点型等接口

class LPPAPI StringUtils {
public:
    /// Maximum length of UTF encoding.
    static const int32_t MAX_ENCODING_UTF8_SIZE;

    /// Default character radix.
    static const int32_t CHARACTER_MAX_RADIX;

public:
    /// Convert uft8 buffer into unicode.
    static int32_t toUnicode(const uint8_t* utf8, int32_t length, CharArray unicode);

    /// 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 String toUnicode(const uint8_t* utf8, int32_t length);

    /// Convert uft8 string into unicode.
    static String toUnicode(const SingleString& s);

    /// Convert unicode buffer into uft8.
    static int32_t toUTF8(const wchar_t* unicode, int32_t length, ByteArray utf8);

    /// Convert unicode buffer into uft8.
    static int32_t toUTF8(const wchar_t* unicode, int32_t length, const UTF8ResultPtr& utf8Result);

    /// Convert unicode buffer into uft8.
    static SingleString toUTF8(const wchar_t* unicode, int32_t length);

    /// Convert unicode string into uft8.
    static SingleString toUTF8(const String& s);

    /// Convert given string to lower case using current locale
    static void toLower(String& str);

    /// Convert given string to lower case using current locale
    static String toLower(const String& str);

    /// Convert given string to upper case using current locale
    static void toUpper(String& str);

    /// Convert given string to upper case using current locale
    static String toUpper(const String& str);

    /// Compare two strings ignoring case differences
    static int32_t compareCase(const String& first, const String& second);

    /// Splits string using given delimiters
    static Collection<String> split(const String& str, const String& delim);

    /// Convert the given string to int32_t.
    static int32_t toInt(const String& value);

    /// Convert the given string to int64_t.
    static int64_t toLong(const String& value);

    /// Return given value as a long integer using base unit.
    static int64_t toLong(const String& value, int32_t base);

    /// Convert the given string to double.
    static double toDouble(const String& value);

    /// Compute the hash code from string.
    static int32_t hashCode(const String& value);

    /// Return given value as a string using base unit.
    static String toString(int64_t value, int32_t base);

    /// Convert any given type to a {@link String}.
    template <class TYPE>
    static String toString(const TYPE& value) {
        StringStream os;
        os << value;
        return os.str();
    }
};

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值