aGrUM  0.15.1
gum::ErrorsContainer Class Reference

This class is used contain and manipulate gum::ParseError. More...

#include <agrum/core/errorsContainer.h>

Public Attributes

Size error_count
 Number of errors detected. More...
 
Size warning_count
 

Public Member Functions

Class Constructor
 ErrorsContainer ()
 Class Constructor. More...
 
 ErrorsContainer (const ErrorsContainer &cont)
 Copy constructor. More...
 
Accessors / Modifiers
void add (ParseError error)
 Add an error object to the container. More...
 
ParseError error (Idx i) const
 Returns the i-th error. More...
 
ParseError last () const
 Returns the last added error. More...
 
void addError (const std::string &msg, const std::string &filename, Idx line, Idx col)
 Adds an error. More...
 
void addWarning (const std::string &msg, const std::string &filename, Idx line, Idx col)
 Adds a warning. More...
 
void addException (const std::string &msg, const std::string &filename)
 Add an exception. More...
 
Size count () const
 Returns the number of errors and warnings. More...
 
void syntheticResults (std::ostream &o) const
 Print errors on output stream. More...
 
void simpleErrors (std::ostream &o) const
 Print errors on output stream. More...
 
void simpleErrorsAndWarnings (std::ostream &o) const
 Print errors on output stream. More...
 
void elegantErrors (std::ostream &o) const
 Print errors on output stream. More...
 
void elegantErrorsAndWarnings (std::ostream &o) const
 Print errors on output stream. More...
 
Coco/R helpers
void Error (const std::wstring &filename, Idx line, Idx col, const wchar_t *msg)
 For adding errors. More...
 
void Warning (const std::wstring &filename, Idx line, Idx col, const wchar_t *msg)
 For adding warnings. More...
 
void Exception (const std::wstring &filename, const wchar_t *msg)
 For adding exceptions. More...
 
Class operators
ErrorsContainer operator+ (const ErrorsContainer &cont) const
 Return the sum of two gum::ErrorsContainer. More...
 
ErrorsContainer operator= (const ErrorsContainer &cont)
 Copy Operator. More...
 
ErrorsContainer operator+= (const ErrorsContainer &cont)
 Add the content of a gum::ErrorsContainer to this gum::ErrorsContainer. More...
 

Detailed Description

This class is used contain and manipulate gum::ParseError.

Definition at line 161 of file errorsContainer.h.

Constructor & Destructor Documentation

◆ ErrorsContainer() [1/2]

gum::ErrorsContainer::ErrorsContainer ( )

Class Constructor.

◆ ErrorsContainer() [2/2]

gum::ErrorsContainer::ErrorsContainer ( const ErrorsContainer cont)

Copy constructor.

Parameters
contThe ErrorsContainer to copy.

Member Function Documentation

◆ add()

INLINE void gum::ErrorsContainer::add ( ParseError  error)

Add an error object to the container.

Parameters
errorThe gum::ParseError to add.

Definition at line 58 of file errorsContainer_inl.h.

References error_count, errors, gum::ParseError::is_error, and warning_count.

Referenced by addError(), addException(), addWarning(), Error(), Exception(), gum::prm::o3prmr::O3prmrInterpreter::import(), gum::O3prmBNReader< GUM_SCALAR >::proceed(), and Warning().

58  {
59  errors.push_back(error);
60 
61  if (error.is_error)
62  error_count++;
63  else
64  warning_count++;
65  }
Size error_count
Number of errors detected.
std::vector< ParseError > errors
The list of gum::ParseError contained in this gum::ErrorsContainer.
bool is_error
If false, this gum::ParseError is a warning.
ParseError error(Idx i) const
Returns the i-th error.
+ Here is the caller graph for this function:

◆ addError()

INLINE void gum::ErrorsContainer::addError ( const std::string &  msg,
const std::string &  filename,
Idx  line,
Idx  col 
)

Adds an error.

Parameters
msgThe error's message.
filenameThe error's file.
lineThe error's line.
colThe error's column.

