Return type for returning a value and status (errata). More...
#include <Errata.h>
Inherits ts::RvBase.
Public Types | |
typedef Rv | self |
Standard self reference type. | |
typedef RvBase | super |
Standard super class reference type. | |
typedef R | Result |
Type of result value. | |
Public Member Functions | |
Rv () | |
Default constructor. | |
Rv (Result const &r) | |
Standard (success) constructor. | |
Rv (Result const &r, Errata const &s) | |
Construct from a result and a pre-existing status object. | |
operator Result const & () const | |
User conversion to the result type. | |
Result & | operator= (Result const &r) |
Assignment from result type. | |
template<typename U > | |
self & | push (Rv< U > const &that) |
Add the status from another instance to this one. | |
self & | set (Result const &r) |
Set the result. | |
Result & | result () |
Return the result. | |
Result const & | result () const |
Return the result. | |
Errata & | errata () |
Return the status. | |
Errata const & | errata () const |
Return the status. | |
self & | operator= (Errata const &status) |
Directly set the errata. | |
self & | push (Errata::Message const &msg) |
Push a message on to the status. | |
Data Fields | |
Result | _result |
The actual result of the function. |
Return type for returning a value and status (errata).
In general, a method wants to return both a result and a status so that errors are logged properly. This structure is used to do that in way that is more usable than just std::pair
. - Simpler and shorter typography - Force use of errata
rather than having to remember it (and the order) each time - Enable assignment directly to R for ease of use and compatibility so clients can upgrade asynchronously.
Definition at line 650 of file Errata.h.
Return the status.
errata
in this object. Definition at line 920 of file Errata.h.
References ts::RvBase::_errata.
Referenced by ts::config::Builder::literalValue(), main(), ts::config::detail::ValueTable::make(), ts::config::Value::makeChild(), and ts::Rv< R >::push().
Return the status.
errata
in this object. Definition at line 919 of file Errata.h.
References ts::RvBase::_errata.
User conversion to the result type.
This makes it easy to use the function normally or to pass the result only to other functions without having to extract it by hand.
Definition at line 914 of file Errata.h.
References ts::Rv< R >::_result.
Assignment from result type.
This allows the result to be assigned to a pre-declared return value structure. The return value is a reference to the internal result so that this operator can be chained in other assignments to instances of result type. This is most commonly used when the result is computed in to a local variable to be both returned and stored in a member.
Rv<int> zret; int value; ... complex computations, result in value this->m_value = zret = value; ... return zret;
r | Result to assign |
Definition at line 712 of file Errata.h.
References ts::Rv< R >::_result.
Directly set the errata.
status | Errata to assign. |
Definition at line 927 of file Errata.h.
References ts::RvBase::_errata.
Rv< T > & ts::Rv< T >::push | ( | Errata::Message const & | msg | ) |
Push a message on to the status.
Definition at line 932 of file Errata.h.
References ts::RvBase::_errata, and ts::Errata::push().
Add the status from another instance to this one.
this
object. that | Source of status messages |
Definition at line 937 of file Errata.h.
References ts::RvBase::_errata, ts::Rv< R >::errata(), and ts::Errata::push().
T const & ts::Rv< T >::result | ( | ) | const |
Return the result.
Definition at line 917 of file Errata.h.
References ts::Rv< R >::_result, and T.
T & ts::Rv< T >::result | ( | ) |
Return the result.
Definition at line 918 of file Errata.h.
References ts::Rv< R >::_result, and T.
Referenced by ts::config::Builder::literalValue(), ts::config::Configuration::loadFromPath(), main(), ts::config::Value::makeChild(), ts::config::Value::makeInteger(), ts::config::Value::makePath(), ts::config::Value::makeString(), and ts::config::Builder::pathClose().
Set the result.
This differs from assignment of the function result in that the return value is a reference to the Rv
, not the internal result. This makes it useful for assigning a result local variable and then returning.
Rv<int> zret; int value; ... complex computation, result in value return zret.set(value);
r | Result to store |
Definition at line 922 of file Errata.h.
References ts::Rv< R >::_result.
The actual result of the function.
Definition at line 655 of file Errata.h.
Referenced by ts::Rv< R >::operator Result const &(), ts::Rv< R >::operator=(), ts::Rv< R >::result(), and ts::Rv< R >::set().