umbrello API Documentation

NativeImportBase Class Reference

Intermediate base class for native Umbrello implementations of programming language import Base class for native implementations of language import. More...

#include <nativeimportbase.h>

Inheritance diagram for NativeImportBase:

ClassImport AdaImport IDLImport JavaImport PascalImport PythonImport List of all members.

Public Member Functions

 NativeImportBase (const QString &singleLineCommentIntro)
 Constructor.

Protected Member Functions

void initialize ()
 Implement abstract operation from ClassImport.
void setMultiLineComment (const QString &intro, const QString &end)
 Set the delimiter strings for a multi line comment.
void setMultiLineAltComment (const QString &intro, const QString &end)
 Set the delimiter strings for an alternative form of multi line comment.
virtual void parseFile (const QString &filename)
 Import a single file.
virtual void initVars ()
 Initialize auxiliary variables.
void scan (QString line)
 Scan a single line.
virtual bool preprocess (QString &line)
 Preprocess a line.
virtual QStringList split (const QString &line)
 Split the line so that a string is returned as a single element of the list.
virtual void fillSource (const QString &word)=0
 Analyze the given word and fill `m_source'.
virtual bool parseStmt ()=0
 Parse the statement which starts at m_source[m_srcIndex] leaving m_srcIndex pointing to the end of the recognized statement.
void skipStmt (QString until=";")
 Advance m_srcIndex until m_source[m_srcIndex] contains the lexeme given by `until'.
bool skipToClosing (QChar opener)
 Advance m_srcIndex to the index of the corresponding closing character of the given opening.
QString advance ()
 Advance m_srcIndex until m_source[m_srcIndex] contains a non-comment.

Protected Attributes

QString m_singleLineCommentIntro
 How to start a single line comment in this programming language.
QStringList m_source
 The scanned lexemes.
uint m_srcIndex
 Used for indexing m_source.
UMLPackagem_scope [32]
 Stack of scopes for use by the specific importer.
uint m_scopeIndex
 Indexes m_scope.
UMLClassifierm_klass
 The class currently being processed.
Uml::Visibility m_currentAccess
 The current access (public/protected/private).
QString m_comment
 Intermediate accumulator for comment text.
bool m_inComment
 True if we are currently in a multi-line comment.
bool m_isAbstract
 Accumulator for abstractness.
QStringList m_parsedFiles
 List of parsed files.
QString m_multiLineCommentIntro
 Multi line comment delimiters.
QString m_multiLineCommentEnd
QString m_multiLineAltCommentIntro
 Some languages support an alternative set of multi line comment delimiters.
QString m_multiLineAltCommentEnd

Detailed Description

Intermediate base class for native Umbrello implementations of programming language import Base class for native implementations of language import.

The default call sequence is as follows (RealizedLanguageImport is used as a placeholder name for the concrete language importer.) NativeImportBase RealizedLanguageImport --> importFiles() parseFile() -----------------------------------> initVars() scan() preprocess() (may be reimplemented) ---------------------------------> fillSource() -----------------------------------> parseStmt() This sequence may be changed by overriding default implementations of virtual methods in NativeImportBase.

Author:
Oliver Kellogg <okellogg@users.sourceforge.net> Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org

Definition at line 44 of file nativeimportbase.h.


Constructor & Destructor Documentation

NativeImportBase::NativeImportBase const QString &  singleLineCommentIntro  ) 
 

Constructor.

Parameters:
singleLineCommentIntro "//" for IDL and Java, "--" for Ada

Definition at line 24 of file nativeimportbase.cpp.

References m_currentAccess, m_inComment, m_isAbstract, m_klass, m_scopeIndex, m_singleLineCommentIntro, and m_srcIndex.


Member Function Documentation

void NativeImportBase::initialize  )  [protected, virtual]
 

Implement abstract operation from ClassImport.

Implements ClassImport.

Definition at line 337 of file nativeimportbase.cpp.

References m_parsedFiles.

void NativeImportBase::setMultiLineComment const QString &  intro,
const QString &  end
[protected]
 

Set the delimiter strings for a multi line comment.

Parameters:
intro In languages with a C style multiline comment this is slash-star.
end In languages with a C style multiline comment this is star-slash.

Definition at line 37 of file nativeimportbase.cpp.

