本文整理汇总了C++中SegmentedString类的典型用法代码示例。如果您正苦于以下问题:C++ SegmentedString类的具体用法?C++ SegmentedString怎么用?C++ SegmentedString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SegmentedString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: documentWrite
static inline void documentWrite(ExecState& state, JSHTMLDocument* thisDocument, NewlineRequirement addNewline)
{
HTMLDocument* document = &thisDocument->wrapped();
// DOM only specifies single string argument, but browsers allow multiple or no arguments.
size_t size = state.argumentCount();
String firstString = state.argument(0).toString(&state)->value(&state);
SegmentedString segmentedString = firstString;
if (size != 1) {
if (!size)
segmentedString.clear();
else {
for (size_t i = 1; i < size; ++i) {
String subsequentString = state.uncheckedArgument(i).toString(&state)->value(&state);
segmentedString.append(SegmentedString(subsequentString));
}
}
}
if (addNewline)
segmentedString.append(SegmentedString(String(&newlineCharacter, 1)));
Document* activeDocument = findCallingDocument(state);
document->write(segmentedString, activeDocument);
}
示例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: prepend
void SegmentedString::prepend(const SegmentedString& s)
{
ASSERT(!escaped());
ASSERT(!s.escaped());
if (s.isComposite()) {
Deque<SegmentedSubstring>::const_reverse_iterator it = s.m_substrings.rbegin();
Deque<SegmentedSubstring>::const_reverse_iterator e = s.m_substrings.rend();
for (; it != e; ++it)
prepend(*it);
}
prepend(s.m_currentString);
m_currentChar = m_pushedChar1 ? m_pushedChar1 : (m_currentString.m_length ? m_currentString.getCurrentChar() : 0);
}
示例4: write
bool TextTokenizer::write(const SegmentedString& s, bool appendData)
{
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;
// Maybe enlarge the buffer
checkBuffer();
}
if (!m_preElement) {
RefPtr<Element> rootElement = m_doc->createElementNS(xhtmlNamespaceURI, "html", ec);
m_doc->appendChild(rootElement, ec);
RefPtr<Element> body = m_doc->createElementNS(xhtmlNamespaceURI, "body", ec);
rootElement->appendChild(body, ec);
RefPtr<Element> preElement = m_doc->createElementNS(xhtmlNamespaceURI, "pre", ec);
body->appendChild(preElement, ec);
m_preElement = preElement.get();
}
String string = String(m_buffer, m_dest - m_buffer);
RefPtr<Text> text = m_doc->createTextNode(string);
m_preElement->appendChild(text, ec);
return false;
}
示例5: end
void HTMLSourceTracker::end(SegmentedString& currentInput, HTMLTokenizer* tokenizer, HTMLToken& token)
{
m_cachedSourceForToken = String();
// FIXME: This work should really be done by the HTMLTokenizer.
token.end(currentInput.numberOfCharactersConsumed() - tokenizer->numberOfBufferedCharacters());
}
示例6: write
void XMLTokenizer::write(const SegmentedString& s, bool /*appendData*/)
{
String parseString = s.toString();
if (m_sawXSLTransform || !m_sawFirstElement)
m_originalSourceForTransform += parseString;
if (m_parserStopped || m_sawXSLTransform)
return;
if (m_parserPaused) {
m_pendingSrc.append(s);
return;
}
doWrite(s.toString());
}
示例7: emitRule
void CSSPreloadScanner::emitRule(const SegmentedString& source)
{
if (equalIgnoringCase("import", m_rule.characters(), m_rule.length())) {
String url = parseCSSStringOrURL(m_ruleValue.characters(), m_ruleValue.length());
if (!url.isEmpty()) {
KURL baseElementURL; // FIXME: This should be passed in from the HTMLPreloadScaner via scan()!
TextPosition position = TextPosition(source.currentLine(), source.currentColumn());
OwnPtr<PreloadRequest> request = PreloadRequest::create("css", position, url, baseElementURL, CachedResource::CSSStyleSheet);
// FIXME: Should this be including the charset in the preload request?
m_requests->append(request.release());
}
m_state = Initial;
} else if (equalIgnoringCase("charset", m_rule.characters(), m_rule.length()))
m_state = Initial;
else
m_state = DoneParsingImportRules;
m_rule.clear();
m_ruleValue.clear();
}
示例8: append
void XMLDocumentParser::append(const SegmentedString& s)
{
String parseString = s.toString();
if (m_sawXSLTransform || !m_sawFirstElement)
m_originalSourceForTransform += parseString;
if (isStopped() || m_sawXSLTransform)
return;
if (m_parserPaused) {
m_pendingSrc.append(s);
return;
}
doWrite(s.toString());
// After parsing, go ahead and dispatch image beforeload events.
ImageLoader::dispatchPendingBeforeLoadEvents();
}
示例9: 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;
}
示例10: append
void SegmentedString::append(const SegmentedString &s)
{
ASSERT(!s.escaped());
append(s.m_currentString);
if (s.m_composite) {
DeprecatedValueListConstIterator<SegmentedSubstring> i = s.m_substrings.begin();
DeprecatedValueListConstIterator<SegmentedSubstring> e = s.m_substrings.end();
for (; i != e; ++i)
append(*i);
}
m_currentChar = m_pushedChar1 ? &m_pushedChar1 : m_currentString.m_current;
}
示例11: ASSERT
void XMLDocumentParser::resumeParsing()
{
ASSERT(m_parserPaused);
m_parserPaused = false;
// First, execute any pending callbacks
parse();
if (m_parserPaused)
return;
// Then, write any pending data
SegmentedString rest = m_pendingSrc;
m_pendingSrc.clear();
append(rest.toString().impl());
// Finally, if finish() has been called and append() didn't result
// in any further callbacks being queued, call end()
if (m_finishCalled && !m_parserPaused && !m_pendingScript)
end();
}
示例12: prepend
void SegmentedString::prepend(const SegmentedString& s, PrependType type) {
if (s.isComposite()) {
Deque<SegmentedSubstring>::const_reverse_iterator it =
s.m_substrings.rbegin();
Deque<SegmentedSubstring>::const_reverse_iterator e = s.m_substrings.rend();
for (; it != e; ++it)
prepend(*it, type);
}
prepend(s.m_currentString, type);
m_currentChar =
m_currentString.length() ? m_currentString.getCurrentChar() : 0;
}
示例13: append
void SegmentedString::append(const SegmentedString &s)
{
ASSERT(!m_closed);
ASSERT(!s.escaped());
append(s.m_currentString);
if (s.m_composite) {
Deque<SegmentedSubstring>::const_iterator it = s.m_substrings.begin();
Deque<SegmentedSubstring>::const_iterator e = s.m_substrings.end();
for (; it != e; ++it)
append(*it);
}
m_currentChar = m_pushedChar1 ? &m_pushedChar1 : m_currentString.m_current;
}
示例14: append
void SegmentedString::append(const SegmentedString& s) {
ASSERT(!m_closed);
append(s.m_currentString);
if (s.isComposite()) {
Deque<SegmentedSubstring>::const_iterator it = s.m_substrings.begin();
Deque<SegmentedSubstring>::const_iterator e = s.m_substrings.end();
for (; it != e; ++it)
append(*it);
}
m_currentChar =
m_currentString.length() ? m_currentString.getCurrentChar() : 0;
}
示例15: prepend
void SegmentedString::prepend(const SegmentedString &s)
{
ASSERT(!escaped());
ASSERT(!s.escaped());
if (s.m_composite) {
DeprecatedValueListConstIterator<SegmentedSubstring> i = s.m_substrings.fromLast();
DeprecatedValueListConstIterator<SegmentedSubstring> e = s.m_substrings.end();
for (; i != e; --i)
prepend(*i);
}
prepend(s.m_currentString);
m_currentChar = m_pushedChar1 ? &m_pushedChar1 : m_currentString.m_current;
}