itom
Loading...
Searching...
No Matches
ito::RetVal Class Reference

Class for managing status values (like errors or warning) More...

#include <retVal.h>

Public Member Functions

 RetVal ()
 default constructor that creates a RetVal with status ito::retOk, code 0 and no message.
 
 RetVal (tRetValue retValue)
 
 RetVal (int retValue)
 
 RetVal (ito::tRetValue retValue, int retCode, const char *pRetMessage)
 
 ~RetVal ()
 destructor
 
RetValoperator= (const RetVal &rhs)
 
RetValoperator+= (const RetVal &rhs)
 
RetVal operator+ (const RetVal &rhs)
 
char operator== (const RetVal &rhs) const
 
char operator!= (const RetVal &rhs) const
 
char operator== (const tRetValue rhs) const
 
char operator!= (const tRetValue rhs) const
 
void appendRetMessage (const char *addRetMessage)
 
int containsWarning () const
 
int containsError () const
 
int containsWarningOrError () const
 
bool hasErrorMessage () const
 
int errorCode () const
 
const char * errorMessage () const
 

Static Public Member Functions

static RetVal format (ito::tRetValue retValue, int retCode, const char *pRetMessage,...)
 

Private Attributes

tRetValue m_retValue
 
int m_retCode
 
ByteArray m_retMessage
 

Detailed Description

Class for managing status values (like errors or warning)

The RetVal class is used for handling return codes. All classes should use this class. In case an error occurs, only the first error is stored and will not be overridden by potentially subsequent occurring errors. An error is more severe than a warning and will overwrite a warning if it is added to an existing RetVal.

Constructor & Destructor Documentation

◆ RetVal() [1/3]

ito::RetVal::RetVal ( tRetValue retValue)
inline

default constructor that creates a RetVal with the status given by retValue, code 0 and no message.

◆ RetVal() [2/3]

ito::RetVal::RetVal ( int retValue)
inline

default constructor that creates a RetVal with the status given by retValue, code 0 and no message.

◆ RetVal() [3/3]

ito::RetVal::RetVal ( ito::tRetValue retValue,
int retCode,
const char * pRetMessage )

constructor with retValue, retCode and errorMessage

Parameters
[in]retValuetype of RetVal; for possible values see tRetValue
[in]retCodeuser definable return code
[in]pRetMessageerror message to be passed or NULL, string is copied Makes a deep copy of RetVal, i.e. a copy of the error message

Member Function Documentation

◆ appendRetMessage()

void ito::RetVal::appendRetMessage ( const char * addRetMessage)

check if any warning has occurred in this return value (true), else (false)

◆ containsError()

int ito::RetVal::containsError ( ) const
inline

check if any warning or error has occurred in this return value (true), else (false)

◆ containsWarning()

int ito::RetVal::containsWarning ( ) const
inline

check if any error has occurred in this return value (true), else (false)

◆ containsWarningOrError()

int ito::RetVal::containsWarningOrError ( ) const
inline

return true if an error or warning message is available

◆ errorCode()

int ito::RetVal::errorCode ( ) const
inline

return zero-terminated error message or empty, zero-terminated string if no error message has been set

◆ format()

RetVal ito::RetVal::format ( ito::tRetValue retValue,
int retCode,
const char * pRetMessage,
... )
static

create RetVal with message that may contain placeholders using the formalism of the default sprintf method.

Parameters
retValueis the type of RetVal (retOk, retWarning, retError)
retCodeis the code number of RetVal
pRetMessageis the zero-terminated message string that may contain placeholders like s, i, ... (see sprintf)
...are further arguments. Their number and type must correspond to the placeholders in pRetMessage
Returns
created RetVal

◆ hasErrorMessage()

bool ito::RetVal::hasErrorMessage ( ) const
inline

return the error code (default: 0)

◆ operator!=() [1/2]

char ito::RetVal::operator!= ( const RetVal & rhs) const
inline

inequality operator compares retValue with with retValue of rhs RetVal. For possible constant values see tRetValue

◆ operator!=() [2/2]

char ito::RetVal::operator!= ( const tRetValue rhs) const
inline

inequality operator compares retValue with tRetValue constant. For possible constant values see tRetValue

◆ operator+()

RetVal ito::RetVal::operator+ ( const RetVal & rhs)
inline

Concatenation of RetVal See operator RetVal::operator+=

◆ operator+=()

RetVal & ito::RetVal::operator+= ( const RetVal & rhs)

Concatenation of RetVal "Adds" RetVals, i.e. returns the most serious error. In case of equally serious errors the first is retained

◆ operator=()

RetVal & ito::RetVal::operator= ( const RetVal & rhs)

assignment operator, copies values of rhs to current RetVal. Before copying current errorMessage is freed

◆ operator==() [1/2]

char ito::RetVal::operator== ( const RetVal & rhs) const
inline

equality operator compares retValue with with retValue of rhs RetVal. For possible constant values see tRetValue

◆ operator==() [2/2]

char ito::RetVal::operator== ( const tRetValue rhs) const
inline

equality operator compares retValue with tRetValue constant. For possible constant values see tRetValue

Member Data Documentation

◆ m_retCode

int ito::RetVal::m_retCode
private

message of this RetVal using ByteArray (using implicit sharing)

◆ m_retValue

tRetValue ito::RetVal::m_retValue
private

< can be one of enumeration tLogLevel values or an or-combination of these values the error code itself


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