References m_multiLineCommentIntro.

void NativeImportBase::setMultiLineAltComment const QString &  intro,
const QString &  end
[protected]
 

Set the delimiter strings for an alternative form of multi line comment.

See setMultiLineComment().

Definition at line 42 of file nativeimportbase.cpp.

References m_multiLineAltCommentIntro.

void NativeImportBase::parseFile const QString &  filename  )  [protected, virtual]
 

Import a single file.

The default implementation should be feasible for languages that don't depend on an external preprocessor.

Parameters:
filename The file to import.

Implements ClassImport.

Reimplemented in IDLImport, and JavaImport.

Definition at line 263 of file nativeimportbase.cpp.

References Import_Utils::addIncludePath(), Import_Utils::includePathList(), initVars(), m_comment, m_currentAccess, m_klass, m_parsedFiles, m_scope, m_scopeIndex, m_singleLineCommentIntro, m_source, m_srcIndex, parseStmt(), scan(), and skipStmt().

Referenced by JavaImport::parseFile(), AdaImport::parseStems(), and PascalImport::parseStmt().

void NativeImportBase::initVars  )  [protected, virtual]
 

Initialize auxiliary variables.

This is called by the default implementation of parseFile() after scanning (before parsing the QStringList m_source.) The default implementation is empty.

Reimplemented in AdaImport, JavaImport, PascalImport, and PythonImport.

Definition at line 260 of file nativeimportbase.cpp.

Referenced by parseFile().

void NativeImportBase::scan QString  line  )  [protected]
 

Scan a single line.

parseFile() calls this for each line read from the input file. This in turn calls other methods such as preprocess() and fillSource().

Parameters:
line The line to scan.

Definition at line 236 of file nativeimportbase.cpp.

References fillSource(), m_singleLineCommentIntro, m_source, preprocess(), and split().

Referenced by parseFile(), and IDLImport::parseFile().

bool NativeImportBase::preprocess QString &  line  )  [protected, virtual]
 

Preprocess a line.

May modify the given line to remove items consumed by the preprocessing such as comments or preprocessor directives. The default implementation handles multi-line comments.

Parameters:
line The line to preprocess.
Returns:
True if the line was completely consumed, false if there are still items left in the line for further analysis.

Reimplemented in IDLImport, and PythonImport.

Definition at line 110 of file nativeimportbase.cpp.

References m_comment, m_inComment, m_multiLineAltCommentIntro, m_multiLineCommentIntro, m_singleLineCommentIntro, m_source, and m_srcIndex.

Referenced by IDLImport::preprocess(), and scan().

QStringList NativeImportBase::split const QString &  line  )  [protected, virtual]
 

Split the line so that a string is returned as a single element of the list.

When not in a string then split at white space. The default implementation is suitable for C style strings and char constants.

Reimplemented in AdaImport.

Definition at line 193 of file nativeimportbase.cpp.

Referenced by scan().

virtual void NativeImportBase::fillSource const QString &  word  )  [protected, pure virtual]
 

Analyze the given word and fill `m_source'.

A "word" is a whitespace delimited item from the input line. To be provided by the specific importer class.

Implemented in AdaImport, IDLImport, JavaImport, PascalImport, and PythonImport.

Referenced by scan().

virtual bool NativeImportBase::parseStmt  )  [protected, pure virtual]
 

Parse the statement which starts at m_source[m_srcIndex] leaving m_srcIndex pointing to the end of the recognized statement.

To be provided by the concrete importer.

Returns:
True if the statement was recognized.

Implemented in AdaImport, IDLImport, JavaImport, PascalImport, and PythonImport.

Referenced by parseFile().

void NativeImportBase::skipStmt QString  until = ";"  )  [protected]
 

Advance m_srcIndex until m_source[m_srcIndex] contains the lexeme given by `until'.

Definition at line 47 of file nativeimportbase.cpp.

References m_source, and m_srcIndex.

Referenced by PascalImport::checkModifiers(), parseFile(), IDLImport::parseFile(), PythonImport::parseStmt(), PascalImport::parseStmt(), JavaImport::parseStmt(), IDLImport::parseStmt(), AdaImport::parseStmt(), PythonImport::skipBody(), and skipToClosing().

