SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
BinaryInputDevice.cpp
Go to the documentation of this file.
1
/****************************************************************************/
8
// Encapsulates binary reading operations on a file
9
/****************************************************************************/
10
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
11
// Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
12
/****************************************************************************/
13
//
14
// This file is part of SUMO.
15
// SUMO is free software: you can redistribute it and/or modify
16
// it under the terms of the GNU General Public License as published by
17
// the Free Software Foundation, either version 3 of the License, or
18
// (at your option) any later version.
19
//
20
/****************************************************************************/
21
22
23
// ===========================================================================
24
// included modules
25
// ===========================================================================
26
#ifdef _MSC_VER
27
#include <
windows_config.h
>
28
#else
29
#include <
config.h
>
30
#endif
31
32
#include <string>
33
#include "
BinaryInputDevice.h
"
34
35
#ifdef CHECK_MEMORY_LEAKS
36
#include <
foreign/nvwa/debug_new.h
>
37
#endif // CHECK_MEMORY_LEAKS
38
39
// ===========================================================================
40
// constants definitions
41
// ===========================================================================
42
#define BUF_MAX 1000
43
44
45
// ===========================================================================
46
// method definitions
47
// ===========================================================================
48
BinaryInputDevice::BinaryInputDevice
(
const
std::string& name)
49
: myStream(name.c_str(), std::fstream::in | std::fstream::binary) {}
50
51
52
BinaryInputDevice::~BinaryInputDevice
() {}
53
54
55
bool
56
BinaryInputDevice::good
()
const
{
57
return
myStream
.good();
58
}
59
60
61
BinaryInputDevice
&
62
operator>>
(
BinaryInputDevice
& os,
int
& i) {
63
os.
myStream
.read((
char
*) &i,
sizeof
(
int
));
64
return
os;
65
}
66
67
68
BinaryInputDevice
&
69
operator>>
(
BinaryInputDevice
& os,
unsigned
int
& i) {
70
os.
myStream
.read((
char
*) &i,
sizeof
(
unsigned
int
));
71
return
os;
72
}
73
74
75
BinaryInputDevice
&
76
operator>>
(
BinaryInputDevice
& os,
SUMOReal
& f) {
77
os.
myStream
.read((
char
*) &f,
sizeof
(
SUMOReal
));
78
return
os;
79
}
80
81
82
BinaryInputDevice
&
83
operator>>
(
BinaryInputDevice
& os,
bool
& b) {
84
b = 0;
85
os.
myStream
.read((
char
*) &b,
sizeof
(
char
));
86
return
os;
87
}
88
89
90
BinaryInputDevice
&
91
operator>>
(
BinaryInputDevice
& os, std::string& s) {
92
unsigned
int
size;
93
os >> size;
94
if
(size <
BUF_MAX
) {
95
os.
myStream
.read((
char
*) &os.
myBuffer
,
sizeof
(
char
)*size);
96
os.
myBuffer
[size] = 0;
97
s = std::string(os.
myBuffer
);
98
return
os;
99
}
100
return
os;
101
}
102
103
104
BinaryInputDevice
&
105
operator>>
(
BinaryInputDevice
& os,
long
& l) {
106
os.
myStream
.read((
char
*) &l,
sizeof
(
long
));
107
return
os;
108
}
109
110
111
112
/****************************************************************************/
113
tmp
buildd
sumo-0.15.0~dfsg
src
utils
iodevices
BinaryInputDevice.cpp
Generated on Sun May 27 2012 14:52:03 for SUMO - Simulation of Urban MObility by
1.8.1