Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
lha.h
Go to the documentation of this file.
1 // This file is part of MARTY.
2 //
3 // MARTY is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // MARTY is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with MARTY. If not, see <https://www.gnu.org/licenses/>.
15 
28 #ifndef LHA_H_INCLUDED
29 #define LHA_H_INCLUDED
30 
31 #include <string>
32 #include <vector>
33 
37 namespace mty::lha {
38 
39  struct LHAElement;
40  class LHAFileData;
41 
46  class Reader {
47 
48  public:
49 
54  static inline
55  bool verbose = false;
56 
65  static
66  LHAFileData readFile(std::string const &fileName);
67 
76  static
77  LHAFileData readFile(std::ifstream &in);
78 
79  private:
80 
89  static
90  std::string nextLine(std::ifstream &in);
91 
100  static
101  std::vector<std::string> split(std::string const &line);
102 
115  static
116  bool isBlockLine(std::vector<std::string> const &line);
117 
126  static
127  bool isPositiveInteger(std::string const &str);
128 
138  static
139  bool isNumber(std::string const &str);
140 
154  static
155  bool isValueLine(std::vector<std::string> const &line);
156 
169  static
170  LHAElement readValue(std::vector<std::string> const &line);
171  };
172 
173 } // End of namespace mty::lha
174 
175 #endif
Class the reads .lha file, parses them and create a LHAFileData containing all blocks with their elem...
Definition: lha.h:46
static bool isNumber(std::string const &str)
Tells if a string corresponds to a number, integer or floating point (standard or scientific notation...
Definition: lha.cpp:126
static bool verbose
Tells if warning messages must be printed during the read of .lha files.
Definition: lha.h:55
static bool isPositiveInteger(std::string const &str)
Tells if a string corresponds to a positive integer.
Definition: lha.cpp:112
static LHAElement readValue(std::vector< std::string > const &line)
Reads a line and returns the LHAElement corresponding to it.
Definition: lha.cpp:149
Corresponds to a line of a .lha file.
Definition: lhaData.h:70
static LHAFileData readFile(std::string const &fileName)
Reads a .lha file and returns its data.
Definition: lha.cpp:24
static std::string nextLine(std::ifstream &in)
Reads a line in in and removes comments (with &#39;#&#39;).
Definition: lha.cpp:67
Namespace containing all lha utilities.
Definition: lha.h:37
static bool isValueLine(std::vector< std::string > const &line)
Tells if a line contains a value.
Definition: lha.cpp:140
static std::vector< std::string > split(std::string const &line)
Splits a string into pieces, separating by space and line break.
Definition: lha.cpp:82
static bool isBlockLine(std::vector< std::string > const &line)
Tells if a line (vector of string) is a block line.
Definition: lha.cpp:106
Final class containing all the data coming from a LHA file.
Definition: lhaData.h:302