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 
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 
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 }
Vec3f n
#define sotDEBUGOUT(level)
Definition: debug.hh:212
#define sotDEBUGIN(level)
Definition: debug.hh:211
#define sotDEBUGINOUT(level)
Definition: debug.hh:213
std::list< std::string > reader
#define sotDEBUG(level)
Definition: debug.hh:165
res
Contiifstream(const std::string &n="")
filename
int line
static const unsigned int BUFFER_SIZE


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Wed Jun 21 2023 02:51:26