GCC Code Coverage Report


Directory: ./
File: src/debug/contiifstream.cpp
Date: 2024-12-13 12:22:33
Exec Total Coverage
Lines: 0 24 0.0%
Branches: 0 24 0.0%

Line Branch Exec Source
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 }
54