src
debug
contiifstream.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2010,
3
* François Bleibel,
4
* Olivier Stasse,
5
*
6
* CNRS/AIST
7
*
8
*/
9
10
#include <
sot/core/contiifstream.hh
>
11
#include <
sot/core/debug.hh
>
12
13
using namespace
dynamicgraph::sot
;
14
15
Contiifstream::Contiifstream
(
const
std::string &
n
)
16
:
filename
(
n
), cursor(0), first(true) {}
17
18
Contiifstream::~Contiifstream
(
void
) {
sotDEBUGINOUT
(5); }
19
20
bool
Contiifstream::loop
(
void
) {
21
sotDEBUGIN
(25);
22
bool
res
=
false
;
23
24
std::fstream file(
filename
.c_str());
25
26
file.seekg(
cursor
);
27
file.sync();
28
29
while
(1) {
30
file.get(
buffer
,
BUFFER_SIZE
);
31
if
(file.gcount()) {
32
res
=
true
;
33
std::string
line
(
buffer
);
34
if
(!
first
)
reader
.push_back(
line
);
35
cursor
= file.tellg();
36
cursor
++;
37
file.get(*
buffer
);
// get the last char ( = '\n')
38
sotDEBUG
(15) <<
"line: "
<<
line
<< std::endl;
39
}
else
{
40
break
;
41
}
42
}
43
44
first
=
false
;
45
sotDEBUGOUT
(25);
46
return
res
;
47
}
48
49
std::string
Contiifstream::next
(
void
) {
50
std::string
res
= *
reader
.begin();
51
reader
.pop_front();
52
return
res
;
53
}
dynamicgraph::sot::Contiifstream::~Contiifstream
~Contiifstream(void)
Definition:
contiifstream.cpp:18
dynamicgraph::sot::Contiifstream::first
bool first
Definition:
contiifstream.hh:42
dynamicgraph::sot::Contiifstream::buffer
char buffer[BUFFER_SIZE]
Definition:
contiifstream.hh:40
debug.hh
dynamicgraph::sot::Contiifstream::cursor
std::streamoff cursor
Definition:
contiifstream.hh:38
res
res
sotDEBUGOUT
#define sotDEBUGOUT(level)
Definition:
debug.hh:215
dynamicgraph::sot::Contiifstream::Contiifstream
Contiifstream(const std::string &n="")
Definition:
contiifstream.cpp:15
sotDEBUGINOUT
#define sotDEBUGINOUT(level)
Definition:
debug.hh:216
filename
filename
dynamicgraph::sot::Contiifstream::reader
std::list< std::string > reader
Definition:
contiifstream.hh:41
sotDEBUGIN
#define sotDEBUGIN(level)
Definition:
debug.hh:214
dynamicgraph::sot::Contiifstream::BUFFER_SIZE
static const std::size_t BUFFER_SIZE
Definition:
contiifstream.hh:39
dynamicgraph::sot::Contiifstream::next
std::string next(void)
Definition:
contiifstream.cpp:49
dynamicgraph::sot
dynamicgraph::sot::Contiifstream::filename
std::string filename
Definition:
contiifstream.hh:37
contiifstream.hh
dynamicgraph::sot::Contiifstream::loop
bool loop(void)
Definition:
contiifstream.cpp:20
line
int line
n
Vec3f n
sotDEBUG
#define sotDEBUG(level)
Definition:
debug.hh:168
sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:31