TokenEngine::TokenSectionSequence Class Reference

#include <tokenengine.h>

Collaboration diagram for TokenEngine::TokenSectionSequence:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 322 of file tokenengine.h.

Public Member Functions

 TokenSectionSequence ()
 TokenSectionSequence (QVector< TokenSection > tokenSections)
QByteArray fullText () const
int count () const
QVector< TokenSectiontokenSections () const
QByteArray text (const int index) const
QByteArray tempText (const int index) const
TokenContainer tokenContainer (const int index) const
int containerIndex (const int index) const

Protected Member Functions

int findSection (const int index) const
int calculateInternalIndex (const int index, const int sectionIndex) const

Private Attributes

QVector< TokenSectionm_tokenSections
QVector< int > m_startIndexes
int m_count

Friends

class TokenSectionSequenceIterator


Constructor & Destructor Documentation

TokenEngine::TokenSectionSequence::TokenSectionSequence (  )  [inline]

Definition at line 325 of file tokenengine.h.

00325 :m_count(0) {};

TokenEngine::TokenSectionSequence::TokenSectionSequence ( QVector< TokenSection tokenSections  ) 

Definition at line 209 of file tokenengine.cpp.

References QVector< T >::append(), m_count, m_startIndexes, m_tokenSections, and s.

00210 :m_tokenSections(tokenSections), m_count(0)
00211 {
00212     for(int s = 0; s < m_tokenSections.count(); ++s) {
00213         m_startIndexes.append(m_count);
00214         m_count += m_tokenSections.at(s).count();
00215     }
00216 }

Here is the call graph for this function:


Member Function Documentation

QByteArray TokenEngine::TokenSectionSequence::fullText (  )  const

Definition at line 218 of file tokenengine.cpp.

References TokenEngine::TokenSection::fullText(), m_tokenSections, and text().

00219 {
00220     QByteArray text;
00221     foreach(TokenSection section, m_tokenSections) {
00222         text += section.fullText();
00223     }
00224     return text;
00225 }

Here is the call graph for this function:

int TokenEngine::TokenSectionSequence::count (  )  const

Definition at line 227 of file tokenengine.cpp.

References m_count.

Referenced by CppLexer::lex(), and TokenStreamAdapter::TokenStream::TokenStream().

00228 {
00229     return m_count;
00230 }

QVector< TokenSection > TokenEngine::TokenSectionSequence::tokenSections (  )  const

Definition at line 232 of file tokenengine.cpp.

References m_tokenSections.

00233 {
00234     return m_tokenSections;
00235 }

QByteArray TokenEngine::TokenSectionSequence::text ( const int  index  )  const

Definition at line 237 of file tokenengine.cpp.

References calculateInternalIndex(), findSection(), and m_tokenSections.

Referenced by fullText().

00238 {
00239     const int sectionIndex = findSection(index);
00240     const int sectionInternalIndex = calculateInternalIndex(index, sectionIndex);
00241     return m_tokenSections.at(sectionIndex).text(sectionInternalIndex);
00242 }

Here is the call graph for this function:

QByteArray TokenEngine::TokenSectionSequence::tempText ( const int  index  )  const

Definition at line 244 of file tokenengine.cpp.

References calculateInternalIndex(), findSection(), and m_tokenSections.

00245 {
00246     const int sectionIndex = findSection(index);
00247     const int sectionInternalIndex = calculateInternalIndex(index, sectionIndex);
00248     return m_tokenSections.at(sectionIndex).tempText(sectionInternalIndex);
00249 }

Here is the call graph for this function:

TokenContainer TokenEngine::TokenSectionSequence::tokenContainer ( const int  index  )  const

Definition at line 252 of file tokenengine.cpp.

References calculateInternalIndex(), findSection(), and m_tokenSections.

00253 {
00254     const int sectionIndex = findSection(index);
00255     const int sectionInternalIndex = calculateInternalIndex(index, sectionIndex);
00256     return m_tokenSections.at(sectionIndex).tokenContainer(sectionInternalIndex);
00257 }

Here is the call graph for this function:

int TokenEngine::TokenSectionSequence::containerIndex ( const int  index  )  const

Definition at line 259 of file tokenengine.cpp.

References calculateInternalIndex(), findSection(), and m_tokenSections.

00260 {
00261     const int sectionIndex = findSection(index);
00262     const int sectionInternalIndex = calculateInternalIndex(index, sectionIndex);
00263     return m_tokenSections.at(sectionIndex).containerIndex(sectionInternalIndex);
00264 }

Here is the call graph for this function:

int TokenEngine::TokenSectionSequence::findSection ( const int  index  )  const [protected]

Definition at line 266 of file tokenengine.cpp.

References QVector< T >::at(), c, m_startIndexes, and m_tokenSections.

Referenced by containerIndex(), tempText(), text(), and tokenContainer().

00267 {
00268     int c = 0;
00269     bool found = false;
00270     //Here we do a linear search through all collections in the list,
00271     //which could turn out to be to slow.
00272     while(!found && c < m_tokenSections.count()) {
00273         const int sectionEnd = m_startIndexes.at(c)
00274                                 + m_tokenSections.at(c).count();
00275         if (index < sectionEnd)
00276             found = true;
00277         else
00278             ++c;
00279     }
00280     if(!found) {
00281         //error
00282         Q_ASSERT(0);
00283         return -1;
00284     }
00285     Q_ASSERT(c < m_tokenSections.count());
00286     return c;
00287 }

Here is the call graph for this function:

int TokenEngine::TokenSectionSequence::calculateInternalIndex ( const int  index,
const int  sectionIndex 
) const [protected]

Definition at line 289 of file tokenengine.cpp.

References QVector< T >::at(), m_startIndexes, and m_tokenSections.

Referenced by containerIndex(), tempText(), text(), and tokenContainer().

00290 {
00291     const int sectionInternalIndex =
00292         index - m_startIndexes.at(sectionIndex);
00293     Q_ASSERT(sectionInternalIndex < m_tokenSections.at(sectionIndex).count());
00294     return sectionInternalIndex;
00295 }

Here is the call graph for this function:


Friends And Related Function Documentation

friend class TokenSectionSequenceIterator [friend]

Definition at line 345 of file tokenengine.h.


Member Data Documentation

QVector<TokenSection> TokenEngine::TokenSectionSequence::m_tokenSections [private]

Definition at line 342 of file tokenengine.h.

Referenced by calculateInternalIndex(), containerIndex(), TokenEngine::TokenSectionSequenceIterator::containerIndex(), findSection(), fullText(), TokenEngine::TokenSectionSequenceIterator::nextToken(), tempText(), TokenEngine::TokenSectionSequenceIterator::tempText(), text(), TokenEngine::TokenSectionSequenceIterator::text(), TokenEngine::TokenSectionSequenceIterator::tokenContainer(), tokenContainer(), tokenSections(), TokenSectionSequence(), and TokenEngine::TokenSectionSequenceIterator::tokenTempRef().

QVector<int> TokenEngine::TokenSectionSequence::m_startIndexes [private]

Definition at line 343 of file tokenengine.h.

Referenced by calculateInternalIndex(), findSection(), and TokenSectionSequence().

int TokenEngine::TokenSectionSequence::m_count [private]

Definition at line 344 of file tokenengine.h.

Referenced by count(), and TokenSectionSequence().


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 20:55:01 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1