Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::ValueChecker Class Reference

Checking the validity of certain values. More...

#include <arcane/utils/ValueChecker.h>

Collaboration diagram for Arcane::ValueChecker:

Public Member Functions

 ValueChecker (const TraceInfo &ti)
template<typename T1, typename T2, typename X = std::is_convertible<T2, T1>>
void areEqual (const T1 &value, const T2 &expected_value, const String &message)
template<typename T1, typename T2, typename ValueType = typename T1::value_type, typename X1 = std::is_convertible<T1, Span<const ValueType>>, typename X2 = std::is_convertible<T1, Span<const ValueType>>>
void areEqualArray (const T1 &x_values, const T2 &x_expected_values, const String &message)
 Checks that the two arrays values and expected_values have the same values.
template<typename T>
void areEqualArray (Span2< const T > values, Span2< const T > expected_values, const String &message)
 Checks that the two 2D arrays values and expected_values have the same values.
template<typename T>
void areEqualArray (SmallSpan2< T > values, SmallSpan2< T > expected_values, const String &message)
 Checks that the two arrays values and expected_values have the same values.
void throwIfError ()
 Throws an exception if nbError()!=0.
void setThrowOnError (bool v)
 Indicates whether an exception is thrown in case of an error.
bool throwOnError () const
 Indicates whether an exception is thrown in case of an error.
Integer nbError () const
 Number of errors.

Private Member Functions

void _addError (const String &message)

Private Attributes

TraceInfo m_trace_info
Integer m_nb_error
OStringStream m_ostr
String m_last_error_str
bool m_throw_on_error

Detailed Description

Checking the validity of certain values.

This class provides a set of methods to check that values conform to a reference.

By default, if a value is different from its reference, an exception is thrown. It is possible to change this behavior by setting setThrowIfError() to false. In this case, it is possible to manually throw the exception by calling throwIfError().

Definition at line 41 of file ValueChecker.h.

Constructor & Destructor Documentation

◆ ValueChecker()

Arcane::ValueChecker::ValueChecker ( const TraceInfo & ti)
inline

Definition at line 45 of file ValueChecker.h.

Member Function Documentation

◆ _addError()

void Arcane::ValueChecker::_addError ( const String & message)
private

Definition at line 28 of file ValueChecker.cc.

◆ areEqual()

template<typename T1, typename T2, typename X = std::is_convertible<T2, T1>>
void Arcane::ValueChecker::areEqual ( const T1 & value,
const T2 & expected_value,
const String & message )
inline

Checks that value and expected_value have the same values.

Definition at line 57 of file ValueChecker.h.

Referenced by Arcane::mesh::DynamicMeshChecker::checkValidReplication().

Here is the caller graph for this function:

◆ areEqualArray() [1/3]

template<typename T1, typename T2, typename ValueType = typename T1::value_type, typename X1 = std::is_convertible<T1, Span<const ValueType>>, typename X2 = std::is_convertible<T1, Span<const ValueType>>>
void Arcane::ValueChecker::areEqualArray ( const T1 & x_values,
const T2 & x_expected_values,
const String & message )
inline

Checks that the two arrays values and expected_values have the same values.

Definition at line 72 of file ValueChecker.h.

References Arcane::SpanImpl< T, SizeType, Extent >::size().

Referenced by areEqualArray(), areEqualArray(), and Arcane::mesh::DynamicMeshChecker::checkValidReplication().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ areEqualArray() [2/3]

template<typename T>
void Arcane::ValueChecker::areEqualArray ( SmallSpan2< T > values,
SmallSpan2< T > expected_values,
const String & message )
inline

Checks that the two arrays values and expected_values have the same values.

Definition at line 124 of file ValueChecker.h.

References areEqualArray().

Here is the call graph for this function:

◆ areEqualArray() [3/3]

template<typename T>
void Arcane::ValueChecker::areEqualArray ( Span2< const T > values,
Span2< const T > expected_values,
const String & message )
inline

Checks that the two 2D arrays values and expected_values have the same values.

Definition at line 102 of file ValueChecker.h.

References areEqualArray(), and Arcane::Span2Impl< T, SizeType, Extent1, Extent2 >::dim1Size().

Here is the call graph for this function:

◆ nbError()

Integer Arcane::ValueChecker::nbError ( ) const
inline

Number of errors.

Definition at line 145 of file ValueChecker.h.

◆ setThrowOnError()

void Arcane::ValueChecker::setThrowOnError ( bool v)
inline

Indicates whether an exception is thrown in case of an error.

Definition at line 136 of file ValueChecker.h.

◆ throwIfError()

void Arcane::ValueChecker::throwIfError ( )

Throws an exception if nbError()!=0.

Definition at line 44 of file ValueChecker.cc.

◆ throwOnError()

bool Arcane::ValueChecker::throwOnError ( ) const
inline

Indicates whether an exception is thrown in case of an error.

Definition at line 142 of file ValueChecker.h.

Member Data Documentation

◆ m_last_error_str

String Arcane::ValueChecker::m_last_error_str
private

Definition at line 152 of file ValueChecker.h.

◆ m_nb_error

Integer Arcane::ValueChecker::m_nb_error
private

Definition at line 150 of file ValueChecker.h.

◆ m_ostr

OStringStream Arcane::ValueChecker::m_ostr
private

Definition at line 151 of file ValueChecker.h.

◆ m_throw_on_error

bool Arcane::ValueChecker::m_throw_on_error
private

Definition at line 153 of file ValueChecker.h.

◆ m_trace_info

TraceInfo Arcane::ValueChecker::m_trace_info
private

Definition at line 149 of file ValueChecker.h.


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