IOStatus Class Reference

CPP API: mio::IOStatus Class Reference
mio::IOStatus Class Reference

IOStatus represents the result of an operation. More...

#include <io.h>

Public Member Functions

const std::error_code & code () const
 get the error code. More...
 
 IOStatus ()=default
 default constructor, represents success More...
 
 IOStatus (std::error_code ec, std::string msg={})
 constructor with error code and message More...
 
const std::string & message () const
 get the message that contains additional information about errors. More...
 
bool operator== (const IOStatus &other) const
 equality comparison operators. More...
 
bool operator!= (const IOStatus &other) const
 equality comparison operators. More...
 
bool is_ok () const
 Check if the status represents success. More...
 
 operator bool () const
 Check if the status represents success. More...
 
std::error_code m_ec = {}
 Check if the status represents failure. More...
 
std::string m_msg = {}
 Check if the status represents failure. More...
 
bool is_error () const
 Check if the status represents failure. More...
 
std::string formatted_message () const
 Get a string that combines the error code and the message. More...
 

Detailed Description

IOStatus represents the result of an operation.

Consists of an error code and additional information in a string message. The error code may be a value from mio::StatusCode or from a dependency. The category of the error code can be inspected to see where the error code originated; see https://en.cppreference.com/w/cpp/error/error_code.

Constructor & Destructor Documentation

◆ IOStatus() [1/2]

mio::IOStatus::IOStatus ( )
default

default constructor, represents success

◆ IOStatus() [2/2]

mio::IOStatus::IOStatus ( std::error_code  ec,
std::string  msg = {} 
)
inline

constructor with error code and message

Parameters
ecerror code
msgoptional message with additional information about the error, default empty.

Member Function Documentation

◆ code()

const std::error_code& mio::IOStatus::code ( ) const
inline

get the error code.

◆ formatted_message()

std::string mio::IOStatus::formatted_message ( ) const
inline

Get a string that combines the error code and the message.

◆ is_error()

bool mio::IOStatus::is_error ( ) const
inline

Check if the status represents failure.

Returns
true if status is failure, false otherwise.

◆ is_ok()

bool mio::IOStatus::is_ok ( ) const
inline

Check if the status represents success.

is_ok() is Equivalent to !bool(code()).

Returns
true if status is success, false otherwise.

◆ message()

const std::string& mio::IOStatus::message ( ) const
inline

get the message that contains additional information about errors.

◆ operator bool()

mio::IOStatus::operator bool ( ) const
inline

Check if the status represents success.

is_ok() is Equivalent to !bool(code()).

Returns
true if status is success, false otherwise.

◆ operator!=()

bool mio::IOStatus::operator!= ( const IOStatus other) const
inline

equality comparison operators.

◆ operator==()

bool mio::IOStatus::operator== ( const IOStatus other) const
inline

equality comparison operators.

Member Data Documentation

◆ m_ec

std::error_code mio::IOStatus::m_ec = {}
private

Check if the status represents failure.

Returns
true if status is failure, false otherwise.

◆ m_msg

std::string mio::IOStatus::m_msg = {}
private

Check if the status represents failure.

Returns
true if status is failure, false otherwise.