tue_serialization
include
tue
serialization
input_archive.h
Go to the documentation of this file.
1
#ifndef TUE_SERIALIZATION_INPUT_ARCHIVE_H_
2
#define TUE_SERIALIZATION_INPUT_ARCHIVE_H_
3
4
#include <
iostream
>
5
6
namespace
tue
7
{
8
namespace
serialization
9
{
10
11
class
InputArchive
{
12
13
public
:
14
15
InputArchive
(
std::istream
&
stream
) :
stream_
(
stream
) {
16
stream_
.
read
((
char
*)&
version_
,
sizeof
(
version_
));
17
}
18
19
virtual
~InputArchive
() {}
20
21
inline
InputArchive
&
operator>>
(
unsigned
char
& c) {
stream_
.
read
((
char
*)&c,
sizeof
(c));
return
*
this
; }
22
23
inline
InputArchive
&
operator>>
(
float
& f) {
stream_
.
read
((
char
*)&f,
sizeof
(f));
return
*
this
; }
24
25
inline
InputArchive
&
operator>>
(
double
& d) {
stream_
.
read
((
char
*)&d,
sizeof
(d));
return
*
this
; }
26
27
inline
InputArchive
&
operator>>
(
int
& i) {
stream_
.
read
((
char
*)&i,
sizeof
(i));
return
*
this
; }
28
29
inline
InputArchive
&
operator>>
(
std::string
& s) {
30
s.
clear
();
31
char
c;
32
while
(!
stream_
.
eof
()) {
33
stream_
.
read
(&c, 1);
34
if
(c ==
'\0'
) {
35
break
;
36
}
37
s += c;
38
}
39
return
*
this
;
40
}
41
42
inline
std::istream
&
stream
() {
return
stream_
; }
43
44
inline
int
version
() {
return
version_
; }
45
46
protected
:
47
48
std::istream
&
stream_
;
49
50
int
version_
;
51
52
};
53
54
}
55
56
}
57
58
#endif
std::string
tue::serialization::InputArchive::stream_
std::istream & stream_
Definition:
input_archive.h:48
tue::serialization::InputArchive::version_
int version_
Definition:
input_archive.h:50
tue::serialization::InputArchive::InputArchive
InputArchive(std::istream &stream)
Definition:
input_archive.h:15
std::istream::read
T read(T... args)
iostream
std::string::clear
T clear(T... args)
tue::serialization::InputArchive::stream
std::istream & stream()
Definition:
input_archive.h:42
tue::serialization::InputArchive::operator>>
InputArchive & operator>>(double &d)
Definition:
input_archive.h:25
tue::serialization::InputArchive::version
int version()
Definition:
input_archive.h:44
tue::serialization::InputArchive::~InputArchive
virtual ~InputArchive()
Definition:
input_archive.h:19
tue::serialization::InputArchive::operator>>
InputArchive & operator>>(int &i)
Definition:
input_archive.h:27
tue::serialization::InputArchive::operator>>
InputArchive & operator>>(float &f)
Definition:
input_archive.h:23
tue::serialization::InputArchive
Definition:
input_archive.h:11
tue::serialization::InputArchive::operator>>
InputArchive & operator>>(unsigned char &c)
Definition:
input_archive.h:21
std::istream
tue::serialization::InputArchive::operator>>
InputArchive & operator>>(std::string &s)
Definition:
input_archive.h:29
tue
Definition:
archive.h:9
std::istream::eof
T eof(T... args)
Generated on Sun Feb 23 2025 04:34:27 for tue_serialization by
1.8.17