ATLAS Offline Software
AsciiInput.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ASCIIIOINPUT_H
6 #define ASCIIIOINPUT_H
7 
8 #include <string>
9 #include <vector>
10 #include <fstream>
11 
18 class AsciiInput {
19  public:
20  AsciiInput(const std::string& fileName);
21  ~AsciiInput();
22 
25  int open();
26 
29  int close();
30 
35  std::vector<std::string> readRow();
36 
39  static std::vector<std::string> strToStrVec(const std::string& inputString);
40 
42  static long strToLong(const std::string& inputString);
43 
45  static double strToDouble(const std::string& inputString);
46 
47  private:
48 
50  std::string m_fileName;
51 
53  std::ifstream m_file;
54 
56  static const int MAX_LINE_LENGTH = 500;
57 
60 };
61 
62 #endif
AsciiInput::AsciiInput
AsciiInput(const std::string &fileName)
Definition: AsciiInput.cxx:9
AsciiInput::~AsciiInput
~AsciiInput()
Definition: AsciiInput.cxx:17
AsciiInput::readRow
std::vector< std::string > readRow()
Read one line of the input text file into a vector of strings.
Definition: AsciiInput.cxx:42
AsciiInput::close
int close()
Close the input file.
Definition: AsciiInput.cxx:32
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
AsciiInput::strToLong
static long strToLong(const std::string &inputString)
A helper function to convert a string to a long value.
Definition: AsciiInput.cxx:113
AsciiInput::m_lineBuffer
char m_lineBuffer[MAX_LINE_LENGTH]
Character buffers used while parsing the input file.
Definition: AsciiInput.h:59
AsciiInput::MAX_LINE_LENGTH
static const int MAX_LINE_LENGTH
Size of the character buffers.
Definition: AsciiInput.h:56
AsciiInput
A class to provide read access to an ASCII input file.
Definition: AsciiInput.h:18
AsciiInput::open
int open()
Open the input file.
Definition: AsciiInput.cxx:22
AsciiInput::strToStrVec
static std::vector< std::string > strToStrVec(const std::string &inputString)
A helper function to convert a string into a string vector, by using any number of space or tab chara...
Definition: AsciiInput.cxx:67
AsciiInput::m_file
std::ifstream m_file
Input file stream.
Definition: AsciiInput.h:53
AsciiInput::m_fileName
std::string m_fileName
Input file name.
Definition: AsciiInput.h:50
AsciiInput::strToDouble
static double strToDouble(const std::string &inputString)
A helper function to convert a string to a double value.
Definition: AsciiInput.cxx:122