RMQ - RabbitMQ C++ Library
Public Member Functions | List of all members
BloombergLP::rmqt::Result< T > Class Template Reference

A result of an operation. More...

#include <rmqt_result.h>

Public Member Functions

 Result (const bsl::string &error, int resultCode=-1)
 Constructs an error result. More...
 
 Result (const bsl::shared_ptr< T > &value, const bsl::string &error=bsl::string(), int resultCode=0)
 
const bsl::shared_ptr< T > & value () const
 
const bsl::string & error () const
 
int returnCode () const
 
 operator BoolType () const
 
bsl::ostream & operator<< (bsl::ostream &os)
 

Detailed Description

template<typename T = void>
class BloombergLP::rmqt::Result< T >

A result of an operation.

This class provides access to an operation. The result object either contains the value of the result (if the operation was successful) or an error code and message explaining why the operation failed.

Constructor & Destructor Documentation

◆ Result() [1/2]

template<typename T = void>
BloombergLP::rmqt::Result< T >::Result ( const bsl::string &  error,
int  resultCode = -1 
)
inlineexplicit

Constructs an error result.

Parameters
errorError message
resultCodeResult code indicating the type of failure

◆ Result() [2/2]

template<typename T = void>
BloombergLP::rmqt::Result< T >::Result ( const bsl::shared_ptr< T > &  value,
const bsl::string &  error = bsl::string(),
int  resultCode = 0 
)
inlineexplicit

Constructs a result

Parameters
valueResult value
errorError message (empty indicates success)
resultCodeResult code (0 indicates success)

Member Function Documentation

◆ error()

template<typename T = void>
const bsl::string & BloombergLP::rmqt::Result< T >::error ( ) const
inline

Error message

Returns
Error message explaining the future (empty indicates success)

◆ operator BoolType()

template<typename T = void>
BloombergLP::rmqt::Result< T >::operator BoolType ( ) const
inline

Used to safely convert a Result object to bool.

◆ returnCode()

template<typename T = void>
int BloombergLP::rmqt::Result< T >::returnCode ( ) const
inline

Return code

Returns
Return code describing the result (0 indicates success)

◆ value()

template<typename T = void>
const bsl::shared_ptr< T > & BloombergLP::rmqt::Result< T >::value ( ) const
inline

Result value

Returns
Shared pointer to the result value

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