本文整理汇总了C++中CharArray::get方法的典型用法代码示例。如果您正苦于以下问题:C++ CharArray::get方法的具体用法?C++ CharArray::get怎么用?C++ CharArray::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CharArray
的用法示例。
在下文中一共展示了CharArray::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST_F(MappingCharFilterTest, testReaderReset) {
CharStreamPtr cs = newLucene<MappingCharFilter>(normMap, newLucene<StringReader>(L"x"));
CharArray buf = CharArray::newInstance(10);
int32_t len = cs->read(buf.get(), 0, 10);
EXPECT_EQ(1, len);
EXPECT_EQ(L'x', buf[0]) ;
len = cs->read(buf.get(), 0, 10);
EXPECT_EQ(-1, len);
// rewind
cs->reset();
len = cs->read(buf.get(), 0, 10);
EXPECT_EQ(1, len);
EXPECT_EQ(L'x', buf[0]) ;
}
示例2: randomString
/// Return a random unicode term, like StressIndexingTest.
String randomString() {
int32_t end = random->nextInt(20);
if (buffer.size() < 1 + end) {
buffer.resize((int32_t)((double)(1 + end) * 1.25));
}
for (int32_t i = 0; i < end; ++i) {
int32_t t = random->nextInt(5);
if (t == 0 && i < end - 1) {
#ifdef LPP_UNICODE_CHAR_SIZE_2
// Make a surrogate pair
// High surrogate
buffer[i++] = (wchar_t)nextInt(0xd800, 0xdc00);
// Low surrogate
buffer[i] = (wchar_t)nextInt(0xdc00, 0xe000);
#else
buffer[i] = (wchar_t)nextInt(0xdc00, 0xe000);
#endif
} else if (t <= 1) {
buffer[i] = (wchar_t)nextInt(0x01, 0x80);
} else if (t == 2) {
buffer[i] = (wchar_t)nextInt(0x80, 0x800);
} else if (t == 3) {
buffer[i] = (wchar_t)nextInt(0x800, 0xd800);
} else if (t == 4) {
buffer[i] = (wchar_t)nextInt(0xe000, 0xfff0);
}
}
return String(buffer.get(), end);
}
示例3: toUnicode
int32_t StringUtils::toUnicode(const uint8_t* utf8, int32_t length, CharArray unicode)
{
if (length == 0)
return 0;
UTF8Decoder utf8Decoder(utf8, utf8 + length);
int32_t decodeLength = utf8Decoder.decode(unicode.get(), unicode.size());
return decodeLength == Reader::READER_EOF ? 0 : decodeLength;
}