aGrUM  0.16.0
errorsContainer_inl.h
Go to the documentation of this file.
1 
29 // to ease automatic parsers
31 
32 namespace gum {
33 
34  INLINE
35  void ErrorsContainer::Error(const std::wstring& filename,
36  Idx line,
37  Idx col,
38  const wchar_t* msg) {
39  add(ParseError(true, narrow(std::wstring(msg)), narrow(filename), line, col));
40  }
41 
42  INLINE
43  void ErrorsContainer::Warning(const std::wstring& filename,
44  Idx line,
45  Idx col,
46  const wchar_t* msg) {
47  add(ParseError(false, narrow(std::wstring(msg)), narrow(filename), line, col));
48  }
49 
50  INLINE
51  void ErrorsContainer::Exception(const std::wstring& filename,
52  const wchar_t* msg) {
54  true, "Exception : " + narrow(std::wstring(msg)), narrow(filename), 0, 0));
55  }
56 
57  INLINE
59  errors.push_back(error);
60 
61  if (error.is_error)
62  error_count++;
63  else
64  warning_count++;
65  }
66 
67  INLINE
68  void ErrorsContainer::addError(const std::string& msg,
69  const std::string& filename,
70  Idx line,
71  Idx col) {
72  add(ParseError(true, msg, filename, line, col));
73  }
74 
75  INLINE
76  void ErrorsContainer::addWarning(const std::string& msg,
77  const std::string& filename,
78  Idx line,
79  Idx col) {
80  add(ParseError(false, msg, filename, line, col));
81  }
82 
83  INLINE
84  void ErrorsContainer::addException(const std::string& msg,
85  const std::string& filename) {
86  add(ParseError(true, msg, filename, 0, 0));
87  }
88 
89  INLINE
91 
92  INLINE
93  void ErrorsContainer::syntheticResults(std::ostream& o) const {
94  o << "Errors : " << error_count << std::endl;
95  o << "Warnings : " << warning_count << std::endl;
96  }
97 
98 } // namespace gum
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void addWarning(const std::string &msg, const std::string &filename, Idx line, Idx col)
Adds a warning.
Size count() const
Returns the number of errors and warnings.
Size error_count
Number of errors detected.
void Exception(const std::wstring &filename, const wchar_t *msg)
For adding exceptions.
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...
void syntheticResults(std::ostream &o) const
Print errors on output stream.
void add(ParseError error)
Add an error object to the container.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
bool is_error
If false, this gum::ParseError is a warning.
std::string narrow(const std::wstring &str)
Cast a std::wstring into a std::string.
void Error(const std::wstring &filename, Idx line, Idx col, const wchar_t *msg)
For adding errors.
Size Idx
Type for indexes.
Definition: types.h:53
ParseError error(Idx i) const
Returns the i-th error.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
void Warning(const std::wstring &filename, Idx line, Idx col, const wchar_t *msg)
For adding warnings.
void addError(const std::string &msg, const std::string &filename, Idx line, Idx col)
Adds an error.
void addException(const std::string &msg, const std::string &filename)
Add an exception.