aGrUM  0.16.0
errorsContainer.h
Go to the documentation of this file.
1 
29 #ifndef GUM_ERRORS_CONTAINERS_H
30 #define GUM_ERRORS_CONTAINERS_H
31 
32 #include <fstream>
33 #include <iostream>
34 #include <vector>
35 
36 #include <agrum/agrum.h>
37 
38 #include <agrum/core/cocoR/common.h>
39 
40 namespace gum {
41 
50  class ParseError {
51  public:
52  // ============================================================================
54  // ============================================================================
56 
63  ParseError(bool is_error, const std::string& msg, Idx line);
64 
73  ParseError(bool is_error,
74  const std::string& msg,
75  const std::string& filename,
76  Idx line,
77  Idx col = 0);
78 
88  ParseError(bool is_error,
89  const std::string& msg,
90  const std::string& filename,
91  const std::string& code,
92  Idx line,
93  Idx col = 0);
94 
99  ParseError(const ParseError& cont);
100 
102  // ============================================================================
104  // ============================================================================
106 
112  ParseError operator=(const ParseError& cont);
113 
115  // ============================================================================
117  // ============================================================================
119 
121  bool is_error;
122 
125 
128 
130  std::string msg;
131 
133  std::string filename;
134 
136  mutable std::string code; // default ""
137 
142  std::string toString() const;
143 
150  std::string toElegantString() const;
151 
153  };
154 
163  mutable std::vector< ParseError > errors;
164 
165  public:
168 
169  // Number of warnings detected.
171 
172  // ============================================================================
174  // ============================================================================
176 
180  ErrorsContainer();
181 
186  ErrorsContainer(const ErrorsContainer& cont);
187 
189  // ============================================================================
191  // ============================================================================
193 
198  void add(ParseError error);
199 
206  ParseError error(Idx i) const;
207 
213  ParseError last() const;
214 
222  void addError(const std::string& msg,
223  const std::string& filename,
224  Idx line,
225  Idx col);
226 
234  void addWarning(const std::string& msg,
235  const std::string& filename,
236  Idx line,
237  Idx col);
238 
244  void addException(const std::string& msg, const std::string& filename);
245 
250  Size count() const;
251 
256  void syntheticResults(std::ostream& o) const;
257 
262  void simpleErrors(std::ostream& o) const;
263 
268  void simpleErrorsAndWarnings(std::ostream& o) const;
269 
274  void elegantErrors(std::ostream& o) const;
275 
280  void elegantErrorsAndWarnings(std::ostream& o) const;
281 
283  // ============================================================================
285  // ============================================================================
287 
295  void
296  Error(const std::wstring& filename, Idx line, Idx col, const wchar_t* msg);
297 
305  void Warning(const std::wstring& filename,
306  Idx line,
307  Idx col,
308  const wchar_t* msg);
309 
315  void Exception(const std::wstring& filename, const wchar_t* msg);
316 
318  // ============================================================================
320  // ============================================================================
322 
328  ErrorsContainer operator+(const ErrorsContainer& cont) const;
329 
336 
343  ErrorsContainer operator+=(const ErrorsContainer& cont);
344 
346 
347  }; // ErrorsContainer
348 
349 } // namespace gum
350 
352 #ifndef GUM_NO_INLINE
354 #endif /* GUM_NO_INLINE */
355 
356 #endif // GUM_ERRORS_CONTAINERS_H
std::string msg
The gum::ParseError message.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Formula operator+(const Formula &a, const Formula &b)
Definition: formula_inl.h:479
Size error_count
Number of errors detected.
std::string filename
The file of this gum::ParseError, default is "".
std::string code
The code of this gum::ParseError, default is "".
std::vector< ParseError > errors
The list of gum::ParseError contained in this gum::ErrorsContainer.
This class is used to represent parsing errors for the different parser implemented in aGrUM...
ParseError(bool is_error, const std::string &msg, Idx line)
Class constructor.
This class is used contain and manipulate gum::ParseError.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
std::string toString() const
Return a std::string representation of this gum::ParseError.
std::string toElegantString() const
Return an elegant std::string representation of this gum::ParseError.
bool is_error
If false, this gum::ParseError is a warning.
Idx line
The line of this gum::ParseError.
ParseError operator=(const ParseError &cont)
Copy operator.
Base class for all aGrUM&#39;s exceptions.
Definition: exceptions.h:106
Size Idx
Type for indexes.
Definition: types.h:53
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
Idx column
The column of this gum::ParseError, default is 0.