+ /**
+ * @returns \p false when file is incorrect, \p true otherwise.
+ * Check file with name \p theFileName for correct terminate
+ * string, i.e. the next to the last line is equal to " -1",
+ */
+ inline bool check_file(const std::string theFileName)
+ {
+ std::ifstream in_stream(theFileName.c_str());
+ if (!in_stream)
+ return false;
+ std::string olds, news;
+ while (!in_stream.eof()){
+ olds = news;
+ std::getline(in_stream, news, '\n');
+ }
+ return (olds == " -1");
+ }
+
+ /*!
+ * \brief reads a whole line
+ * \param in_stream - source stream
+ * \param next - if true, first reads the current line up to the end
+ * which is necessary after reading using >> operator
+ * \retval std::string - the result line
+ */
+ inline std::string read_line(std::ifstream& in_stream, const bool next=true)
+ {
+ std::string resLine;
+ std::getline( in_stream, resLine );
+ if ( next )
+ std::getline( in_stream, resLine );
+
+ if ( resLine.size() > 0 && resLine[ resLine.size()-1 ] == '\r' )
+ resLine.resize( resLine.size()-1 );
+ return resLine;
+ }