Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
c8a1b123
Commit
c8a1b123
authored
14 years ago
by
ck
Browse files
Options
Downloads
Patches
Plain Diff
ProFileWriter: Support non-file variables.
Reviewed-by: Oswald Buddenhagen
parent
bb824a74
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/shared/proparser/prowriter.cpp
+32
-20
32 additions, 20 deletions
src/shared/proparser/prowriter.cpp
src/shared/proparser/prowriter.h
+33
-4
33 additions, 4 deletions
src/shared/proparser/prowriter.h
with
65 additions
and
24 deletions
src/shared/proparser/prowriter.cpp
+
32
−
20
View file @
c8a1b123
...
...
@@ -170,10 +170,18 @@ static const ushort *skipToken(ushort tok, const ushort *&tokPtr, int &lineNo)
return
0
;
}
void
ProWriter
::
add
Fil
es
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
filePaths
,
const
QString
&
var
)
void
ProWriter
::
add
VarValu
es
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
values
,
const
QString
&
var
,
bool
valuesAreFiles
)
{
QStringList
valuesToWrite
;
if
(
valuesAreFiles
)
{
foreach
(
const
QString
&
v
,
values
)
valuesToWrite
<<
proFileDir
.
relativeFilePath
(
v
);
}
else
{
valuesToWrite
=
values
;
}
// Check if variable item exists as child of root item
const
ushort
*
tokPtr
=
(
const
ushort
*
)
profile
->
items
().
constData
();
int
lineNo
=
0
;
...
...
@@ -201,9 +209,8 @@ void ProWriter::addFiles(ProFile *profile, QStringList *lines,
}
}
QString
added
;
foreach
(
const
QString
&
filePath
,
filePaths
)
added
+=
QLatin1String
(
" "
)
+
proFileDir
.
relativeFilePath
(
filePath
)
+
QLatin1String
(
"
\\\n
"
);
foreach
(
const
QString
&
v
,
valuesToWrite
)
added
+=
QLatin1String
(
" "
)
+
v
+
QLatin1String
(
"
\\\n
"
);
added
.
chop
(
3
);
lines
->
insert
(
lineNo
,
added
);
return
;
...
...
@@ -216,8 +223,8 @@ void ProWriter::addFiles(ProFile *profile, QStringList *lines,
// Create & append new variable item
QString
added
=
QLatin1Char
(
'\n'
)
+
var
+
QLatin1String
(
" +="
);
foreach
(
const
QString
&
filePath
,
filePaths
)
added
+=
QLatin1String
(
"
\\\n
"
)
+
proFileDir
.
relativeFilePath
(
filePath
)
;
foreach
(
const
QString
&
v
,
valuesToWrite
)
added
+=
QLatin1String
(
"
\\\n
"
)
+
v
;
*
lines
<<
added
;
}
...
...
@@ -245,20 +252,24 @@ static void findProVariables(const ushort *tokPtr, const QStringList &vars,
}
}
QStringList
ProWriter
::
remove
Fil
es
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
filePath
s
,
const
QStringList
&
var
s
)
QStringList
ProWriter
::
remove
VarValu
es
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
values
,
const
QStringList
&
var
s
,
bool
valuesAreFile
s
)
{
QStringList
notChanged
=
filePath
s
;
QStringList
notChanged
=
value
s
;
QList
<
int
>
varLines
;
findProVariables
((
const
ushort
*
)
profile
->
items
().
constData
(),
vars
,
&
varLines
);
// This is a tad stupid - basically, it can remove only entries which
// the above code added.
QStringList
relativeFilePaths
;
foreach
(
const
QString
&
absoluteFilePath
,
filePaths
)
relativeFilePaths
<<
proFileDir
.
relativeFilePath
(
absoluteFilePath
);
QStringList
valuesToFind
;
if
(
valuesAreFiles
)
{
// This is a tad stupid - basically, it can remove only entries which
// the above code added.
foreach
(
const
QString
&
absoluteFilePath
,
values
)
valuesToFind
<<
proFileDir
.
relativeFilePath
(
absoluteFilePath
);
}
else
{
valuesToFind
=
values
;
}
// This code expects proVars to be sorted by the variables' appearance in the file.
int
delta
=
1
;
...
...
@@ -310,9 +321,10 @@ QStringList ProWriter::removeFiles(ProFile *profile, QStringList *lines,
break
;
colNo
++
;
}
QString
fn
=
line
.
mid
(
varCol
,
colNo
-
varCol
);
if
(
relativeFilePaths
.
contains
(
fn
))
{
notChanged
.
removeOne
(
QDir
::
cleanPath
(
proFileDir
.
absoluteFilePath
(
fn
)));
const
QString
fn
=
line
.
mid
(
varCol
,
colNo
-
varCol
);
const
int
pos
=
valuesToFind
.
indexOf
(
fn
);
if
(
pos
!=
-
1
)
{
notChanged
.
removeOne
(
values
.
at
(
pos
));
if
(
colNo
<
lineLen
)
colNo
++
;
else
if
(
varCol
)
...
...
This diff is collapsed.
Click to expand it.
src/shared/proparser/prowriter.h
+
33
−
4
View file @
c8a1b123
...
...
@@ -46,11 +46,40 @@ class ProWriter
{
public:
static
void
addFiles
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
filePaths
,
const
QString
&
var
);
const
QDir
&
proFileDir
,
const
QStringList
&
filePaths
,
const
QString
&
var
)
{
addVarValues
(
profile
,
lines
,
proFileDir
,
filePaths
,
var
,
true
);
}
static
QStringList
removeFiles
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
filePaths
,
const
QStringList
&
vars
);
const
QDir
&
proFileDir
,
const
QStringList
&
filePaths
,
const
QStringList
&
vars
)
{
return
removeVarValues
(
profile
,
lines
,
proFileDir
,
filePaths
,
vars
,
true
);
}
static
void
addVarValues
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
values
,
const
QString
&
var
)
{
addVarValues
(
profile
,
lines
,
proFileDir
,
values
,
var
,
false
);
}
static
QStringList
removeVarValues
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
values
,
const
QStringList
&
vars
)
{
return
removeVarValues
(
profile
,
lines
,
proFileDir
,
values
,
vars
,
false
);
}
private
:
static
void
addVarValues
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
values
,
const
QString
&
var
,
bool
valuesAreFiles
);
static
QStringList
removeVarValues
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
values
,
const
QStringList
&
vars
,
bool
valuesAreFiles
);
};
}
// namespace Internal
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment