OpenWalnut  1.5.0dev
WReaderCSV.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WREADERCSV_H
26 #define WREADERCSV_H
27 
28 #include <memory>
29 #include <string>
30 #include <vector>
31 
32 #include <core/dataHandler/WDataSetCSV.h>
33 #include <core/dataHandler/WDataSetPoints.h>
34 
35 #include "core/dataHandler/io/WReader.h"
36 
37 
38 /**
39  * Read content from a CSV file.
40  * \ingroup dataHandler
41  */
43 {
44  /**
45  * Only WReaderCSVTest class may be friend
46  */
47  friend class WReaderCSVTest;
48 public:
49  /**
50  * Constructs a CSV reader object.
51  *
52  * \param fname path of the file to load.
53  */
54  explicit WReaderCSV( std::string fname );
55 
56  /**
57  * Destroys this instance.
58  */
59  virtual ~WReaderCSV() throw();
60 
61  /**
62  * Read the file and create a dataset as a vector.
63  *
64  * \return pointer to a WDataSetCSV.
65  * \throws WException If the file could not be opened.
66  */
67  virtual std::shared_ptr< WDataSetCSV > read();
68 private:
69  /**
70  * Transforms a given string into a string vector, by a predefined delimiter
71  * \param line The line, which shell be split into a string vector
72  * \return The splitted string as a string vector
73  */
74  std::vector< std::string > transformLineToVector( std::string line );
75 };
76 
77 #endif // WREADERCSV_H
Represents a CSV dataset.
Definition: WDataSetCSV.h:38
Test class of WReaderCSV class.
Read content from a CSV file.
Definition: WReaderCSV.h:43
virtual ~WReaderCSV()
Destroys this instance.
Definition: WReaderCSV.cpp:37
WReaderCSV(std::string fname)
Constructs a CSV reader object.
Definition: WReaderCSV.cpp:32
virtual std::shared_ptr< WDataSetCSV > read()
Read the file and create a dataset as a vector.
Definition: WReaderCSV.cpp:74
std::vector< std::string > transformLineToVector(std::string line)
Transforms a given string into a string vector, by a predefined delimiter.
Definition: WReaderCSV.cpp:135
Read some data from a given file.
Definition: WReader.h:40