ADBC
Arrow Database Connectivity
Loading...
Searching...
No Matches
status.h File Reference
#include <cassert>
#include <cstring>
#include <memory>
#include <sstream>
#include <string>
#include <utility>
#include <variant>
#include <vector>
#include <arrow-adbc/adbc.h>

Go to the source code of this file.

Classes

class  adbc::driver::Status
 A wrapper around AdbcStatusCode + AdbcError. More...
 
struct  adbc::driver::Status::Impl
 Private Status implementation details. More...
 
class  adbc::driver::Result< T >
 A wrapper around a value, or an error. More...
 

Macros

#define STATUS_CTOR(NAME, CODE)
 
#define RAISE_RESULT_IMPL(NAME, ERROR, LHS, RHS)
 
#define RAISE_STATUS_IMPL(NAME, ERROR, RHS)
 
#define UNWRAP_RESULT_IMPL(name, lhs, rhs)
 
#define UNWRAP_STATUS_IMPL(name, rhs)
 
#define DRIVER_CONCAT(x, y)   x##y
 
#define UNWRAP_RESULT_NAME(x, y)   DRIVER_CONCAT(x, y)
 
#define RAISE_RESULT(ERROR, LHS, RHS)    RAISE_RESULT_IMPL(UNWRAP_RESULT_NAME(driver_raise_result, __COUNTER__), ERROR, LHS, RHS)
 A helper to unwrap a Result in functions returning AdbcStatusCode.
 
#define RAISE_STATUS(ERROR, RHS)    RAISE_STATUS_IMPL(UNWRAP_RESULT_NAME(driver_raise_status, __COUNTER__), ERROR, RHS)
 A helper to unwrap a Status in functions returning AdbcStatusCode.
 
#define UNWRAP_RESULT(lhs, rhs)    UNWRAP_RESULT_IMPL(UNWRAP_RESULT_NAME(driver_unwrap_result, __COUNTER__), lhs, rhs)
 A helper to unwrap a Result in functions returning Result/Status.
 
#define UNWRAP_STATUS(rhs)    UNWRAP_STATUS_IMPL(UNWRAP_RESULT_NAME(driver_unwrap_status, __COUNTER__), rhs)
 A helper to unwrap a Status in functions returning Result/Status.
 
#define STATUS_CTOR(NAME, CODE)
 
#define UNWRAP_ERRNO_IMPL(NAME, CODE, RHS)
 
#define UNWRAP_ERRNO(CODE, RHS)    UNWRAP_ERRNO_IMPL(UNWRAP_RESULT_NAME(driver_errno, __COUNTER__), CODE, RHS)
 
#define UNWRAP_NANOARROW_IMPL(NAME, ERROR, CODE, RHS)
 
#define UNWRAP_NANOARROW(ERROR, CODE, RHS)
 

Functions

driver::Status adbc::driver::status::Ok ()
 

Macro Definition Documentation

◆ RAISE_RESULT

#define RAISE_RESULT ( ERROR,
LHS,
RHS )    RAISE_RESULT_IMPL(UNWRAP_RESULT_NAME(driver_raise_result, __COUNTER__), ERROR, LHS, RHS)

A helper to unwrap a Result in functions returning AdbcStatusCode.

◆ RAISE_RESULT_IMPL

#define RAISE_RESULT_IMPL ( NAME,
ERROR,
LHS,
RHS )
Value:
auto&& NAME = (RHS); \
if (!(NAME).has_value()) { \
return (NAME).status().ToAdbc(ERROR); \
} \
LHS = std::move((NAME).value());

◆ RAISE_STATUS

#define RAISE_STATUS ( ERROR,
RHS )    RAISE_STATUS_IMPL(UNWRAP_RESULT_NAME(driver_raise_status, __COUNTER__), ERROR, RHS)

A helper to unwrap a Status in functions returning AdbcStatusCode.

◆ RAISE_STATUS_IMPL

#define RAISE_STATUS_IMPL ( NAME,
ERROR,
RHS )
Value:
auto&& NAME = (RHS); \
if (!(NAME).ok()) { \
return (NAME).ToAdbc(ERROR); \
}

◆ STATUS_CTOR [1/2]

#define STATUS_CTOR ( NAME,
CODE )
Value:
template <typename... Args> \
static Status NAME(Args&&... args) { \
std::stringstream ss; \
([&] { ss << args; }(), ...); \
return Status(ADBC_STATUS_##CODE, ss.str()); \
}

◆ STATUS_CTOR [2/2]

#define STATUS_CTOR ( NAME,
CODE )
Value:
template <typename... Args> \
static Status NAME(Args&&... args) { \
std::stringstream ss; \
([&] { ss << args; }(), ...); \
return Status(ADBC_STATUS_##CODE, ss.str()); \
}

◆ UNWRAP_ERRNO_IMPL

#define UNWRAP_ERRNO_IMPL ( NAME,
CODE,
RHS )
Value:
auto&& NAME = (RHS); \
if (NAME != 0) { \
return adbc::driver::status::CODE("Call failed: ", #RHS, " = (errno ", NAME, ") ", \
std::strerror(NAME)); \
}

◆ UNWRAP_NANOARROW

#define UNWRAP_NANOARROW ( ERROR,
CODE,
RHS )
Value:
UNWRAP_NANOARROW_IMPL(UNWRAP_RESULT_NAME(driver_errno_na, __COUNTER__), ERROR, CODE, \
RHS)

◆ UNWRAP_NANOARROW_IMPL

#define UNWRAP_NANOARROW_IMPL ( NAME,
ERROR,
CODE,
RHS )
Value:
auto&& NAME = (RHS); \
if (NAME != 0) { \
return adbc::driver::status::CODE("nanoarrow call failed: ", #RHS, " = (", NAME, \
") ", std::strerror(NAME), ". ", (ERROR).message); \
}

◆ UNWRAP_RESULT

#define UNWRAP_RESULT ( lhs,
rhs )    UNWRAP_RESULT_IMPL(UNWRAP_RESULT_NAME(driver_unwrap_result, __COUNTER__), lhs, rhs)

A helper to unwrap a Result in functions returning Result/Status.

◆ UNWRAP_RESULT_IMPL

#define UNWRAP_RESULT_IMPL ( name,
lhs,
rhs )
Value:
auto&& name = (rhs); \
if (!(name).has_value()) { \
return std::move(name).status(); \
} \
lhs = std::move((name).value());

◆ UNWRAP_STATUS

#define UNWRAP_STATUS ( rhs)     UNWRAP_STATUS_IMPL(UNWRAP_RESULT_NAME(driver_unwrap_status, __COUNTER__), rhs)

A helper to unwrap a Status in functions returning Result/Status.

◆ UNWRAP_STATUS_IMPL

#define UNWRAP_STATUS_IMPL ( name,
rhs )
Value:
auto&& name = (rhs); \
if (!(name).ok()) { \
return std::move(name); \
}