WG14 result
Loading...
Searching...
No Matches
status_code.h File Reference
#include "config.h"
#include "status_code_domain.h"
Include dependency graph for status_code.h:

Go to the source code of this file.

Macros

#define STATUS_CODE_WITH_PAYLOAD(name)    struct WG14_RESULT_PREFIX(status_code_with_payload_##name)
 The type of a status code with named payload. You must call STATUS_CODE_WITH_PAYLOAD_DECLARE(T, name) first.
 
#define STATUS_CODE_WITH_PAYLOAD_DECLARE(T, name)
 
#define STATUS_CODE_WITH_PAYLOAD_MAKE(name, ...)    WG14_RESULT_PREFIX(status_code_with_payload_##name##_make)(__VA_ARGS__)
 Make a named status code previously declared.
 
#define status_code_is_empty(...)    WG14_RESULT_PREFIX(status_code_is_empty)(&(__VA_ARGS__).base)
 True if the status code is empty (convenience macro)
 
#define status_code_is_success(...)    WG14_RESULT_PREFIX(status_code_is_success)(&(__VA_ARGS__).base)
 True if the status code is a success (convenience macro)
 
#define status_code_is_failure(...)    WG14_RESULT_PREFIX(status_code_is_failure)(&(__VA_ARGS__).base)
 True if the status code is a failure (convenience macro)
 
#define status_code_message(...)    WG14_RESULT_PREFIX(status_code_message)(&(__VA_ARGS__).base)
 Retrieves the message of the status code (convenience macro). Make sure you call status_code_domain_string_ref_destroy() when you are done with the returned string reference.
 
#define status_code_strictly_equivalent(primary, secondary)
 True if the status codes are strictly semantically equivalent (convenience macro). primary's domain's equivalence function decides if secondary is semantically equivalent to it. Note that for most status codes, if the codes have the same domain, a pure value equality is performed. This operation may not be transitive.
 
#define status_code_destroy(...)
 Destroys the status code (type aware)
 
#define status_code_clone(dest, src)
 Clones the status code (type aware)
 

Macro Definition Documentation

◆ status_code_clone

#define status_code_clone (   dest,
  src 
)
Value:
({ \
typedef WG14_RESULT_TYPEOF(*(dest)) WG14_RESULT_PREFIX(_dest_code_type_); \
typedef WG14_RESULT_TYPEOF(*(src)) WG14_RESULT_PREFIX(_src_code_type_); \
WG14_RESULT_PREFIX(_dest_code_type_) * \
WG14_RESULT_PREFIX(_dest_code_ptr_) = \
(WG14_RESULT_PREFIX(_dest_code_type_) *) (&(*(dest))); \
WG14_RESULT_PREFIX(_src_code_type_) * WG14_RESULT_PREFIX(_src_code_ptr_) = \
(WG14_RESULT_PREFIX(_src_code_type_) *) (&(*(src))); \
typedef WG14_RESULT_TYPEOF(WG14_RESULT_PREFIX(_dest_code_ptr_)->value) \
WG14_RESULT_PREFIX(_dest_value_type_); \
status_code_destroy(_dest_code_ptr_); \
int WG14_RESULT_PREFIX(ret) = 0; \
if(WG14_RESULT_PREFIX(_src_code_ptr_)->base.domain != WG14_RESULT_NULLPTR) \
{ \
const WG14_RESULT_PREFIX(status_code_domain_payload_info_t) \
WG14_RESULT_PREFIX(_info_) = STATUS_CODE_DOMAIN_PAYLOAD_INFO_INIT( \
WG14_RESULT_PREFIX(_dest_value_type_)); \
WG14_RESULT_PREFIX(ret) = WG14_RESULT_VTABLE_INVOKE_API( \
WG14_RESULT_PREFIX(_src_code_ptr_)->base.domain, erased_copy, \
&WG14_RESULT_PREFIX(_dest_code_ptr_)->base, \
&WG14_RESULT_PREFIX(_src_code_ptr_)->base, WG14_RESULT_PREFIX(_info_)); \
} \
WG14_RESULT_PREFIX(ret); \
})
#define WG14_RESULT_NULLPTR
Definition config.h:47
#define WG14_RESULT_TYPEOF(...)
Definition config.h:71
#define WG14_RESULT_VTABLE_INVOKE_API(domain, name,...)
#define STATUS_CODE_DOMAIN_PAYLOAD_INFO_INIT(T)
A default initialiser for a status_code_domain_payload_info_t for.
Type of a payload info of a domain.

Clones the status code (type aware)

Definition at line 221 of file status_code.h.

◆ status_code_destroy

#define status_code_destroy (   ...)
Value:
{ \
typedef WG14_RESULT_TYPEOF_UNQUAL(*(__VA_ARGS__)) \
WG14_RESULT_PREFIX(_code_type_); \
WG14_RESULT_PREFIX(_code_type_) * WG14_RESULT_PREFIX(_code_ptr_) = \
(WG14_RESULT_PREFIX(_code_type_) *) (&(*(__VA_ARGS__))); \
if(WG14_RESULT_PREFIX(_code_ptr_)->base.domain != WG14_RESULT_NULLPTR && \
WG14_RESULT_PREFIX(_code_ptr_)->base.domain->vptr->erased_destroy != \
{ \
typedef WG14_RESULT_TYPEOF(WG14_RESULT_PREFIX(_code_ptr_)->value) \
WG14_RESULT_PREFIX(_value_type_); \
const WG14_RESULT_PREFIX(status_code_domain_payload_info_t) \
WG14_RESULT_PREFIX(_info_) = \
STATUS_CODE_DOMAIN_PAYLOAD_INFO_INIT(WG14_RESULT_PREFIX(_value_type_)); \
WG14_RESULT_VTABLE_INVOKE_API( \
WG14_RESULT_PREFIX(_code_ptr_)->base.domain, erased_destroy, \
&WG14_RESULT_PREFIX(_code_ptr_)->base, WG14_RESULT_PREFIX(_info_)); \
WG14_RESULT_PREFIX(_code_ptr_)->base.domain = WG14_RESULT_NULLPTR; \
} \
}
#define WG14_RESULT_TYPEOF_UNQUAL(...)
Definition config.h:83

Destroys the status code (type aware)

Definition at line 194 of file status_code.h.

◆ status_code_is_empty

#define status_code_is_empty (   ...)     WG14_RESULT_PREFIX(status_code_is_empty)(&(__VA_ARGS__).base)

True if the status code is empty (convenience macro)

Definition at line 172 of file status_code.h.

◆ status_code_is_failure

#define status_code_is_failure (   ...)     WG14_RESULT_PREFIX(status_code_is_failure)(&(__VA_ARGS__).base)

True if the status code is a failure (convenience macro)

Definition at line 178 of file status_code.h.

◆ status_code_is_success

#define status_code_is_success (   ...)     WG14_RESULT_PREFIX(status_code_is_success)(&(__VA_ARGS__).base)

True if the status code is a success (convenience macro)

Definition at line 175 of file status_code.h.

◆ status_code_message

#define status_code_message (   ...)     WG14_RESULT_PREFIX(status_code_message)(&(__VA_ARGS__).base)

Retrieves the message of the status code (convenience macro). Make sure you call status_code_domain_string_ref_destroy() when you are done with the returned string reference.

Definition at line 183 of file status_code.h.

◆ status_code_strictly_equivalent

#define status_code_strictly_equivalent (   primary,
  secondary 
)
Value:
WG14_RESULT_PREFIX(status_code_strictly_equivalent) \
(&(primary).base, &(secondary).base)
#define status_code_strictly_equivalent(primary, secondary)
True if the status codes are strictly semantically equivalent (convenience macro)....

True if the status codes are strictly semantically equivalent (convenience macro). primary's domain's equivalence function decides if secondary is semantically equivalent to it. Note that for most status codes, if the codes have the same domain, a pure value equality is performed. This operation may not be transitive.

Definition at line 190 of file status_code.h.

◆ STATUS_CODE_WITH_PAYLOAD

#define STATUS_CODE_WITH_PAYLOAD (   name)     struct WG14_RESULT_PREFIX(status_code_with_payload_##name)

The type of a status code with named payload. You must call STATUS_CODE_WITH_PAYLOAD_DECLARE(T, name) first.

Definition at line 37 of file status_code.h.

◆ STATUS_CODE_WITH_PAYLOAD_DECLARE

#define STATUS_CODE_WITH_PAYLOAD_DECLARE (   T,
  name 
)
Value:
struct WG14_RESULT_PREFIX(status_code_with_payload_##name) \
{ \
WG14_RESULT_PREFIX(status_code_untyped) base; \
T value; \
}; \
WG14_RESULT_INLINE struct WG14_RESULT_PREFIX( \
status_code_with_payload_##name) \
WG14_RESULT_PREFIX(status_code_with_payload_##name##_make)(T val) \
{ \
struct WG14_RESULT_PREFIX(status_code_with_payload_##name) \
ret = {{&name##_domain}, val}; \
return ret; \
}
#define WG14_RESULT_INLINE
Definition config.h:63
Type of an untyped status code.

Definition at line 44 of file status_code.h.

◆ STATUS_CODE_WITH_PAYLOAD_MAKE

#define STATUS_CODE_WITH_PAYLOAD_MAKE (   name,
  ... 
)     WG14_RESULT_PREFIX(status_code_with_payload_##name##_make)(__VA_ARGS__)

Make a named status code previously declared.

Definition at line 59 of file status_code.h.