[umbrello-devel] [PATCH 3/3] Get rid of the PositionFilename typedef and use QString directly.
Raphael Kubo da Costa
rakuco at FreeBSD.org
Sun Nov 3 13:12:20 UTC 2013
After the previous commit simplified PositionFilename and changed it into a
QString typedef, we can now safely remove it and use QString directly.
Doing so allows us to avoid some needless conversions and possibly makes the
code easier to follow.
---
umbrello/codeimport/kdevcppparser/driver.cpp | 2 +-
umbrello/codeimport/kdevcppparser/lexer.cpp | 2 +-
umbrello/codeimport/kdevcppparser/lexer.h | 6 +++---
umbrello/codeimport/kdevcppparser/position.h | 5 ++---
umbrello/codeimport/kdevcppparser/preprocesslexer.cpp | 2 +-
umbrello/codeimport/kdevcppparser/preprocesslexer.h | 4 ++--
6 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/umbrello/codeimport/kdevcppparser/driver.cpp b/umbrello/codeimport/kdevcppparser/driver.cpp
index 1693928..54c3957 100644
--- a/umbrello/codeimport/kdevcppparser/driver.cpp
+++ b/umbrello/codeimport/kdevcppparser/driver.cpp
@@ -234,7 +234,7 @@ bool Driver::parseFile(const QString& fileName, bool onlyPreProcess, bool force)
lexer = &lex;
setupLexer(&lex);
- if (!lex.setSource(sourceProvider()->contents(fileName), PositionFilename(fileName)))
+ if (!lex.setSource(sourceProvider()->contents(fileName), fileName))
return false;
if(!onlyPreProcess){
diff --git a/umbrello/codeimport/kdevcppparser/lexer.cpp b/umbrello/codeimport/kdevcppparser/lexer.cpp
index 8bf9fce..b9be267 100644
--- a/umbrello/codeimport/kdevcppparser/lexer.cpp
+++ b/umbrello/codeimport/kdevcppparser/lexer.cpp
@@ -325,7 +325,7 @@ Lexer::~Lexer()
}
bool Lexer::setSource(const QString& source,
- PositionFilename const& p_filename)
+ const QString& p_filename)
{
reset();
m_preprocessLexer.setSource(source, p_filename);
diff --git a/umbrello/codeimport/kdevcppparser/lexer.h b/umbrello/codeimport/kdevcppparser/lexer.h
index 49b7d43..4c838db 100644
--- a/umbrello/codeimport/kdevcppparser/lexer.h
+++ b/umbrello/codeimport/kdevcppparser/lexer.h
@@ -70,7 +70,7 @@ public:
const QString& str = QString())
{ m_preprocessLexer.addSkipWord(word, skipType, str); }
- bool setSource(const QString& source, PositionFilename const& p_filename);
+ bool setSource(const QString& source, const QString& p_filename);
void setRecordComments(bool record);
Position currentPosition() const { return m_source.get_currentPosition(); }
@@ -131,7 +131,7 @@ private:
m_startLine = true;
}
- void set_filename(PositionFilename const& p_filename) { m_filename = p_filename; }
+ void set_filename(const QString& p_filename) { m_filename = p_filename; }
void set_source(QString const& source) {
m_ptr = CharIterator(source.data(),
source.data() + source.length(),
@@ -144,7 +144,7 @@ private:
// setters
void set_startLine(bool p) {m_startLine = p;}
private:
- PositionFilename m_filename;
+ QString m_filename;
CharIterator m_ptr;
const CharIterator m_endPtr;
bool m_startLine;
diff --git a/umbrello/codeimport/kdevcppparser/position.h b/umbrello/codeimport/kdevcppparser/position.h
index 32c911c..3881e72 100644
--- a/umbrello/codeimport/kdevcppparser/position.h
+++ b/umbrello/codeimport/kdevcppparser/position.h
@@ -27,8 +27,7 @@
#include <QChar>
#include <QDebug>
-typedef QString PositionFilename;
-typedef boost::spirit::classic::file_position_base<PositionFilename> PositionType;
+typedef boost::spirit::classic::file_position_base<QString> PositionType;
class Position : public PositionType
{
@@ -37,7 +36,7 @@ public:
{
}
- explicit Position(const PositionFilename &p) : PositionType(p)
+ explicit Position(const QString& fileName) : PositionType(fileName)
{
}
diff --git a/umbrello/codeimport/kdevcppparser/preprocesslexer.cpp b/umbrello/codeimport/kdevcppparser/preprocesslexer.cpp
index 8c4a65f..c7dbd29 100644
--- a/umbrello/codeimport/kdevcppparser/preprocesslexer.cpp
+++ b/umbrello/codeimport/kdevcppparser/preprocesslexer.cpp
@@ -312,7 +312,7 @@ PreprocessLexer::~PreprocessLexer()
}
void PreprocessLexer::setSource(const QString& source,
- PositionFilename const& p_filename)
+ const QString& p_filename)
{
reset();
m_source.set_source(source, p_filename);
diff --git a/umbrello/codeimport/kdevcppparser/preprocesslexer.h b/umbrello/codeimport/kdevcppparser/preprocesslexer.h
index f5a6352..55136b8 100644
--- a/umbrello/codeimport/kdevcppparser/preprocesslexer.h
+++ b/umbrello/codeimport/kdevcppparser/preprocesslexer.h
@@ -201,7 +201,7 @@ public:
void addSkipWord(const QString& word, SkipType skipType = SkipWord,
const QString& str = QString());
bool preprocess();
- void setSource(const QString& source, PositionFilename const& p_filename);
+ void setSource(const QString& source, const QString& p_filename);
void setRecordComments(bool record);
QString const& preprocessedString() const {return m_preprocessedString;}
private:
@@ -280,7 +280,7 @@ private:
m_ptr = CharIterator();
}
void set_source(const QString& source,
- PositionFilename const& p_filename) {
+ const QString& p_filename) {
m_source = source;
m_ptr = CharIterator(m_source.data(),
m_source.data() + m_source.length(),
--
1.8.4.2
More information about the umbrello-devel
mailing list