aimstil  5.0.5
io.tpp
Go to the documentation of this file.
1 #include <stdlib.h>
2 
3 namespace til { namespace io
4 {
5 
6  //---------------------------------------------------------------------------
7 
8  template < typename TIterator, typename TProgressIndicator >
9  void
10  SimpleLoader< TIterator, TProgressIndicator >::
11  operator()(const char * filename, TIterator begin)
12  {
13  std::ifstream f(filename);
14  if (!f) throw CannotOpenFile();
15  std::string tmp;
16  std::size_t i = 0;
17  while (!std::getline(f, m_buffer).eof())
18  {
19  m_indicator(i);
20  std::istringstream linestream(m_buffer);
21  while (getline(linestream, tmp, ' '))
22  {
23  *begin = strtof(tmp.c_str(), 0);
24  ++begin;
25  ++i;
26  }
27  }
28  }
29 
30  //---------------------------------------------------------------------------
31 
32  template < typename TIterator, typename TProgressIndicator >
33  void
34  SimpleLoader< TIterator, TProgressIndicator >::
35  operator()(const std::string & filename, TIterator begin)
36  {
37  (*this)(filename.c_str(), begin);
38  }
39 
40  //---------------------------------------------------------------------------
41 
42 }} // namespace til::io
43 
44