本文整理汇总了C++中SegmentedString::currentChar方法的典型用法代码示例。如果您正苦于以下问题:C++ SegmentedString::currentChar方法的具体用法?C++ SegmentedString::currentChar怎么用?C++ SegmentedString::currentChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SegmentedString
的用法示例。
在下文中一共展示了SegmentedString::currentChar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: consumeNamedEntity
static bool consumeNamedEntity(SegmentedString& source, StringBuilder& decodedEntity, bool& notEnoughCharacters, UChar additionalAllowedCharacter, UChar& cc)
{
StringBuilder consumedCharacters;
HTMLEntitySearch entitySearch;
while (!source.isEmpty()) {
cc = source.currentChar();
entitySearch.advance(cc);
if (!entitySearch.isEntityPrefix())
break;
consumedCharacters.append(cc);
source.advance();
}
notEnoughCharacters = source.isEmpty();
if (notEnoughCharacters) {
// We can't an entity because there might be a longer entity
// that we could match if we had more data.
unconsumeCharacters(source, consumedCharacters);
return false;
}
if (!entitySearch.mostRecentMatch()) {
unconsumeCharacters(source, consumedCharacters);
return false;
}
if (entitySearch.mostRecentMatch()->length != entitySearch.currentLength()) {
// We've consumed too many characters. We need to walk the
// source back to the point at which we had consumed an
// actual entity.
unconsumeCharacters(source, consumedCharacters);
consumedCharacters.clear();
const int length = entitySearch.mostRecentMatch()->length;
const LChar* reference = entitySearch.mostRecentMatch()->entity;
for (int i = 0; i < length; ++i) {
cc = source.currentChar();
ASSERT_UNUSED(reference, cc == *reference++);
consumedCharacters.append(cc);
source.advance();
ASSERT(!source.isEmpty());
}
cc = source.currentChar();
}
if (entitySearch.mostRecentMatch()->lastCharacter() == ';'
|| !additionalAllowedCharacter
|| !(isASCIIAlphanumeric(cc) || cc == '=')) {
decodedEntity.append(entitySearch.mostRecentMatch()->firstValue);
if (entitySearch.mostRecentMatch()->secondValue)
decodedEntity.append(entitySearch.mostRecentMatch()->secondValue);
return true;
}
unconsumeCharacters(source, consumedCharacters);
return false;
}
示例2: append
void FTPDirectoryDocumentParser::append(PassRefPtr<StringImpl> inputSource)
{
String source(inputSource);
// Make sure we have the table element to append to by loading the template set in the pref, or
// creating a very basic document with the appropriate table
if (!m_tableElement) {
if (!loadDocumentTemplate())
createBasicDocument();
ASSERT(m_tableElement);
}
bool foundNewLine = false;
m_dest = m_buffer;
SegmentedString str = source;
while (!str.isEmpty()) {
UChar c = str.currentChar();
if (c == '\r') {
*m_dest++ = '\n';
foundNewLine = true;
// possibly skip an LF in the case of an CRLF sequence
m_skipLF = true;
} else if (c == '\n') {
if (!m_skipLF)
*m_dest++ = c;
else
m_skipLF = false;
} else {
*m_dest++ = c;
m_skipLF = false;
}
str.advance();
// Maybe enlarge the buffer
checkBuffer();
}
if (!foundNewLine) {
m_dest = m_buffer;
return;
}
UChar* start = m_buffer;
UChar* cursor = start;
while (cursor < m_dest) {
if (*cursor == '\n') {
m_carryOver.append(String(start, cursor - start));
LOG(FTP, "%s", m_carryOver.ascii().data());
parseAndAppendOneLine(m_carryOver);
m_carryOver = String();
start = ++cursor;
} else
cursor++;
}
// Copy the partial line we have left to the carryover buffer
if (cursor - start > 1)
m_carryOver.append(String(start, cursor - start - 1));
}