Documentation for OpenFLUID 2.2.0
ProgressiveColumnFileReader.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 
33 /**
34  @file ProgressiveColumnFileReader.hpp
35 
36  @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
37  @author Armel THÖNI <armel.thoni@inrae.fr>
38  */
39 
40 
41 #ifndef __OPENFLUID_TOOLS_PROGRESSIVECOLUMNFILEREADER_HPP__
42 #define __OPENFLUID_TOOLS_PROGRESSIVECOLUMNFILEREADER_HPP__
43 
44 
45 #include <fstream>
46 #include <vector>
47 
48 #include <openfluid/dllexport.hpp>
49 
50 
51 namespace openfluid { namespace tools {
52 
53 
54 /**
55  Progressive reader for column text files
56 */
58 {
59  private:
60 
61  std::ifstream m_File;
62 
63 
64  protected:
65 
66  std::string m_FileName;
67 
68  std::string m_ColSeparators;
69 
70 
71  public:
72 
73  /**
74  Constructor
75  @param[in] FileName the file to open
76  @param[in] ColSeparators a list of columns separators. Default value is " \t\r\n"
77  */
78  ProgressiveColumnFileReader(const std::string& FileName,
79  const std::string& ColSeparators = " \t\r\n");
80 
82  { }
83 
84  /**
85  Gets the next line of data in the file, as a single string
86  @param[out] Line the read line
87  @return true if the next line has been read, false otherwise
88  */
89  bool getNextLine(std::string& Line);
90 
91  /**
92  Gets the next line of data in the file, as a vector of strings
93  @param[out] Values the vector of read values
94  @return true if the next line has been read and splitted into a vector of strings,
95  false otherwise
96  */
97  bool getNextLine(std::vector<std::string>& Values);
98 
99  /**
100  Resets the internal iterator of the file
101  */
102  void reset();
103 
104  /**
105  Returns the file name
106  @return the file name
107  */
108  std::string getFileName() const { return m_FileName; };
109 
110 };
111 
112 
113 } } // namespaces
114 
115 
116 #endif /* __OPENFLUID_TOOLS_PROGRESSIVECOLUMNFILEREADER_HPP__ */
Definition: ProgressiveColumnFileReader.hpp:58
ProgressiveColumnFileReader(const std::string &FileName, const std::string &ColSeparators=" \t\r\n")
std::string m_ColSeparators
Definition: ProgressiveColumnFileReader.hpp:68
virtual ~ProgressiveColumnFileReader()
Definition: ProgressiveColumnFileReader.hpp:81
std::string getFileName() const
Definition: ProgressiveColumnFileReader.hpp:108
bool getNextLine(std::vector< std::string > &Values)
std::string m_FileName
Definition: ProgressiveColumnFileReader.hpp:66
#define OPENFLUID_API
Definition: dllexport.hpp:86
Definition: ApplicationException.hpp:47