8.8.1.1. RetVal - Reference#

class RetVal#

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.

Public Functions

inline RetVal()#

default constructor that creates a RetVal with status ito::retOk, code 0 and no message.

inline RetVal(tRetValue retValue)

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

inline RetVal(int retValue)

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

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

constructor with retValue, retCode and errorMessage

Parameters:
  • retValue[in] type of RetVal; for possible values see tRetValue

  • retCode[in] user definable return code

  • pRetMessage[in] error message to be passed or NULL, string is copied Makes a deep copy of RetVal, i.e. a copy of the error message

inline ~RetVal()#

destructor

RetVal &operator=(const RetVal &rhs)#

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

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

inline RetVal operator+(const RetVal &rhs)#

Concatenation of RetVal See operator RetVal::operator+=

inline char operator==(const RetVal &rhs) const#

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

inline char operator!=(const RetVal &rhs) const#

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

inline char operator==(const tRetValue rhs) const#

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

inline char operator!=(const tRetValue rhs) const#

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

void appendRetMessage(const char *addRetMessage)#

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

inline int containsWarning() const#

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

inline int containsError() const#

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

inline int containsWarningOrError() const#

return true if an error or warning message is available

inline bool hasErrorMessage() const#

return the error code (default: 0)

inline int errorCode() const#

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

Public Static Functions

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

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

Parameters:
  • retValue – is the type of RetVal (retOk, retWarning, retError)

  • retCode – is the code number of RetVal

  • pRetMessage – is 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