Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Core Modules
dune-common
Commits
1b7b0705
Commit
1b7b0705
authored
20 years ago
by
Robert Klöfkorn
Browse files
Options
Downloads
Patches
Plain Diff
function readParameter parses ascii file for keywords and reads paramters.
[[Imported from SVN: r1256]]
parent
6a0b02a4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
io/file/asciiparser.hh
+76
-0
76 additions, 0 deletions
io/file/asciiparser.hh
with
76 additions
and
0 deletions
io/file/asciiparser.hh
0 → 100644
+
76
−
0
View file @
1b7b0705
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef __DUNE_ASCIIPARSER_HH__
#define __DUNE_ASCIIPARSER_HH__
namespace
Dune
{
static
const
int
MAXTAB
=
30
;
//! reads data folowing the given keyword
//! if verbose is true then an output of what was read is given
//! the token '%' stands for comment
template
<
class
T
>
bool
readParameter
(
const
char
*
filename
,
const
char
keywd
[],
T
&
data
,
bool
verbose
=
true
)
{
std
::
fstream
file
(
filename
,
std
::
ios
::
in
);
std
::
basic_string
<
char
>
keyword
(
keywd
);
bool
readData
=
false
;
char
ch
[
1024
];
while
(
!
file
.
eof
()
)
{
std
::
basic_string
<
char
>
keyHelp
;
file
>>
keyHelp
;
if
(
keyHelp
[
0
]
==
'%'
)
{
file
.
getline
(
ch
,
1024
,
'\n'
);
}
else
{
// copy only keyword size and compare
int
pos
=
keyHelp
.
find_first_of
(
':'
);
int
pos1
=
keyHelp
.
find_first_of
(
' '
);
if
(
pos
>
0
)
{
if
(
pos1
>
0
)
pos
-=
pos1
;
else
pos
=
1
;
}
else
pos
=
0
;
std
::
basic_string
<
char
>
key
(
keyHelp
,
0
,
keyHelp
.
size
()
-
pos
);
if
(
key
==
keyword
)
{
file
>>
data
;
readData
=
true
;
break
;
}
}
}
file
.
close
();
if
(
readData
)
{
if
(
verbose
)
{
int
length
=
MAXTAB
-
keyword
.
size
();
std
::
cout
<<
"Reading "
<<
keyword
;
for
(
int
i
=
0
;
i
<
length
;
i
++
)
std
::
cout
<<
"."
;
std
::
cout
<<
" "
<<
data
<<
"
\n
"
;;
}
}
else
{
std
::
cerr
<<
"WARNING: couldn't read "
<<
keyword
<<
"
\n
"
;
}
return
readData
;
}
}
// end namespace
#endif
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