Biorbd
IfStream.h
1 #ifndef BIORBD_UTILS_IFSTREAM_H
2 #define BIORBD_UTILS_IFSTREAM_H
3 
4 #include <map>
5 #include "biorbdConfig.h"
6 #include "Utils/Path.h"
7 #include <iostream>
8 #include "rbdl_math.h"
9 
10 namespace biorbd {
11 namespace utils {
12 class Equation;
16 class BIORBD_API IfStream
17 {
18 public:
22  IfStream();
23 
29  IfStream(
30  const biorbd::utils::Path& path,
31  std::ios_base::openmode mode );
32 
38  IfStream(
39  const char* path,
40  std::ios_base::openmode mode );
41 
48  bool open(
49  const biorbd::utils::Path& path,
50  std::ios_base::openmode mode );
51 
57  bool read(
58  biorbd::utils::String& text);
59 
65  bool readAWord(
66  biorbd::utils::String& text);
67 
73  bool read(
74  int& val);
75 
81  bool read(
82  bool& val);
83 
89  bool read(
90  unsigned int& val);
91 
97  bool read(
98  double& val);
99 #ifdef BIORBD_USE_CASADI_MATH
100  bool read(
106  RBDLCasadiMath::MX_Xd_SubMatrix val);
107 #endif
108 
115  bool read(
116  double& result,
117  const std::map<biorbd::utils::Equation, double> &variables);
118 #ifdef BIORBD_USE_CASADI_MATH
119  bool read(
126  RBDLCasadiMath::MX_Xd_SubMatrix result,
127  const std::map<biorbd::utils::Equation, double> &variables);
128 #endif
129 
136  bool readSpecificTag(
137  const biorbd::utils::String& tag,
138  biorbd::utils::String& text);
139 
145  bool reachSpecificTag(
146  const biorbd::utils::String& tag);
147 
153  int countTagsInAConsecutiveLines(
154  const biorbd::utils::String& tag);
155 
160  void getline(
161  biorbd::utils::String& text);
162 
166  bool close();
167 
172  bool eof();
173 
174 protected:
175  std::shared_ptr<bool> m_isOpen;
176 
177 private:
178  std::shared_ptr<std::ifstream> m_ifs;
179  std::shared_ptr<biorbd::utils::Path> m_path;
180 };
181 
182 }}
183 
184 #endif // BIORBD_UTILS_IFSTREAM_H
185 
biorbd::utils::IfStream::m_isOpen
std::shared_ptr< bool > m_isOpen
If file is open.
Definition: IfStream.h:175
biorbd::utils::String
Wrapper around the std::string class with augmented functionality.
Definition: String.h:17
biorbd::utils::Path
Collection of methods to manipulate path.
Definition: Path.h:17
biorbd::utils::IfStream
Wrapper for the an std::ifstream with increased capacities.
Definition: IfStream.h:17