Definition at line 68 of file errorsContainer_inl.h.

References add().

Referenced by gum::prm::o3prmr::O3prmrInterpreter::addError().

71  {
72  add(ParseError(true, msg, filename, line, col));
73  }
void add(ParseError error)
Add an error object to the container.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addException()

INLINE void gum::ErrorsContainer::addException ( const std::string &  msg,
const std::string &  filename 
)

Add an exception.

Parameters
msgThe exception's message.
filenameThe exception's file.

Definition at line 84 of file errorsContainer_inl.h.

References add().

85  {
86  add(ParseError(true, msg, filename, 0, 0));
87  }
void add(ParseError error)
Add an error object to the container.
+ Here is the call graph for this function:

◆ addWarning()

INLINE void gum::ErrorsContainer::addWarning ( const std::string &  msg,
const std::string &  filename,
Idx  line,
Idx  col 
)

Adds a warning.

Parameters
msgThe warning's message.
filenameThe warning's file.
lineThe warning's line.
colThe warning's column.

Definition at line 76 of file errorsContainer_inl.h.

References add().

Referenced by gum::prm::o3prmr::O3prmrInterpreter::addWarning().

79  {
80  add(ParseError(false, msg, filename, line, col));
81  }
void add(ParseError error)
Add an error object to the container.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ count()

INLINE Size gum::ErrorsContainer::count ( ) const

Returns the number of errors and warnings.

Returns
Returns the number of errors and warnings.

Definition at line 90 of file errorsContainer_inl.h.

References error_count, and warning_count.

Referenced by gum::prm::o3prmr::O3prmrInterpreter::count(), and gum::prm::o3prmr::O3prmrInterpreter::import().

90 { return error_count + warning_count; }
Size error_count
Number of errors detected.
+ Here is the caller graph for this function:

◆ elegantErrors()

void gum::ErrorsContainer::elegantErrors ( std::ostream &  o) const

Print errors on output stream.

Parameters
oThe output strem to send results.

Referenced by gum::O3prmBNReader< GUM_SCALAR >::showElegantErrors(), and gum::prm::o3prmr::O3prmrInterpreter::showElegantErrors().

+ Here is the caller graph for this function:

◆ elegantErrorsAndWarnings()

void gum::ErrorsContainer::elegantErrorsAndWarnings ( std::ostream &  o) const

Print errors on output stream.

Parameters
oThe output strem to send results.

Referenced by gum::prm::o3prmr::O3prmrInterpreter::checkSemantic(), gum::O3prmBNReader< GUM_SCALAR >::showElegantErrorsAndWarnings(), and gum::prm::o3prmr::O3prmrInterpreter::showElegantErrorsAndWarnings().

+ Here is the caller graph for this function:

◆ error()

ParseError gum::ErrorsContainer::error ( Idx  i) const

Returns the i-th error.

Parameters
iThe error to return.
Returns
Returns the i-th error.
Exceptions
OutOfBoundsRaised if there is less than i errors.

Referenced by gum::O3prmBNReader< GUM_SCALAR >::errCol(), gum::O3prmBNReader< GUM_SCALAR >::errIsError(), gum::O3prmBNReader< GUM_SCALAR >::errLine(), gum::O3prmBNReader< GUM_SCALAR >::errMsg(), gum::prm::o3prmr::O3prmrInterpreter::error(), and gum::prm::o3prmr::O3prmrInterpreter::import().

+ Here is the caller graph for this function:

◆ Error()

INLINE void gum::ErrorsContainer::Error ( const std::wstring &  filename,
Idx  line,
Idx  col,
const wchar_t *  msg 
)

For adding errors.

Parameters
filenameThe error's file.
lineThe error's line.
colThe error's column.
msgThe error's message.

Definition at line 35 of file errorsContainer_inl.h.

References add(), and narrow().

