1 #include "../include/animorph/FileReader.h"
2 
3 #include <locale.h>
4 
5 using namespace std;
6 using namespace Animorph;
7 
open(const std::string & filename)8 int FileReader::open (const std::string& filename)
9 {
10   ifstream &if_stream = (*this);
11 
12   // Because float-values should be 0.1 instead of 0,1
13   // in non-english if read from file. Later reset the locale
14   locale = setlocale (LC_NUMERIC, NULL);
15   setlocale (LC_NUMERIC, "C");
16 
17   if_stream.open (filename.c_str (), ios::in);
18   if (!if_stream)
19   {
20     cerr << "Couldn't open file:" << filename << endl;
21     return -1;
22   }
23 
24   return 0;
25 }
26 
close()27 void FileReader::close ()
28 {
29   ifstream &if_stream = (*this);
30 
31   // reset locale after file was written
32   setlocale (LC_NUMERIC, locale);
33 
34   if_stream.close ();
35 }
36