Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91899636
csv_writer.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Nov 15, 14:12
Size
874 B
Mime Type
text/x-c
Expires
Sun, Nov 17, 14:12 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22326521
Attached To
R9490 Homework_sp4e_Peruzzo_SáezUribe
csv_writer.cc
View Options
#include "csv_writer.hh"
#include <cstdlib>
#include <fstream>
/* -------------------------------------------------------------------------- */
CsvWriter
::
CsvWriter
(
const
std
::
string
&
filename
)
:
filename
(
filename
)
{}
/* -------------------------------------------------------------------------- */
void
CsvWriter
::
write
(
System
&
system
)
{
this
->
compute
(
system
);
}
/* -------------------------------------------------------------------------- */
void
CsvWriter
::
compute
(
System
&
system
)
{
std
::
ofstream
os
(
filename
.
c_str
());
if
(
os
.
is_open
()
==
false
)
{
std
::
cerr
<<
"cannot open file "
<<
filename
<<
std
::
endl
<<
"check that the dumps folder exists"
<<
std
::
endl
;
std
::
exit
(
1
);
}
UInt
nb_particles
=
system
.
getNbParticles
();
for
(
UInt
p
=
0
;
p
<
nb_particles
;
++
p
)
{
os
<<
system
.
getParticle
(
p
)
<<
std
::
endl
;
}
os
.
close
();
}
Event Timeline
Log In to Comment