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
}
n
Vec3f n
sotDEBUGOUT
#define sotDEBUGOUT(level)
Definition:
debug.hh:212
dynamicgraph::sot::Contiifstream::first
bool first
Definition:
contiifstream.hh:42
dynamicgraph::sot::Contiifstream::cursor
std::streamoff cursor
Definition:
contiifstream.hh:38
dynamicgraph::sot::Contiifstream::buffer
char buffer[BUFFER_SIZE]
Definition:
contiifstream.hh:40
sotDEBUGIN
#define sotDEBUGIN(level)
Definition:
debug.hh:211
dynamicgraph::sot::Contiifstream::filename
std::string filename
Definition:
contiifstream.hh:37
sotDEBUGINOUT
#define sotDEBUGINOUT(level)
Definition:
debug.hh:213
dynamicgraph::sot::Contiifstream::~Contiifstream
~Contiifstream(void)
Definition:
contiifstream.cpp:18
debug.hh
dynamicgraph::sot::Contiifstream::reader
std::list< std::string > reader
Definition:
contiifstream.hh:41
sotDEBUG
#define sotDEBUG(level)
Definition:
debug.hh:165
dynamicgraph::sot::Contiifstream::next
std::string next(void)
Definition:
contiifstream.cpp:49
contiifstream.hh
res
res
dynamicgraph::sot
dynamicgraph::sot::Contiifstream::Contiifstream
Contiifstream(const std::string &n="")
Definition:
contiifstream.cpp:15
dynamicgraph::sot::Contiifstream::loop
bool loop(void)
Definition:
contiifstream.cpp:20
filename
filename
line
int line
dynamicgraph::sot::Contiifstream::BUFFER_SIZE
static const unsigned int BUFFER_SIZE
Definition:
contiifstream.hh:39
sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Wed Jun 21 2023 02:51:26