IOFunctions.cpp
Go to the documentation of this file.
1 #include "IOFunctions.h"
2 
3 namespace PointMatcherSupport
4 {
5 
6 
7 std::istream & safeGetLine( std::istream& is, std::string & t)
8 {
9  t.clear();
10 
11  // The characters in the stream are read one-by-one using a std::streambuf.
12  // That is faster than reading them one-by-one using the std::istream.
13  // Code that uses streambuf this way must be guarded by a sentry object.
14  // The sentry object performs various tasks,
15  // such as thread synchronization and updating the stream state.
16 
17  std::istream::sentry se(is, true);
18  std::streambuf* sb = is.rdbuf();
19 
20  for(;;) {
21  int c = sb->sbumpc();
22  switch (c) {
23  case '\n':
24  return is;
25  case '\r':
26  if(sb->sgetc() == '\n')
27  sb->sbumpc();
28  return is;
29  case EOF:
30  // Also handle the case when the last line has no line ending
31  if(t.empty())
32  is.setstate(std::ios::eofbit);
33  return is;
34  default:
35  t += (char)c;
36  }
37  }
38 }
39 
40 }// namespace PointMatcherSupport
testing::internal::string
::std::string string
Definition: gtest.h:1979
IOFunctions.h
PointMatcherSupport::safeGetLine
std::istream & safeGetLine(std::istream &is, std::string &t)
Replaces getline for handling windows style CR/LF line endings.
Definition: IOFunctions.cpp:7
PointMatcherSupport
Functions and classes that are not dependant on scalar type are defined in this namespace.
Definition: Bibliography.cpp:45
t
geometry_msgs::TransformStamped t


mp2p_icp
Author(s):
autogenerated on Wed Oct 23 2024 02:45:40