⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stringit.cpp

📁 konqueror3 embedded版本, KDE环境下的当家浏览器的嵌入式版本源码包.
💻 CPP
字号:
/*    This file is part of the KDE libraries    Copyright (C) 2004 Apple Computer    This library is free software; you can redistribute it and/or    modify it under the terms of the GNU Library General Public    License as published by the Free Software Foundation; either    version 2 of the License, or (at your option) any later version.    This library is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    Library General Public License for more details.    You should have received a copy of the GNU Library General Public License    along with this library; see the file COPYING.LIB.  If not, write to    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,    Boston, MA 02110-1301, USA.*/#include "stringit.h"namespace khtml {uint TokenizerString::length() const{    uint length = m_currentString.m_length;    if (!m_pushedChar1.isNull()) {        ++length;        if (!m_pushedChar2.isNull())            ++length;    }    if (m_composite) {        QValueListConstIterator<TokenizerSubstring> i = m_substrings.begin();        QValueListConstIterator<TokenizerSubstring> e = m_substrings.end();        for (; i != e; ++i)            length += (*i).m_length;    }    return length;}void TokenizerString::clear(){    m_pushedChar1 = 0;    m_pushedChar2 = 0;    m_currentChar = 0;    m_currentString.clear();    m_substrings.clear();    m_lines = 0;    m_composite = false;}void TokenizerString::append(const TokenizerSubstring &s){    if (s.m_length) {        if (!m_currentString.m_length) {            m_currentString = s;	} else {            m_substrings.append(s);            m_composite = true;        }    }}void TokenizerString::prepend(const TokenizerSubstring &s){    assert(!escaped());    if (s.m_length) {        if (!m_currentString.m_length)            m_currentString = s;        else {            // Shift our m_currentString into our list.            m_substrings.prepend(m_currentString);            m_currentString = s;            m_composite = true;        }    }}void TokenizerString::append(const TokenizerString &s){    assert(!s.escaped());    append(s.m_currentString);    if (s.m_composite) {        QValueListConstIterator<TokenizerSubstring> i = s.m_substrings.begin();        QValueListConstIterator<TokenizerSubstring> e = s.m_substrings.end();        for (; i != e; ++i)            append(*i);    }    m_currentChar = m_pushedChar1.isNull() ? m_currentString.m_current : &m_pushedChar1;}void TokenizerString::prepend(const TokenizerString &s){    assert(!escaped());    assert(!s.escaped());    if (s.m_composite) {        QValueListConstIterator<TokenizerSubstring> i = s.m_substrings.fromLast();        QValueListConstIterator<TokenizerSubstring> e = s.m_substrings.end();        for (; i != e; --i)            prepend(*i);    }    prepend(s.m_currentString);    m_currentChar = m_pushedChar1.isNull() ? m_currentString.m_current : &m_pushedChar1;}void TokenizerString::advanceSubstring(){    if (m_composite) {        m_currentString = m_substrings.first();        m_substrings.remove(m_substrings.begin());        if (m_substrings.isEmpty())            m_composite = false;    } else {        m_currentString.clear();    }}QString TokenizerString::toString() const{    QString result;    if (!m_pushedChar1.isNull()) {        result.append(m_pushedChar1);        if (!m_pushedChar2.isNull())            result.append(m_pushedChar2);    }    m_currentString.appendTo(result);    if (m_composite) {        QValueListConstIterator<TokenizerSubstring> i = m_substrings.begin();        QValueListConstIterator<TokenizerSubstring> e = m_substrings.end();        for (; i != e; ++i)            (*i).appendTo(result);    }    return result;}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -