Blender V5.3
blender::ed::asset::index::ReadingResult< T > Class Template Reference

#include <asset_index.hh>

Public Types

enum class  Type { Success , Failure , Cancelled }

Public Member Functions

 ReadingResult (Type type)
bool is_success () const
bool is_failure () const
bool is_cancelled () const
bool has_warnings () const
template<typename U>
void move_warnings_from (ReadingResult< U > &other)
ReadingResult without_success_value () const
template<typename U = T>
requires (!std::is_same_v<U, std::monostate>)
T & operator* ()
template<typename U = T>
requires (!std::is_same_v<U, std::monostate>)
const T & operator* () const
template<typename U = T>
requires (!std::is_same_v<U, std::monostate>)
T * operator-> ()
template<typename U = T>
requires (!std::is_same_v<U, std::monostate>)
const T * operator-> () const
template<typename U>
 ReadingResult (const ReadingResult< U > &other)

Static Public Member Functions

template<typename U = T>
requires (std::is_same_v<U, std::monostate>)
static ReadingResult Success ()
template<typename U = T>
requires (!std::is_same_v<U, std::monostate>)
static ReadingResult Success (T value)
static ReadingResult Failure (const StringRef failure_reason)
static ReadingResult Cancelled ()

Public Attributes

Type type
std::string failure_reason
std::optional< T > success_value
Vector< std::string > warnings

Detailed Description

template<typename T = std::monostate>
class blender::ed::asset::index::ReadingResult< T >

Result of reading a remote listing.

Can be in any of these three states:

type=Success: has a 'success value' of type T, and a vector of warnings (strings; may be empty).

type=Failure: has a 'failure message' (may be empty, but for good UX better to always use).

type=Cancelled: has no extra info, because this was in response to a user cancelling an operation (and so this happening should be expected).

Definition at line 48 of file asset_index.hh.

Member Enumeration Documentation

◆ Type

template<typename T = std::monostate>
enum class blender::ed::asset::index::ReadingResult::Type
strong
Enumerator
Success 
Failure 
Cancelled 

Definition at line 50 of file asset_index.hh.

Constructor & Destructor Documentation

◆ ReadingResult() [1/2]

template<typename T = std::monostate>
blender::ed::asset::index::ReadingResult< T >::ReadingResult ( Type type)
inlineexplicit

Construct a ReadingResult with the given type.

NOTE: Do not use this function, use one of the above functions instead. It's public only because it's needed in internal code of this class, but across differently-templated versions of this class (which C++ considers to be unrelated, and thus cannot access each other's private members).

Definition at line 125 of file asset_index.hh.

References type.

Referenced by Cancelled(), Failure(), move_warnings_from(), ReadingResult(), Success(), Success(), and without_success_value().

◆ ReadingResult() [2/2]

template<typename T = std::monostate>
template<typename U>
blender::ed::asset::index::ReadingResult< T >::ReadingResult ( const ReadingResult< U > & other)
inline

Conversion constructor from any other ReadingResult.

Definition at line 226 of file asset_index.hh.

References failure_reason, ReadingResult(), Success, success_value, and type.

Member Function Documentation

◆ Cancelled()

template<typename T = std::monostate>
ReadingResult blender::ed::asset::index::ReadingResult< T >::Cancelled ( )
inlinestatic

Construct a cancelled result.

Callback functions passed to index::read_remote_listing() can return false to indicate the loading should be cancelled.

Definition at line 112 of file asset_index.hh.

References Cancelled, and ReadingResult().

Referenced by blender::ed::asset::index::listing_entries_from_root(), and blender::ed::asset::index::read_remote_listing_v1().

◆ Failure()

template<typename T = std::monostate>
ReadingResult blender::ed::asset::index::ReadingResult< T >::Failure ( const StringRef failure_reason)
inlinestatic

Construct a failure result. The ReadingResult copies the failure reason, so the StringRef can refer to temporary data.

NOTE: Don't forget to wrap the string in N_(...) for translation tagging.

Definition at line 100 of file asset_index.hh.

References Failure, failure_reason, ReadingResult(), and blender::result.

◆ has_warnings()

template<typename T = std::monostate>
bool blender::ed::asset::index::ReadingResult< T >::has_warnings ( ) const
inline

◆ is_cancelled()

template<typename T = std::monostate>
bool blender::ed::asset::index::ReadingResult< T >::is_cancelled ( ) const
inline

Return whether this result indicates cancellation.

Definition at line 138 of file asset_index.hh.

References Cancelled.

Referenced by blender::ed::asset::index::listing_entries_from_root(), and blender::ed::asset::index::read_remote_listing_v1().

◆ is_failure()

template<typename T = std::monostate>
bool blender::ed::asset::index::ReadingResult< T >::is_failure ( ) const
inline

Return whether this result indicates a failure.

Definition at line 133 of file asset_index.hh.

References Failure.

Referenced by blender::ed::asset::index::listing_entries_from_root(), and blender::ed::asset::index::read_remote_listing_v1().

◆ is_success()

◆ move_warnings_from()

template<typename T = std::monostate>
template<typename U>
void blender::ed::asset::index::ReadingResult< T >::move_warnings_from ( ReadingResult< U > & other)
inline

Move the warnings from another result into this one.

Definition at line 151 of file asset_index.hh.

References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), BLI_assert_msg, is_success(), ReadingResult(), and warnings.

