Commit 06821596 authored by Jochen Becher's avatar Jochen Becher

ModelEditor: Apply naming convention to attributes

Change-Id: Ife37a542be9b9e721e988cb11d9498469b2226f0
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent a08cb7d5
......@@ -48,11 +48,11 @@ namespace qmt {
struct ConfigController::ConfigControllerPrivate
{
ConfigControllerPrivate()
: _stereotype_controller(0)
: m_stereotypeController(0)
{
}
StereotypeController *_stereotype_controller;
StereotypeController *m_stereotypeController;
};
ConfigController::ConfigController(QObject *parent)
......@@ -68,7 +68,7 @@ ConfigController::~ConfigController()
void ConfigController::setStereotypeController(StereotypeController *stereotype_controller)
{
d->_stereotype_controller = stereotype_controller;
d->m_stereotypeController = stereotype_controller;
}
void ConfigController::readStereotypeDefinitions(const QString &path)
......@@ -101,12 +101,12 @@ void ConfigController::readStereotypeDefinitions(const QString &path)
void ConfigController::onStereotypeIconParsed(const StereotypeIcon &stereotype_icon)
{
d->_stereotype_controller->addStereotypeIcon(stereotype_icon);
d->m_stereotypeController->addStereotypeIcon(stereotype_icon);
}
void ConfigController::onToolbarParsed(const Toolbar &toolbar)
{
d->_stereotype_controller->addToolbar(toolbar);
d->m_stereotypeController->addToolbar(toolbar);
}
} // namespace qmt
......@@ -33,16 +33,16 @@
namespace qmt {
SourcePos::SourcePos()
: _source_id(-1),
_line_number(-1),
_column_number(-1)
: m_sourceId(-1),
m_lineNumber(-1),
m_columnNumber(-1)
{
}
SourcePos::SourcePos(int source_id, int line_number, int column_number)
: _source_id(source_id),
_line_number(line_number),
_column_number(column_number)
: m_sourceId(source_id),
m_lineNumber(line_number),
m_columnNumber(column_number)
{
}
......
......@@ -45,20 +45,20 @@ public:
public:
bool isValid() const { return _source_id >= 0 && _line_number >= 0; }
bool isValid() const { return m_sourceId >= 0 && m_lineNumber >= 0; }
int getSourceId() const { return _source_id; }
int getSourceId() const { return m_sourceId; }
int getLineNumber() const { return _line_number; }
int getLineNumber() const { return m_lineNumber; }
bool hasColumnNumber() const { return _column_number >= 0; }
bool hasColumnNumber() const { return m_columnNumber >= 0; }
int getColumnNumber() const { return _column_number; }
int getColumnNumber() const { return m_columnNumber; }
private:
int _source_id;
int _line_number;
int _column_number;
int m_sourceId;
int m_lineNumber;
int m_columnNumber;
};
} // namespace qmt
......
......@@ -56,10 +56,10 @@ public:
public:
SourcePos getSourcePos() const { return _source_pos; }
SourcePos getSourcePos() const { return m_sourcePos; }
private:
SourcePos _source_pos;
SourcePos m_sourcePos;
};
......
......@@ -36,10 +36,10 @@
namespace qmt {
StringTextSource::StringTextSource()
: _source_id(-1),
_index(-1),
_line_number(-1),
_column_number(-1)
: m_sourceId(-1),
m_index(-1),
m_lineNumber(-1),
m_columnNumber(-1)
{
}
......@@ -49,36 +49,36 @@ StringTextSource::~StringTextSource()
void StringTextSource::setText(const QString &text)
{
_text = text;
_index = 0;
_line_number = 1;
_column_number = 1;
m_text = text;
m_index = 0;
m_lineNumber = 1;
m_columnNumber = 1;
}
void StringTextSource::setSourceId(int source_id)
{
_source_id = source_id;
m_sourceId = source_id;
}
SourceChar StringTextSource::readNextChar()
{
QMT_CHECK(_source_id >= 0);
QMT_CHECK(_index >= 0);
QMT_CHECK(_line_number >= 0);
QMT_CHECK(_column_number >= 0);
QMT_CHECK(m_sourceId >= 0);
QMT_CHECK(m_index >= 0);
QMT_CHECK(m_lineNumber >= 0);
QMT_CHECK(m_columnNumber >= 0);
if (_index >= _text.length()) {
return SourceChar(QChar(), SourcePos(_source_id, _line_number, _column_number));
if (m_index >= m_text.length()) {
return SourceChar(QChar(), SourcePos(m_sourceId, m_lineNumber, m_columnNumber));
}
SourcePos pos(_source_id, _line_number, _column_number);
QChar ch(_text.at(_index));
++_index;
SourcePos pos(m_sourceId, m_lineNumber, m_columnNumber);
QChar ch(m_text.at(m_index));
++m_index;
if (ch == QChar::LineFeed) {
++_line_number;
_column_number = 1;
++m_lineNumber;
m_columnNumber = 1;
} else {
++_column_number;
++m_columnNumber;
}
return SourceChar(ch, pos);
}
......
......@@ -49,7 +49,7 @@ public:
void setText(const QString &text);
int getSourceId() const { return _source_id; }
int getSourceId() const { return m_sourceId; }
void setSourceId(int source_id);
......@@ -60,15 +60,15 @@ public:
private:
QString _text;
QString m_text;
int _source_id;
int m_sourceId;
int _index;
int m_index;
int _line_number;
int m_lineNumber;
int _column_number;
int m_columnNumber;
};
} // namespace qmt
......
......@@ -46,7 +46,7 @@ namespace qmt {
TextScannerError::TextScannerError(const QString &error_msg, const SourcePos &source_pos)
: Exception(error_msg),
_source_pos(source_pos)
m_sourcePos(source_pos)
{
}
......@@ -56,20 +56,20 @@ TextScannerError::~TextScannerError()
struct TextScanner::TextScannerPrivate {
TextScannerPrivate()
: _max_operator_length(0),
_source(0)
: m_maxOperatorLength(0),
m_source(0)
{
}
QHash<QString, int> _keyword_to_subtype_map;
QHash<QString, int> _operator_to_subtype_map;
int _max_operator_length;
QSet<QChar> _operator_first_chars_set;
QSet<QChar> _operator_chars_set;
ITextSource *_source;
QStack<SourceChar> _unread_source_chars;
SourcePos _last_source_pos;
QStack<Token> _unread_tokens;
QHash<QString, int> m_keywordToSubtypeMap;
QHash<QString, int> m_operatorToSubtypeMap;
int m_maxOperatorLength;
QSet<QChar> m_operatorFirstCharsSet;
QSet<QChar> m_operatorCharsSet;
ITextSource *m_source;
QStack<SourceChar> m_unreadSourceChars;
SourcePos m_lastSourcePos;
QStack<Token> m_unreadTokens;
};
TextScanner::TextScanner(QObject *parent) :
......@@ -85,45 +85,45 @@ TextScanner::~TextScanner()
void TextScanner::setKeywords(const QList<QPair<QString, int> > &keywords)
{
d->_keyword_to_subtype_map.clear();
d->m_keywordToSubtypeMap.clear();
foreach (const DefTuple &tuple, keywords) {
d->_keyword_to_subtype_map.insert(tuple.first.toLower(), tuple.second);
d->m_keywordToSubtypeMap.insert(tuple.first.toLower(), tuple.second);
}
}
void TextScanner::setOperators(const QList<QPair<QString, int> > &operators)
{
d->_operator_to_subtype_map.clear();
d->_max_operator_length = 0;
d->_operator_first_chars_set.clear();
d->_operator_chars_set.clear();
d->m_operatorToSubtypeMap.clear();
d->m_maxOperatorLength = 0;
d->m_operatorFirstCharsSet.clear();
d->m_operatorCharsSet.clear();
foreach (const DefTuple &tuple, operators) {
QString op = tuple.first;
d->_operator_to_subtype_map.insert(op, tuple.second);
if (op.length() > d->_max_operator_length) {
d->_max_operator_length = op.length();
d->m_operatorToSubtypeMap.insert(op, tuple.second);
if (op.length() > d->m_maxOperatorLength) {
d->m_maxOperatorLength = op.length();
}
d->_operator_first_chars_set.insert(op.at(0));
d->m_operatorFirstCharsSet.insert(op.at(0));
foreach (const QChar ch, op) {
d->_operator_chars_set.insert(ch);
d->m_operatorCharsSet.insert(ch);
}
}
}
void TextScanner::setSource(ITextSource *text_source)
{
d->_source = text_source;
d->m_source = text_source;
}
SourcePos TextScanner::getSourcePos() const
{
return d->_last_source_pos;
return d->m_lastSourcePos;
}
Token TextScanner::read()
{
if (!d->_unread_tokens.isEmpty()) {
return d->_unread_tokens.pop();
if (!d->m_unreadTokens.isEmpty()) {
return d->m_unreadTokens.pop();
}
skipWhitespaces();
SourceChar source_char = readChar();
......@@ -139,7 +139,7 @@ Token TextScanner::read()
return Token(Token::TOKEN_ENDOFLINE, QString(), source_char.pos);
} else if (source_char.ch.isNull()) {
return Token(Token::TOKEN_ENDOFINPUT, QString(), source_char.pos);
} else if (d->_operator_first_chars_set.contains(source_char.ch)) {
} else if (d->m_operatorFirstCharsSet.contains(source_char.ch)) {
return scanOperator(source_char);
} else {
throw TextScannerError(QStringLiteral("Unexpected character."), source_char.pos);
......@@ -148,24 +148,24 @@ Token TextScanner::read()
void TextScanner::unread(const Token &token)
{
d->_unread_tokens.push(token);
d->m_unreadTokens.push(token);
}
SourceChar TextScanner::readChar()
{
SourceChar ch;
if (!d->_unread_source_chars.isEmpty()) {
ch = d->_unread_source_chars.pop();
if (!d->m_unreadSourceChars.isEmpty()) {
ch = d->m_unreadSourceChars.pop();
} else {
ch = d->_source->readNextChar();
ch = d->m_source->readNextChar();
}
d->_last_source_pos = ch.pos;
d->m_lastSourcePos = ch.pos;
return ch;
}
void TextScanner::unreadChar(const SourceChar &source_char)
{
d->_unread_source_chars.push(source_char);
d->m_unreadSourceChars.push(source_char);
}
void TextScanner::skipWhitespaces()
......@@ -259,8 +259,8 @@ Token TextScanner::scanIdentifier(const SourceChar &first_char)
if (!source_char.ch.isLetterOrNumber() && source_char.ch != QLatin1Char('_')) {
unreadChar(source_char);
QString keyword = text.toLower();
if (d->_keyword_to_subtype_map.contains(keyword)) {
return Token(Token::TOKEN_KEYWORD, d->_keyword_to_subtype_map.value(keyword), text, first_char.pos);
if (d->m_keywordToSubtypeMap.contains(keyword)) {
return Token(Token::TOKEN_KEYWORD, d->m_keywordToSubtypeMap.value(keyword), text, first_char.pos);
}
return Token(Token::TOKEN_IDENTIFIER, text, first_char.pos);
}
......@@ -295,14 +295,14 @@ Token TextScanner::scanOperator(const SourceChar &first_char)
extra_chars.push(first_char);
for (;;) {
if (d->_operator_to_subtype_map.contains(text)) {
if (d->m_operatorToSubtypeMap.contains(text)) {
have_operator = true;
operator_length = text.length();
subtype = d->_operator_to_subtype_map.value(text);
subtype = d->m_operatorToSubtypeMap.value(text);
op = text;
}
source_char = readChar();
if (text.length() >= d->_max_operator_length || !d->_operator_chars_set.contains(source_char.ch)) {
if (text.length() >= d->m_maxOperatorLength || !d->m_operatorCharsSet.contains(source_char.ch)) {
unreadChar(source_char);
int i = text.length();
while (i > operator_length) {
......
......@@ -54,10 +54,10 @@ public:
public:
SourcePos getSourcePos() const { return _source_pos; }
SourcePos getSourcePos() const { return m_sourcePos; }
private:
SourcePos _source_pos;
SourcePos m_sourcePos;
};
......
......@@ -33,24 +33,24 @@
namespace qmt {
Token::Token()
: _type(TOKEN_UNDEFINED),
_subtype(0)
: m_type(TOKEN_UNDEFINED),
m_subtype(0)
{
}
Token::Token(Type type, const QString &text, const SourcePos &source_pos)
: _type(type),
_subtype(0),
_text(text),
_source_pos(source_pos)
: m_type(type),
m_subtype(0),
m_text(text),
m_sourcePos(source_pos)
{
}
Token::Token(Token::Type type, int subtype, const QString &text, const SourcePos &source_pos)
: _type(type),
_subtype(subtype),
_text(text),
_source_pos(source_pos)
: m_type(type),
m_subtype(subtype),
m_text(text),
m_sourcePos(source_pos)
{
}
......@@ -60,22 +60,22 @@ Token::~Token()
void Token::setType(Token::Type type)
{
_type = type;
m_type = type;
}
void Token::setSubtype(int subtype)
{
_subtype = subtype;
m_subtype = subtype;
}
void Token::setText(const QString &text)
{
_text = text;
m_text = text;
}
void Token::setSourcePos(const SourcePos &source_pos)
{
_source_pos = source_pos;
m_sourcePos = source_pos;
}
} // namespace qmt
......@@ -62,27 +62,27 @@ public:
public:
Type getType() const { return _type; }
Type getType() const { return m_type; }
void setType(Type type);
int getSubtype() const { return _subtype; }
int getSubtype() const { return m_subtype; }
void setSubtype(int subtype);
QString getText() const { return _text; }
QString getText() const { return m_text; }
void setText(const QString &text);
SourcePos getSourcePos() const { return _source_pos; }
SourcePos getSourcePos() const { return m_sourcePos; }
void setSourcePos(const SourcePos &source_pos);
private:
Type _type;
int _subtype;
QString _text;
SourcePos _source_pos;
Type m_type;
int m_subtype;
QString m_text;
SourcePos m_sourcePos;
};
} // namespace qmt
......
......@@ -43,16 +43,16 @@ protected:
Container() { }
Container(const Container<T> &rhs)
: _elements(rhs._elements)
: m_elements(rhs.m_elements)
{
rhs._elements.clear();
rhs.m_elements.clear();
}
public:
~Container()
{
qDeleteAll(_elements);
qDeleteAll(m_elements);
}
public:
......@@ -60,48 +60,48 @@ public:
Container &operator=(const Container<T> &rhs)
{
if (this != &rhs) {
qDeleteAll(_elements);
_elements = rhs._elements;
rhs._elements.clear();
qDeleteAll(m_elements);
m_elements = rhs.m_elements;
rhs.m_elements.clear();
}
return *this;
}
public:
bool isEmpty() const { return _elements.empty(); }
bool isEmpty() const { return m_elements.empty(); }