forked from rtbkit/rtbkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathportable_oarchive.cc
77 lines (58 loc) · 1.94 KB
/
portable_oarchive.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* portable_oarchive.cc
Jeremy Barnes, 20 March 2005
Copyright (c) 2005 Jeremy Barnes. All rights reserved.
This file is part of "Jeremy's Machine Learning Library", copyright (c)
1999-2005 Jeremy Barnes.
This program is available under the GNU General Public License, the terms
of which are given by the file "license.txt" in the top level directory of
the source code distribution. If this file is missing, you have no right
to use the program; please contact the author.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
---
Implementation of the portable oarchive.
*/
#include "portable_oarchive.h"
#include "nested_archive.h"
#include "jml/utils/filter_streams.h"
using namespace std;
namespace ML {
namespace DB {
/*****************************************************************************/
/* PORTABLE_BIN_OARCHIVE */
/*****************************************************************************/
portable_bin_oarchive::portable_bin_oarchive()
: stream(0), offset_(0)
{
}
portable_bin_oarchive::portable_bin_oarchive(const std::string & filename)
: stream(new filter_ostream(filename)), owned_stream(stream),
offset_(0)
{
}
portable_bin_oarchive::portable_bin_oarchive(std::ostream & stream)
: stream(&stream), offset_(0)
{
}
void portable_bin_oarchive::open(const std::string & filename)
{
stream = new filter_ostream(filename.c_str());
owned_stream.reset(stream);
offset_ = 0;
}
void portable_bin_oarchive::open(std::ostream & stream)
{
this->stream = &stream;
owned_stream.reset();
offset_ = 0;
}
void
portable_bin_oarchive::
save(const Nested_Writer & writer)
{
writer.serialize(*this);
}
} // namespace DB
} // namespace ML