aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::ErrorsContainer Class Reference

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

#include <agrum/tools/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 160 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 50 of file errorsContainer_inl.h.

References gum::Set< Key, Alloc >::emplace().

50  {
51  errors.push_back(error);
52 
53  if (error.is_error)
54  error_count++;
55  else
56  warning_count++;
57  }
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 call 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 60 of file errorsContainer_inl.h.

References gum::Set< Key, Alloc >::emplace().

63  {
64  add(ParseError(true, msg, filename, line, col));
65  }
void add(ParseError error)
Add an error object to the container.
+ Here is the call 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 76 of file errorsContainer_inl.h.

References gum::Set< Key, Alloc >::emplace().

76  {
77  add(ParseError(true, msg, filename, 0, 0));
78  }
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 68 of file errorsContainer_inl.h.

References gum::Set< Key, Alloc >::emplace().

71  {
72  add(ParseError(false, msg, filename, line, col));
73  }
void add(ParseError error)
Add an error object to the container.
+ Here is the call 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 81 of file errorsContainer_inl.h.

References gum::Set< Key, Alloc >::emplace().

81 { return error_count + warning_count; }
Size error_count
Number of errors detected.
+ Here is the call 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.

◆ elegantErrorsAndWarnings()

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

Print errors on output stream.

Parameters
oThe output strem to send results.

◆ 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.

◆ 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 34 of file errorsContainer_inl.h.

References gum::Set< Key, Alloc >::emplace().

34  {
35  add(ParseError(true, narrow(std::wstring(msg)), narrow(filename), line, col));
36  }
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 45 of file errorsContainer_inl.h.

References gum::Set< Key, Alloc >::emplace().

45  {
46  add(ParseError(true, "Exception : " + narrow(std::wstring(msg)), narrow(filename), 0, 0));
47  }
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.

◆ 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 84 of file errorsContainer_inl.h.

References gum::Set< Key, Alloc >::emplace().

84  {
85  o << "Errors : " << error_count << std::endl;
86  o << "Warnings : " << warning_count << std::endl;
87  }
Size error_count
Number of errors detected.
+ Here is the call 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 40 of file errorsContainer_inl.h.

References gum::Set< Key, Alloc >::emplace().

40  {
41  add(ParseError(false, narrow(std::wstring(msg)), narrow(filename), line, col));
42  }
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

Number of errors detected.

Definition at line 166 of file errorsContainer.h.

◆ errors

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

The list of gum::ParseError contained in this gum::ErrorsContainer.

Definition at line 162 of file errorsContainer.h.

◆ warning_count

Size gum::ErrorsContainer::warning_count

Definition at line 169 of file errorsContainer.h.


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