2 This file is part of the KDE libraries
4 Copyright (C) 2004 Apple Computer
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
26 uint
TokenizerString::length() const
28 uint length
= m_currentString
.m_length
;
29 if (!m_pushedChar1
.isNull()) {
31 if (!m_pushedChar2
.isNull())
35 QList
<TokenizerSubstring
>::ConstIterator i
= m_substrings
.begin();
36 QList
<TokenizerSubstring
>::ConstIterator e
= m_substrings
.end();
38 length
+= (*i
).m_length
;
43 void TokenizerString::clear()
48 m_currentString
.clear();
54 void TokenizerString::append(const TokenizerSubstring
&s
)
57 if (!m_currentString
.m_length
) {
60 m_substrings
.append(s
);
66 void TokenizerString::prepend(const TokenizerSubstring
&s
)
70 if (!m_currentString
.m_length
)
73 // Shift our m_currentString into our list.
74 m_substrings
.prepend(m_currentString
);
81 void TokenizerString::append(const TokenizerString
&s
)
84 append(s
.m_currentString
);
86 QList
<TokenizerSubstring
>::ConstIterator i
= s
.m_substrings
.begin();
87 QList
<TokenizerSubstring
>::ConstIterator e
= s
.m_substrings
.end();
91 m_currentChar
= m_pushedChar1
.isNull() ? m_currentString
.m_current
: &m_pushedChar1
;
94 void TokenizerString::prepend(const TokenizerString
&s
)
99 QList
<TokenizerSubstring
>::ConstIterator e
= s
.m_substrings
.end();
100 while (e
!= s
.m_substrings
.begin())
106 prepend(s
.m_currentString
);
107 m_currentChar
= m_pushedChar1
.isNull() ? m_currentString
.m_current
: &m_pushedChar1
;
110 void TokenizerString::advanceSubstring()
113 m_currentString
= m_substrings
.first();
114 m_substrings
.removeFirst();
115 if (m_substrings
.isEmpty())
118 m_currentString
.clear();
122 QString
TokenizerString::toString() const
125 if (!m_pushedChar1
.isNull()) {
126 result
.append(m_pushedChar1
);
127 if (!m_pushedChar2
.isNull())
128 result
.append(m_pushedChar2
);
130 m_currentString
.appendTo(result
);
132 QList
<TokenizerSubstring
>::ConstIterator i
= m_substrings
.begin();
133 QList
<TokenizerSubstring
>::ConstIterator e
= m_substrings
.end();
135 (*i
).appendTo(result
);