38  {
39  add(ParseError(true, narrow(std::wstring(msg)), narrow(filename), line, col));
40  }
void add(ParseError error)
Add an error object to the container.
std::string narrow(const std::wstring &str)
Cast a std::wstring into a std::string.
+ Here is the call graph for this function:

◆ Exception()

INLINE void gum::ErrorsContainer::Exception ( const std::wstring &  filename,
const wchar_t *  msg 
)

For adding exceptions.

Parameters
filenameThe exception's file.
msgThe exception's message.

Definition at line 51 of file errorsContainer_inl.h.

References add(), and narrow().

52  {
53  add(ParseError(
54  true, "Exception : " + narrow(std::wstring(msg)), narrow(filename), 0, 0));
55  }
void add(ParseError error)
Add an error object to the container.
std::string narrow(const std::wstring &str)
Cast a std::wstring into a std::string.
+ Here is the call graph for this function:

◆ last()

ParseError gum::ErrorsContainer::last ( ) const

Returns the last added error.

Returns
Returns the last added error.
Exceptions
OutOfBoundsRaised if is no error to return.

Referenced by gum::prm::o3prmr::O3prmrInterpreter::addError(), and gum::prm::o3prmr::O3prmrInterpreter::addWarning().

+ Here is the caller graph for this function:

◆ operator+()

ErrorsContainer gum::ErrorsContainer::operator+ ( const ErrorsContainer cont) const

Return the sum of two gum::ErrorsContainer.

Parameters
contThe gum::ErrorsContainer to add.
Returns
Return the sum of two gum::ErrorsContainer.

◆ operator+=()

ErrorsContainer gum::ErrorsContainer::operator+= ( const ErrorsContainer cont)

Add the content of a gum::ErrorsContainer to this gum::ErrorsContainer.

Parameters
contThe gum::ErrorsContainer to add to this.
Returns
Returns this gum::ErrorsContainer.

◆ operator=()

ErrorsContainer gum::ErrorsContainer::operator= ( const ErrorsContainer cont)

Copy Operator.

Parameters
contThe gum::ErrorsContainer to copy.
Returns
Returns this gum::ErrorsContainer.

◆ simpleErrors()

void gum::ErrorsContainer::simpleErrors ( std::ostream &  o) const

Print errors on output stream.

Parameters
oThe output strem to send results.

◆ simpleErrorsAndWarnings()

void gum::ErrorsContainer::simpleErrorsAndWarnings ( std::ostream &  o) const

Print errors on output stream.

Parameters
oThe output strem to send results.

◆ syntheticResults()

INLINE void gum::ErrorsContainer::syntheticResults ( std::ostream &  o) const

Print errors on output stream.

Parameters
oThe output strem to send results.

Definition at line 93 of file errorsContainer_inl.h.

References error_count, and warning_count.

Referenced by gum::O3prmBNReader< GUM_SCALAR >::showErrorCounts(), and gum::prm::o3prmr::O3prmrInterpreter::showErrorCounts().

93  {
94  o << "Errors : " << error_count << std::endl;
95  o << "Warnings : " << warning_count << std::endl;
96  }
Size error_count
Number of errors detected.
+ Here is the caller graph for this function:

◆ Warning()

INLINE void gum::ErrorsContainer::Warning ( const std::wstring &  filename,
Idx  line,
Idx  col,
const wchar_t *  msg 
)

For adding warnings.

Parameters
filenameThe warning's file.
lineThe warning's line.
colThe warning's column.
msgThe warning's message.

Definition at line 43 of file errorsContainer_inl.h.

References add(), and narrow().

46  {
47  add(ParseError(false, narrow(std::wstring(msg)), narrow(filename), line, col));
48  }
void add(ParseError error)
Add an error object to the container.
std::string narrow(const std::wstring &str)
Cast a std::wstring into a std::string.
+ Here is the call graph for this function:

Member Data Documentation

◆ error_count

Size gum::ErrorsContainer::error_count

◆ errors

std::vector< ParseError > gum::ErrorsContainer::errors
mutableprivate

◆ warning_count


The documentation for this class was generated from the following files: