MeshLib C++ Docs
Loading...
Searching...
No Matches
MRExpected.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4#include "MRPch/MRBindingMacros.h"
5#include "MRPch/MRExpected.h"
6#include <string>
7
8namespace MR
9{
12
13
14#if MR_USE_STD_EXPECTED || defined(MR_DOT_NET_BUILD)
15
16template<class T, class E = std::string>
17using Expected = std::expected<T, E>;
18
19template<class E = std::string>
20using Unexpected = std::unexpected<E>;
21
22template <class E>
23MR_BIND_IGNORE inline auto unexpected( E &&e )
24{
25 return std::unexpected( std::forward<E>( e ) );
26}
27
28#else
29
30template<class T, class E = std::string>
31using Expected = tl::expected<T, E>;
32
33template<class E = std::string>
34using Unexpected = tl::unexpected<E>;
35
36template <class E>
37MR_BIND_IGNORE inline auto unexpected( E &&e )
38{
39 return tl::make_unexpected( std::forward<E>( e ) );
40}
41
42#endif
43
46{
47 return "Operation was canceled";
48}
49
55
58{
59 return "Unsupported file extension";
60}
61
67
70{
71 return "Unsupported file format";
72}
73
79
81#define MR_RETURN_IF_UNEXPECTED( expr ) \
82 if ( auto&& res = ( expr ); !res ) \
83 return unexpected( std::move( res.error() ) );
84
85}
MR_BIND_IGNORE std::string stringUnsupportedFileExtension()
common message about unknown file extension
Definition MRExpected.h:57
MR_BIND_IGNORE auto unexpected(E &&e)
Definition MRExpected.h:37
tl::expected< T, E > Expected
Definition MRExpected.h:31
MR_BIND_IGNORE auto unexpectedUnsupportedFileExtension()
returns Expected error with stringUnsupportedFileExtension()
Definition MRExpected.h:63
MR_BIND_IGNORE auto unexpectedUnsupportedFileFormat()
returns Expected error with stringUnsupportedFileFormat()
Definition MRExpected.h:75
MR_BIND_IGNORE auto unexpectedOperationCanceled()
returns Expected error with stringOperationCanceled()
Definition MRExpected.h:51
tl::unexpected< E > Unexpected
Definition MRExpected.h:34
std::array< Vector3f, 3 > MR_BIND_IGNORE
Definition MRMeshBuilderTypes.h:13
MR_BIND_IGNORE std::string stringUnsupportedFileFormat()
common message prefix about unsupported file format
Definition MRExpected.h:69
MR_BIND_IGNORE std::string stringOperationCanceled()
common message about user termination of an operation
Definition MRExpected.h:45
only for bindings generation
Definition MRCameraOrientationPlugin.h:8