Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
openfoam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor 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
Development
openfoam
Commits
c6bcd65d
Commit
c6bcd65d
authored
8 years ago
by
Mark OLESEN
Browse files
Options
Downloads
Patches
Plain Diff
STYLE: minor simplification of coding in dictionary
parent
f05be160
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/OpenFOAM/db/dictionary/dictionary.C
+72
-87
72 additions, 87 deletions
src/OpenFOAM/db/dictionary/dictionary.C
with
72 additions
and
87 deletions
src/OpenFOAM/db/dictionary/dictionary.C
+
72
−
87
View file @
c6bcd65d
...
...
@@ -60,114 +60,101 @@ const Foam::entry* Foam::dictionary::lookupScopedSubEntryPtr
// Non-scoped lookup
return
lookupEntryPtr
(
keyword
,
recursive
,
patternMatch
);
}
else
else
if
(
dotPos
==
0
)
{
if
(
dotPos
==
0
)
{
// Starting with a '.'. Go up for every 2nd '.' found
// Starting with a '.' -> go up for every further '.' found
++
dotPos
;
const
dictionary
*
dictPtr
=
this
;
string
::
size_type
begVar
=
dotPos
+
1
;
string
::
const_iterator
iter
=
keyword
.
begin
()
+
begVar
;
string
::
size_type
endVar
=
begVar
;
while
(
iter
!=
keyword
.
end
()
&&
*
iter
==
'.'
)
const
dictionary
*
dictPtr
=
this
;
for
(
string
::
const_iterator
it
=
keyword
.
begin
()
+
1
;
it
!=
keyword
.
end
()
&&
*
it
==
'.'
;
++
dotPos
,
++
it
)
{
// Go to parent
if
(
&
dictPtr
->
parent_
!=
&
dictionary
::
null
)
{
++
iter
;
++
endVar
;
// Go to parent
if
(
&
dictPtr
->
parent_
==
&
dictionary
::
null
)
{
FatalIOErrorInFunction
(
*
this
)
<<
"No parent of current dictionary"
<<
" when searching for "
<<
keyword
.
substr
(
begVar
,
keyword
.
size
()
-
begVar
)
<<
exit
(
FatalIOError
);
}
dictPtr
=
&
dictPtr
->
parent_
;
}
else
{
FatalIOErrorInFunction
(
*
this
)
<<
"No parent of current dictionary when searching for "
<<
keyword
.
substr
(
1
)
<<
exit
(
FatalIOError
);
return
dictPtr
->
lookupScopedSubEntryPtr
(
keyword
.
substr
(
endVar
),
false
,
patternMatch
);
return
nullptr
;
}
}
else
{
// Extract the first word
const
word
firstWord
=
keyword
.
substr
(
0
,
dotPos
);
const
entry
*
entPtr
=
lookupScopedSubEntryPtr
(
firstWord
,
false
,
//recursive
patternMatch
);
return
dictPtr
->
lookupScopedSubEntryPtr
(
keyword
.
substr
(
dotPos
),
false
,
patternMatch
);
}
else
{
// The first word
const
entry
*
entPtr
=
lookupScopedSubEntryPtr
(
keyword
.
substr
(
0
,
dotPos
),
false
,
patternMatch
);
if
(
!
entPtr
)
{
// Fall back to finding key with '.' so e.g. if keyword is
// a.b.c.d it would try
// a.b, a.b.c, a.b.c.d
if
(
!
entPtr
)
while
(
true
)
{
// Fall back to finding key with '.' so e.g. if keyword is
// a.b.c.d it would try
// a.b, a.b.c, a.b.c.d
dotPos
=
keyword
.
find
(
'.'
,
dotPos
+
1
);
string
::
size_type
nextDotPos
=
keyword
.
find
entPtr
=
lookupEntryPtr
(
'.'
,
dotPos
+
1
keyword
.
substr
(
0
,
dotPos
),
false
,
patternMatch
);
while
(
true
)
if
(
dotPos
==
string
::
npos
)
{
// Parsed the whole word. Return entry or null.
return
entPtr
;
}
if
(
entPtr
&&
entPtr
->
isDict
())
{
const
entry
*
subEntPtr
=
lookup
EntryPtr
return
entPtr
->
dict
().
lookupScopedSub
EntryPtr
(
keyword
.
substr
(
0
,
nextD
otPos
),
keyword
.
substr
(
d
otPos
),
false
,
patternMatch
);
if
(
nextDotPos
==
string
::
npos
)
{
// Parsed the whole word. Return entry or null.
return
subEntPtr
;
}
if
(
subEntPtr
&&
subEntPtr
->
isDict
())
{
return
subEntPtr
->
dict
().
lookupScopedSubEntryPtr
(
keyword
.
substr
(
nextDotPos
,
keyword
.
size
()
-
nextDotPos
),
false
,
patternMatch
);
}
nextDotPos
=
keyword
.
find
(
'.'
,
nextDotPos
+
1
);
}
}
}
if
(
entPtr
->
isDict
())
{
return
entPtr
->
dict
().
lookupScopedSubEntryPtr
(
keyword
.
substr
(
dotPos
,
keyword
.
size
()
-
dotPos
),
false
,
patternMatch
);
}
else
{
return
nullptr
;
}
if
(
entPtr
->
isDict
())
{
return
entPtr
->
dict
().
lookupScopedSubEntryPtr
(
keyword
.
substr
(
dotPos
),
false
,
patternMatch
);
}
}
return
nullptr
;
}
...
...
@@ -597,10 +584,9 @@ const Foam::entry* Foam::dictionary::lookupScopedEntryPtr
dictPtr
=
&
dictPtr
->
parent_
;
}
// At top. Recurse to find entries
return
dictPtr
->
lookupScopedSubEntryPtr
(
keyword
.
substr
(
1
,
keyword
.
size
()
-
1
),
keyword
.
substr
(
1
),
false
,
patternMatch
);
...
...
@@ -1038,7 +1024,6 @@ bool Foam::dictionary::changeKeyword
IDLList
<
entry
>::
replace
(
iter2
(),
iter
());
delete
iter2
();
hashedEntries_
.
erase
(
iter2
);
}
else
{
...
...
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