◆ operator*() [1/2]

template<typename T = std::monostate>
template<typename U = T>
requires (!std::is_same_v<U, std::monostate>)
T & blender::ed::asset::index::ReadingResult< T >::operator* ( )
inline

Get a reference to the result's success value, similar to std::optional<T>. Only valid if this result is successful and there is an actual success value.

Definition at line 178 of file asset_index.hh.

References BLI_assert_msg, is_success(), success_value, and T.

◆ operator*() [2/2]

template<typename T = std::monostate>
template<typename U = T>
requires (!std::is_same_v<U, std::monostate>)
const T & blender::ed::asset::index::ReadingResult< T >::operator* ( ) const
inline

Get a reference to the result's success value, similar to std::optional<T>. Only valid if this result is successful and there is an actual success value.

Definition at line 191 of file asset_index.hh.

References BLI_assert_msg, is_success(), success_value, T, and blender::U.

◆ operator->() [1/2]

template<typename T = std::monostate>
template<typename U = T>
requires (!std::is_same_v<U, std::monostate>)
T * blender::ed::asset::index::ReadingResult< T >::operator-> ( )
inline

Get a pointer to the result's success value, similar to std::optional<T>. Only valid if this result is successful and there is an actual success value.

Definition at line 204 of file asset_index.hh.

References success_value, and T.

◆ operator->() [2/2]

template<typename T = std::monostate>
template<typename U = T>
requires (!std::is_same_v<U, std::monostate>)
const T * blender::ed::asset::index::ReadingResult< T >::operator-> ( ) const
inline

Get a pointer to the result's success value, similar to std::optional<T>. Only valid if this result is successful and there is an actual success value.

Definition at line 216 of file asset_index.hh.

References success_value, T, and blender::U.

◆ Success() [1/2]

◆ Success() [2/2]

template<typename T = std::monostate>
template<typename U = T>
requires (!std::is_same_v<U, std::monostate>)
ReadingResult blender::ed::asset::index::ReadingResult< T >::Success ( T value)
inlinestatic

Construct a valued success result. Only enabled if T != std::monostate.

Definition at line 86 of file asset_index.hh.

References ReadingResult(), blender::result, Success, and T.

◆ without_success_value()

template<typename T = std::monostate>
ReadingResult blender::ed::asset::index::ReadingResult< T >::without_success_value ( ) const
inline

Return this ReadingResult, but without its success value.

The result type, failure message, and warnings are copied.

Definition at line 164 of file asset_index.hh.

References failure_reason, ReadingResult(), success_value, and warnings.

Referenced by blender::ed::asset::index::read_remote_listing().

Member Data Documentation

◆ failure_reason

◆ success_value

template<typename T = std::monostate>
std::optional<T> blender::ed::asset::index::ReadingResult< T >::success_value

◆ type

template<typename T = std::monostate>
Type blender::ed::asset::index::ReadingResult< T >::type

Definition at line 55 of file asset_index.hh.

Referenced by ReadingResult(), and ReadingResult().

◆ warnings

template<typename T = std::monostate>
Vector<std::string> blender::ed::asset::index::ReadingResult< T >::warnings

Even when an operation was performed successfully, there could have been warnings. These are only intended to be used on success status; on failure, only failure_reason is expected to be set. On cancellation, no reason needs to be given (as it is in response to the user cancelling the operation).

See also
ReadingResult::append_warning()

Definition at line 68 of file asset_index.hh.

Referenced by blender::ed::asset::index::listing_entries_from_root(), move_warnings_from(), blender::ed::asset::index::read_remote_listing_v1(), and without_success_value().


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