Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dumux
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
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
dumux-repositories
dumux
Commits
f714f582
Commit
f714f582
authored
4 years ago
by
Timo Koch
Browse files
Options
Downloads
Patches
Plain Diff
[io] Add function to read container from stream
parent
73cbb603
No related branches found
No related tags found
1 merge request
!1967
Feature/data input
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dumux/io/container.hh
+15
-4
15 additions, 4 deletions
dumux/io/container.hh
with
15 additions
and
4 deletions
dumux/io/container.hh
+
15
−
4
View file @
f714f582
...
...
@@ -55,6 +55,20 @@ void writeContainerToFile(const Container& v,
std
::
copy
(
v
.
begin
(),
v
.
end
(),
it
);
}
/*!
* \brief Read an input stream into a container
* \param stream A standard input stream
* \tparam Container The container type, requires begin(), end(), push_back() method
*/
template
<
typename
Container
>
Container
readStreamToContainer
(
std
::
istream
&
stream
)
{
Container
v
;
std
::
istream_iterator
<
typename
Container
::
value_type
>
it
(
stream
);
std
::
copy
(
it
,
std
::
istream_iterator
<
typename
Container
::
value_type
>
(),
std
::
back_inserter
(
v
));
return
v
;
}
/*!
* \brief Read a simple text file into a container
* \param filename The filename to write to
...
...
@@ -65,11 +79,8 @@ void writeContainerToFile(const Container& v,
template
<
typename
Container
>
Container
readFileToContainer
(
const
std
::
string
&
filename
)
{
Container
v
;
std
::
ifstream
infile
(
filename
,
std
::
ios
::
in
);
std
::
istream_iterator
<
typename
Container
::
value_type
>
it
(
infile
);
std
::
copy
(
it
,
std
::
istream_iterator
<
typename
Container
::
value_type
>
(),
std
::
back_inserter
(
v
));
return
v
;
return
readStreamToContainer
<
Container
>
(
infile
);
}
}
// end namespace Dumux
...
...
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