avcpp 3.1.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
Loading...
Searching...
No Matches
av::OptionalErrorCode Class Reference

Carries the caller's choice between exceptions and error codes. More...

#include <averror.h>

Public Member Functions

 OptionalErrorCode (std::error_code &ec)
 Report errors through the given variable.
 operator bool () const
 Whether the caller supplied an error code variable.
std::error_code & operator* ()
 The caller's variable.

Static Public Member Functions

static OptionalErrorCode null ()
 The value that means "the caller wants no error code".

Detailed Description

A function that can fail takes an OptionalErrorCode as its last parameter. The default is throws(), which makes the function throw av::Exception; passing a std::error_code& makes it store the code instead. The object is a non-owning pointer to that variable, so the variable must outlive the call.

Examples
api2-generate-subtitles.cpp.

Constructor & Destructor Documentation

◆ OptionalErrorCode()

av::OptionalErrorCode::OptionalErrorCode ( std::error_code & ec)
Parameters
ecthe variable that receives the error; it must outlive the call

Member Function Documentation

◆ null()

OptionalErrorCode av::OptionalErrorCode::null ( )
static
Returns
an empty holder; used by throws() as the default argument

◆ operator bool()

av::OptionalErrorCode::operator bool ( ) const
Returns
true when a variable was passed

◆ operator*()

std::error_code & av::OptionalErrorCode::operator* ( )
Returns
the variable the holder points at

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