OpenWalnut  1.5.0dev
clusterDisplayVoxels/WFileParser.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 WFILEPARSER_H
26 #define WFILEPARSER_H
27 
28 #include <string>
29 #include <vector>
30 
31 /**
32  * class implements text file loading and several convinience methods to access
33  */
35 {
36 public:
37  /**
38  * constructor
39  * \param fileName
40  */
41  explicit WFileParser( const std::string fileName );
42 
43  /**
44  * destructor
45  */
46  ~WFileParser();
47 
48  /**
49  * helper function to read a text file
50  * \return string containing the file
51  */
52  bool readFile();
53 
54  /**
55  * getter
56  * \return the content of the loaded as vector of strings for each line
57  */
58  std::vector<std::string>getRawLines();
59 
60  /**
61  * getter
62  * \param tag tag marking a certain type of content
63  * \return vector of strings for each line for the tag
64  */
65  std::vector<std::string>getLinesForTag( std::string tag );
66 
67  /**
68  * getter
69  * \param tag tag marking a certain type of content
70  * \return same as getLinesForTag but each line represented as vector of strings
71  */
72  std::vector< std::vector<std::string> >getLinesForTagSeparated( std::string tag );
73 
74 protected:
75 private:
76  std::string m_fileName; //!< the file name of the file to parse
77 
78  std::vector<std::string>m_rawLines; //!< vector of every line in the file
79 
80  std::string m_tagIndicator; //!< string marking a line as tag
81 
82  std::string m_endIndicator; //!< string marking the end of a tagged area
83 
84  std::string m_delimiter; //!< delimiter for entries in a line
85 };
86 
87 inline std::vector<std::string>WFileParser::getRawLines()
88 {
89  return m_rawLines;
90 }
91 
92 #endif // WFILEPARSER_H
class implements text file loading and several convinience methods to access
std::string m_fileName
the file name of the file to parse
std::vector< std::string > m_rawLines
vector of every line in the file
std::vector< std::vector< std::string > > getLinesForTagSeparated(std::string tag)
getter
std::vector< std::string > getRawLines()
getter
WFileParser(const std::string fileName)
constructor
std::string m_delimiter
delimiter for entries in a line
bool readFile()
helper function to read a text file
std::vector< std::string > getLinesForTag(std::string tag)
getter
std::string m_endIndicator
string marking the end of a tagged area
std::string m_tagIndicator
string marking a line as tag