Android-cuttlefish cvd tool
Classes | Namespaces | Macros | Typedefs | Functions | Variables
result.h File Reference
#include <assert.h>
#include <errno.h>
#include <sstream>
#include <string>
#include <type_traits>
#include "android-base/errors.h"
#include "android-base/expected.h"
#include "android-base/format.h"
Include dependency graph for result.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  android::base::Errno
 
struct  android::base::ResultError< E, include_message >
 
struct  android::base::ResultError< E, false >
 
struct  android::base::internal::DoNothingStream
 
class  android::base::Error< E, include_message, typename >
 
struct  android::base::impl::ConversionBase< T >
 
struct  android::base::impl::NumericConversions< T, typename >
 
struct  android::base::impl::NumericConversions< T, std::enable_if_t< impl::IsNumeric< impl::Code< T > > > >
 
struct  android::base::OkOrFail< Result< T, E, include_message > >
 

Namespaces

namespace  android
 
namespace  android::base
 
namespace  android::base::internal
 
namespace  android::base::impl
 

Macros

#define Errorf(fmt, ...)   android::base::ErrorfImpl(FMT_STRING(fmt), ##__VA_ARGS__)
 
#define ErrnoErrorf(fmt, ...)   android::base::ErrnoErrorfImpl(FMT_STRING(fmt), ##__VA_ARGS__)
 
#define SPECIALIZED_CONVERSION(type)
 
#define ASSERT_RESULT_OK(stmt)
 
#define EXPECT_RESULT_OK(stmt)
 

Typedefs

template<typename T , typename E = Errno, bool include_message = true>
using android::base::Result = android::base::expected< T, ResultError< E, include_message > >
 
template<typename U >
using android::base::impl::Code = std::decay_t< decltype(std::declval< U >().error().code())>
 
template<typename U >
using android::base::impl::ErrorType = std::decay_t< decltype(std::declval< U >().error())>
 

Functions

template<typename E >
bool android::base::operator== (const ResultError< E > &lhs, const ResultError< E > &rhs)
 
template<typename E >
bool android::base::operator!= (const ResultError< E > &lhs, const ResultError< E > &rhs)
 
template<typename E >
std::ostream & android::base::operator<< (std::ostream &os, const ResultError< E > &t)
 
Error< Errno > android::base::ErrnoError ()
 
template<typename E >
android::base::ErrorCode (E code)
 
template<typename T , typename E , typename... Args>
android::base::ErrorCode (E code, T &&t, const Args &... args)
 
template<typename T , typename... Args>
Error< Errno > android::base::ErrorfImpl (const T &&fmt, const Args &... args)
 
template<typename T , typename... Args>
Error< Errno > android::base::ErrnoErrorfImpl (const T &&fmt, const Args &... args)
 

Variables

template<typename U >
constexpr bool android::base::impl::IsNumeric
 

Macro Definition Documentation

◆ ASSERT_RESULT_OK

#define ASSERT_RESULT_OK (   stmt)
Value:
if (const auto& tmp = (stmt); !tmp.ok()) \
FAIL() << "Value of: " << #stmt << "\n" \
<< " Actual: " << tmp.error().message() << "\n" \
<< "Expected: is ok\n"

◆ ErrnoErrorf

#define ErrnoErrorf (   fmt,
  ... 
)    android::base::ErrnoErrorfImpl(FMT_STRING(fmt), ##__VA_ARGS__)

◆ Errorf

#define Errorf (   fmt,
  ... 
)    android::base::ErrorfImpl(FMT_STRING(fmt), ##__VA_ARGS__)

◆ EXPECT_RESULT_OK

#define EXPECT_RESULT_OK (   stmt)
Value:
if (const auto& tmp = (stmt); !tmp.ok()) \
ADD_FAILURE() << "Value of: " << #stmt << "\n" \
<< " Actual: " << tmp.error().message() << "\n" \
<< "Expected: is ok\n"

◆ SPECIALIZED_CONVERSION

#define SPECIALIZED_CONVERSION (   type)
Value:
operator const expected<type, ErrorType<T>>() const &&\
{ return unexpected(std::move(this->error_));}
unexpected(E) -> unexpected< E >