本文整理汇总了C++中SegmentedString::advance方法的典型用法代码示例。如果您正苦于以下问题:C++ SegmentedString::advance方法的具体用法?C++ SegmentedString::advance怎么用?C++ SegmentedString::advance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SegmentedString
的用法示例。
在下文中一共展示了SegmentedString::advance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: write
void TextTokenizer::write(const SegmentedString& s, bool)
{
ExceptionCode ec;
m_dest = m_buffer;
SegmentedString str = s;
while (!str.isEmpty()) {
UChar c = *str;
if (c == '\r') {
*m_dest++ = '\n';
// 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 (!m_preElement && !inViewSourceMode()) {
RefPtr<Element> rootElement = m_doc->createElement(htmlTag, false);
m_doc->appendChild(rootElement, ec);
RefPtr<Element> body = m_doc->createElement(bodyTag, false);
rootElement->appendChild(body, ec);
RefPtr<Element> preElement = m_doc->createElement(preTag, false);
preElement->setAttribute("style", "word-wrap: break-word; white-space: pre-wrap;", ec);
body->appendChild(preElement, ec);
m_preElement = preElement.get();
}
String string = String(m_buffer, m_dest - m_buffer);
if (inViewSourceMode()) {
static_cast<HTMLViewSourceDocument*>(m_doc)->addViewSourceText(string);
return;
}
unsigned charsLeft = string.length();
while (charsLeft) {
// split large text to nodes of manageable size
RefPtr<Text> text = Text::createWithLengthLimit(m_doc, string, charsLeft);
m_preElement->appendChild(text, ec);
}
}
示例3: write
bool FTPDirectoryTokenizer::write(const SegmentedString& s, bool appendData)
{
// 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 = s;
while (!str.isEmpty()) {
UChar c = *str;
if (c == '\r') {
*m_dest++ = '\n';
// 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;
foundNewLine = true;
} else {
*m_dest++ = c;
m_skipLF = false;
}
str.advance(0);
// Maybe enlarge the buffer
checkBuffer();
}
if (!foundNewLine) {
m_dest = m_buffer;
return false;
}
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));
return false;
}