Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
kcenon::network::Result< T > Class Template Reference

#include <result_types.h>

Collaboration diagram for kcenon::network::Result< T >:
Collaboration graph

Public Member Functions

 Result (const T &val)
 
 Result (T &&val)
 
 Result (const simple_error &err)
 
bool is_ok () const
 
bool is_err () const
 
const T & value () const
 
T & value ()
 
const simple_errorerror () const
 
 operator bool () const
 

Static Public Member Functions

template<typename U = T>
static Result< T > ok (U &&value)
 
static Result< T > err (const simple_error &error)
 
static Result< T > err (int code, const std::string &message, const std::string &source="")
 

Private Attributes

std::variant< T, simple_errordata_
 

Detailed Description

template<typename T>
class kcenon::network::Result< T >
Examples
/home/runner/work/network_system/network_system/include/kcenon/network/types/result.h.

Definition at line 128 of file result_types.h.

Constructor & Destructor Documentation

◆ Result() [1/3]

template<typename T >
kcenon::network::Result< T >::Result ( const T & val)
inline

Definition at line 130 of file result_types.h.

130: data_(val) {}
std::variant< T, simple_error > data_

Referenced by kcenon::network::Result< T >::err(), kcenon::network::Result< T >::err(), and kcenon::network::Result< T >::ok().

Here is the caller graph for this function:

◆ Result() [2/3]

template<typename T >
kcenon::network::Result< T >::Result ( T && val)
inline

Definition at line 131 of file result_types.h.

131: data_(std::forward<T>(val)) {}

◆ Result() [3/3]

template<typename T >
kcenon::network::Result< T >::Result ( const simple_error & err)
inline

Definition at line 132 of file result_types.h.

132: data_(err) {}
static Result< T > err(const simple_error &error)

Member Function Documentation

◆ err() [1/2]

template<typename T >
static Result< T > kcenon::network::Result< T >::err ( const simple_error & error)
inlinestatic

Definition at line 140 of file result_types.h.

140 {
141 return Result<T>(error);
142 }
const simple_error & error() const

References kcenon::network::Result< T >::error(), and kcenon::network::Result< T >::Result().

Referenced by kcenon::network::core::session_handle::send(), and kcenon::network::core::session_model< SessionType >::send().

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

◆ err() [2/2]

template<typename T >
static Result< T > kcenon::network::Result< T >::err ( int code,
const std::string & message,
const std::string & source = "" )
inlinestatic

Definition at line 144 of file result_types.h.

144 {
145 return Result<T>(simple_error(code, message, source));
146 }

References kcenon::network::message, and kcenon::network::Result< T >::Result().

Here is the call graph for this function:

◆ error()

template<typename T >
const simple_error & kcenon::network::Result< T >::error ( ) const
inline

Definition at line 154 of file result_types.h.

154{ return std::get<simple_error>(data_); }

References kcenon::network::Result< T >::data_.

Referenced by kcenon::network::Result< T >::err().

Here is the caller graph for this function:

◆ is_err()

template<typename T >
bool kcenon::network::Result< T >::is_err ( ) const
inline

Definition at line 149 of file result_types.h.

149{ return !is_ok(); }

References kcenon::network::Result< T >::is_ok().

Referenced by kcenon::network::protocols::grpc::service_registry::impl::configure_server().

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

◆ is_ok()

template<typename T >
bool kcenon::network::Result< T >::is_ok ( ) const
inline

Definition at line 148 of file result_types.h.

148{ return std::holds_alternative<T>(data_); }

References kcenon::network::Result< T >::data_.

Referenced by kcenon::network::Result< T >::is_err(), and kcenon::network::Result< T >::operator bool().

Here is the caller graph for this function:

◆ ok()

template<typename T >
template<typename U = T>
static Result< T > kcenon::network::Result< T >::ok ( U && value)
inlinestatic

Definition at line 136 of file result_types.h.

136 {
137 return Result<T>(std::forward<U>(value));
138 }
const T & value() const

References kcenon::network::Result< T >::Result(), and kcenon::network::Result< T >::value().

Referenced by kcenon::network::core::session_model< SessionType >::send().

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

◆ operator bool()

template<typename T >
kcenon::network::Result< T >::operator bool ( ) const
inline

Definition at line 156 of file result_types.h.

156{ return is_ok(); }

References kcenon::network::Result< T >::is_ok().

Here is the call graph for this function:

◆ value() [1/2]

template<typename T >
T & kcenon::network::Result< T >::value ( )
inline

Definition at line 152 of file result_types.h.

152{ return std::get<T>(data_); }

References kcenon::network::Result< T >::data_.

◆ value() [2/2]

template<typename T >
const T & kcenon::network::Result< T >::value ( ) const
inline

Definition at line 151 of file result_types.h.

151{ return std::get<T>(data_); }

References kcenon::network::Result< T >::data_.

Referenced by kcenon::network::Result< T >::ok().

Here is the caller graph for this function:

Member Data Documentation

◆ data_


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