Simpatico
v1.10
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
src
util
archives
TextFileOArchive.cpp
1
/*
2
* Util Package - C++ Utilities for Scientific Computation
3
*
4
* Copyright 2010 - 2017, The Regents of the University of Minnesota
5
* Distributed under the terms of the GNU General Public License.
6
*/
7
8
#include "TextFileOArchive.h"
9
10
namespace
Util
11
{
12
13
/*
14
* Constructor.
15
*/
16
TextFileOArchive::TextFileOArchive
()
17
: filePtr_(0),
18
version_(0),
19
createdFile_(true)
20
{ filePtr_ =
new
std::ofstream(); }
21
22
/*
23
* Constructor.
24
*/
25
TextFileOArchive::TextFileOArchive
(std::string filename)
26
: filePtr_(0),
27
version_(0),
28
createdFile_(true)
29
{ filePtr_ =
new
std::ofstream(filename.c_str()); }
30
31
32
/*
33
* Constructor.
34
*/
35
TextFileOArchive::TextFileOArchive
(std::ofstream&
file
)
36
: filePtr_(&file),
37
version_(0),
38
createdFile_(false)
39
{
40
if
(!file.is_open()) {
41
UTIL_THROW
(
"File not open"
);
42
}
43
}
44
45
/*
46
* Destructor.
47
*/
48
TextFileOArchive::~TextFileOArchive
()
49
{
50
if
(filePtr_ && createdFile_) {
51
delete
filePtr_;
52
}
53
}
54
55
/*
56
* Return underlying file by reference.
57
*/
58
std::ofstream&
TextFileOArchive::file
()
59
{
return
*filePtr_; }
60
61
}
Util::TextFileOArchive::file
std::ofstream & file()
Get the underlying ifstream by reference.
Definition:
TextFileOArchive.cpp:58
UTIL_THROW
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Definition:
global.h:51
Util::TextFileOArchive::~TextFileOArchive
virtual ~TextFileOArchive()
Destructor.
Definition:
TextFileOArchive.cpp:48
Util
Utility classes for scientific computation.
Definition:
accumulators.mod:1
Util::TextFileOArchive::TextFileOArchive
TextFileOArchive()
Constructor.
Definition:
TextFileOArchive.cpp:16
Generated on Wed Mar 7 2018 12:59:44 for Simpatico by
1.8.11