bool NativeImportBase::skipToClosing QChar  opener  )  [protected]
 

Advance m_srcIndex to the index of the corresponding closing character of the given opening.

Nested opening/closing pairs are respected. Valid openers are: '{' '[' '(' '<'

Returns:
True for success, false for misuse (invalid opener) or if no matching closing character is found in m_source.

Definition at line 53 of file nativeimportbase.cpp.

References advance(), m_source, m_srcIndex, and skipStmt().

Referenced by JavaImport::joinTypename(), PascalImport::parseStmt(), and JavaImport::parseStmt().

QString NativeImportBase::advance  )  [protected]
 

Advance m_srcIndex until m_source[m_srcIndex] contains a non-comment.

Comments encountered during advancement are accumulated in `m_comment'. If m_srcIndex hits the end of m_source then QString::null is returned.

Definition at line 94 of file nativeimportbase.cpp.

References m_comment, m_singleLineCommentIntro, m_source, and m_srcIndex.

Referenced by PascalImport::checkModifiers(), IDLImport::joinTypename(), PythonImport::parseStmt(), PascalImport::parseStmt(), JavaImport::parseStmt(), IDLImport::parseStmt(), AdaImport::parseStmt(), PythonImport::skipBody(), and skipToClosing().


Member Data Documentation

QString NativeImportBase::m_singleLineCommentIntro [protected]
 

How to start a single line comment in this programming language.

Definition at line 163 of file nativeimportbase.h.

Referenced by advance(), NativeImportBase(), parseFile(), preprocess(), and scan().

QStringList NativeImportBase::m_source [protected]
 

The scanned lexemes.

Definition at line 168 of file nativeimportbase.h.

Referenced by advance(), parseFile(), preprocess(), scan(), skipStmt(), and skipToClosing().

uint NativeImportBase::m_srcIndex [protected]
 

Used for indexing m_source.

Definition at line 172 of file nativeimportbase.h.

Referenced by advance(), NativeImportBase(), parseFile(), preprocess(), skipStmt(), and skipToClosing().

UMLPackage* NativeImportBase::m_scope[32] [protected]
 

Stack of scopes for use by the specific importer.

Definition at line 177 of file nativeimportbase.h.

Referenced by parseFile().

uint NativeImportBase::m_scopeIndex [protected]
 

Indexes m_scope.

Index 0 is reserved for global scope.

Definition at line 181 of file nativeimportbase.h.

Referenced by NativeImportBase(), and parseFile().

UMLClassifier* NativeImportBase::m_klass [protected]
 

The class currently being processed.

Definition at line 186 of file nativeimportbase.h.

Referenced by NativeImportBase(), and parseFile().

Uml::Visibility NativeImportBase::m_currentAccess [protected]
 

The current access (public/protected/private).

Definition at line 190 of file nativeimportbase.h.

Referenced by NativeImportBase(), and parseFile().

QString NativeImportBase::m_comment [protected]
 

Intermediate accumulator for comment text.

Definition at line 194 of file nativeimportbase.h.

Referenced by advance(), parseFile(), and preprocess().

bool NativeImportBase::m_inComment [protected]
 

True if we are currently in a multi-line comment.

Only applies to languages with multi-line comments.

Definition at line 199 of file nativeimportbase.h.

Referenced by NativeImportBase(), and preprocess().

bool NativeImportBase::m_isAbstract [protected]
 

Accumulator for abstractness.

Definition at line 203 of file nativeimportbase.h.

Referenced by NativeImportBase().

QStringList NativeImportBase::m_parsedFiles [protected]
 

List of parsed files.

Contains file names without paths. Before actually parsing a given file, NativeImportBase checks whether the name is already present in this list in order to avoid parsing the same file multiple times.

Definition at line 211 of file nativeimportbase.h.

Referenced by initialize(), and parseFile().

QString NativeImportBase::m_multiLineCommentIntro [protected]
 

Multi line comment delimiters.

Definition at line 216 of file nativeimportbase.h.

Referenced by preprocess(), and setMultiLineComment().

QString NativeImportBase::m_multiLineAltCommentIntro [protected]
 

Some languages support an alternative set of multi line comment delimiters.

Definition at line 222 of file nativeimportbase.h.

Referenced by preprocess(), and setMultiLineAltComment().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:08:05 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003