You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/leaf.adoc
+90-55Lines changed: 90 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1733,7 +1733,12 @@ TIP: The automatically generated diagnostic messages are developer-friendly, but
1733
1733
[[tutorial-serialization]]
1734
1734
=== Serialization
1735
1735
1736
-
LEAF provides a serialization API that enables exporting error information into different formats, such as JSON. This is useful for structured logging, remote debugging, or integrating with monitoring systems. To serialize error information, use the `write_to` member function available on <<error_info>>, <<diagnostic_info>>, and <<diagnostic_details>> classes.
1736
+
LEAF provides a serialization API that enables exporting error information into different formats, such as JSON. This is useful for structured logging, remote debugging, or integrating with monitoring systems. To serialize error information, use the `write_to` member function available on the following types:
Returns: :: If `*this` is in <<result,value state>>, returns `false`, otherwise returns `true`.
5037
+
Effects: :: Destroys `*this`, then re-initializes it as if using the appropriate `result<T>` constructor. Basic exception-safety guarantee.
4980
5038
4981
5039
'''
4982
5040
4983
-
[[result::operator_bool]]
4984
-
==== `operator bool`
5041
+
[[result::operator_ptr]]
5042
+
==== `operatorpass:[->]`
4985
5043
4986
5044
.#include <boost/leaf/result.hpp>
4987
5045
[source,c++]
4988
5046
----
4989
5047
namespace boost { namespace leaf {
4990
5048
4991
5049
template <class T>
4992
-
result<T>::operator bool() const noexcept;
5050
+
T const * result<T>::operator->() const noexcept;
5051
+
5052
+
template <class T>
5053
+
T * result<T>::operator->() noexcept;
4993
5054
4994
5055
} }
4995
5056
----
4996
5057
4997
-
Returns: :: If `*this` is in <<result,value state>>, returns `true`, otherwise returns `false`.
5058
+
Returns :: If `*this` is in <<result,value state>>, returns a pointer to the stored value; otherwise returns `nullptr`.
4998
5059
4999
5060
'''
5000
5061
@@ -5036,52 +5097,26 @@ A member type of `result<T>`, defined as a synonym for `T`.
5036
5097
5037
5098
'''
5038
5099
5039
-
[[result::bad_result]]
5040
-
Effects: :: If `*this` is in <<result,value state>>, returns a reference to the stored value, otherwise throws `bad_result`.
5041
-
5042
-
'''
5043
-
5044
-
[[result::operator_ptr]]
5045
-
==== `operatorpass:[->]`
5100
+
[[result::write_to]]
5101
+
==== `write_to`
5046
5102
5047
5103
.#include <boost/leaf/result.hpp>
5048
5104
[source,c++]
5049
5105
----
5050
5106
namespace boost { namespace leaf {
5051
5107
5052
5108
template <class T>
5053
-
T const * result<T>::operator->() const noexcept;
5054
-
5055
-
template <class T>
5056
-
T * result<T>::operator->() noexcept;
5109
+
template <class Writer>
5110
+
void result<T>::write_to( Writer & w ) const;
5057
5111
5058
5112
} }
5059
5113
----
5060
5114
5061
-
Returns :: If `*this` is in <<result,value state>>, returns a pointer to the stored value; otherwise returns 0.
5062
-
5063
-
'''
5064
-
5065
-
[[result::operator_deref]]
5066
-
==== `operator*`
5067
-
5068
-
.#include <boost/leaf/result.hpp>
5069
-
[source,c++]
5070
-
----
5071
-
namespace boost { namespace leaf {
5072
-
5073
-
template <class T>
5074
-
T const & result<T>::operator*() const noexcept;
5075
-
5076
-
template <class T>
5077
-
T & result<T>::operator*() noexcept;
5078
-
5079
-
} }
5080
-
----
5115
+
The `write_to` member function is used with the serialization system; see <<tutorial-serialization>>.
5081
5116
5082
-
Requires: :: `*this` must be in <<result,value state>>.
5117
+
If the result is in <<result,value state>>, outputs the value. If it is in <<result,error state>>, outputs the <<error_id>>. If the result holds <<try_capture_all,captured error objects>>, outputs them as well.
5083
5118
5084
-
Returns :: a reference to the stored value.
5119
+
NOTE: Result objects carry error objects only when in <<try_capture_all,capture state>>. Otherwise, to output error objects, use `write_to` on <<diagnostic_details>> in an error handling scope.
0 commit comments