![]() |
FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
|
This is a wrapper around a Packet and a value for safe extraction. More...
#include <network_manager.hpp>
Public Member Functions | |
constexpr | ChainedArguments (fge::net::Packet const &pck, TValue *existingValue=nullptr) |
constexpr | ChainedArguments (fge::net::Packet const &pck, Error &&err, TValue *existingValue=nullptr) |
constexpr | ChainedArguments (ChainedArguments const &r)=default |
constexpr | ChainedArguments (ChainedArguments &&r) noexcept=default |
constexpr ChainedArguments & | operator= (ChainedArguments const &r)=default |
constexpr ChainedArguments & | operator= (ChainedArguments &&r) noexcept=default |
constexpr TValue * | extract () |
Extract and verify the value from the packet. | |
template<class TPeek > | |
constexpr std::optional< TPeek > | peek () |
Peek without changing the read position a copy of value. | |
constexpr fge::net::Packet const & | packet () const |
constexpr TValue const & | value () const |
constexpr TValue & | value () |
template<class TInvokable > | |
constexpr std::invoke_result_t< TInvokable, ChainedArguments< TValue > & > | and_then (TInvokable &&f) |
Chain up some code after a successful extraction. | |
template<class TInvokable , class TIndex > | |
constexpr ChainedArguments< TValue > & | and_for_each (TIndex iStart, TIndex iEnd, TIndex iIncrement, TInvokable &&f) |
Chain up some code in a for loop after a successful extraction. | |
template<class TInvokable , class TIndex > | |
constexpr ChainedArguments< TValue > & | and_for_each (TIndex iStart, TIndex iIncrement, TInvokable &&f) |
Chain up some code in a for loop after a successful extraction. | |
template<class TInvokable > | |
constexpr ChainedArguments< TValue > & | and_for_each (TInvokable &&f) |
Chain up some code in a for loop after a successful extraction. | |
template<class TInvokable > | |
constexpr std::optional< Error > | on_error (TInvokable &&f) |
Chain up some code after a unsuccessful extraction. | |
constexpr std::optional< Error > | end () |
End the chain by doing a last validity check on the packet. | |
constexpr std::optional< Error > | end (std::nullopt_t nullopt) const |
End the chain without returning an error. | |
constexpr std::optional< Error > | end (Error &&err) const |
End the chain by returning a custom error$. | |
constexpr ChainedArguments< TValue > & | apply (TValue &value) |
Apply the extracted value to the provided reference. | |
template<class TInvokable > | |
constexpr ChainedArguments< TValue > & | apply (TInvokable &&f) |
Apply the extracted value to the provided invokable argument. | |
template<class TNewValue > | |
constexpr ChainedArguments< TNewValue > | newChain (TNewValue *existingValue=nullptr) |
Create a new chain with a different value type. | |
template<class TNewValue > | |
constexpr ChainedArguments< TNewValue > | newChain (TNewValue *existingValue=nullptr) const |
Create a new chain with a different value type. | |
constexpr ChainedArguments< TValue > & | setError (Error &&err) |
Set the error. | |
constexpr ChainedArguments< TValue > & | invalidate (Error &&err) |
Invalidate the packet and set the error. | |
This is a wrapper around a Packet and a value for safe extraction.
A ChainedArguments is the argument for all network extraction rules. The goal is to chain up multiple rules and at the end output an optional error.
When the packet is invalid, the chain will stop and the error will be returned.
TValue | The type of the value that will be extracted |
|
nodiscardconstexpr |
Chain up some code in a for loop after a successful extraction.
If the packet is invalid, the chain will stop and the invokable argument will not be called.
TInvokable | The type of the invokable argument |
TIndex | The type of the index |
iStart | The starting value of the index |
iEnd | The ending value of the index |
iIncrement | The increment value of the index |
f | The invokable argument |
|
nodiscardconstexpr |
Chain up some code in a for loop after a successful extraction.
This is the same as and_for_each(TIndex iStart, TIndex iEnd, TIndex iIncrement, TInvokable&& f) but you don't have to provide the end value of the index as it will be got from the last chain result.
TInvokable | The type of the invokable argument |
TIndex | The type of the index |
iStart | The starting value of the index |
iIncrement | The increment value of the index |
f | The invokable argument |
|
nodiscardconstexpr |
Chain up some code in a for loop after a successful extraction.
This is the same as and_for_each(TIndex iStart, TIndex iEnd, TIndex iIncrement, TInvokable&& f) but you don't have to provide any index arguments as the end value of the index as it will be got from the last chain result and the start is 0.
TInvokable | The type of the invokable argument |
f | The invokable argument |
|
nodiscardconstexpr |
Chain up some code after a successful extraction.
If the packet is invalid, the chain will stop and the invokable argument will not be called.
TInvokable | The type of the invokable argument |
f | The invokable argument |
|
constexpr |
Apply the extracted value to the provided invokable argument.
TInvokable | The type of the invokable argument |
f | The invokable argument |
|
constexpr |
Apply the extracted value to the provided reference.
If the packet is invalid, the value will not be applied. When applied, the internal value is (if possible) moved to the provided reference. So value() must not be called after this.
value | The reference that will be applied |
|
nodiscardconstexpr |
End the chain by doing a last validity check on the packet.
|
nodiscardconstexpr |
End the chain by returning a custom error$.
err | The error |
|
nodiscardconstexpr |
End the chain without returning an error.
This is useful when you want to skip in a and_for_each loop.
nullopt | A nullopt_t |
|
nodiscardconstexpr |
Extract and verify the value from the packet.
If the user as provided an existing value, it will be used instead of creating a new one.
|
constexpr |
Invalidate the packet and set the error.
err | The error |
|
constexpr |
Create a new chain with a different value type.
The packet and the error will be copied/moved to the new chain.
TNewValue | The type of the new value |
existingValue | An optional existing value |
|
constexpr |
Create a new chain with a different value type.
This const version is generally used in a and_for_each loop. The error isn't forwarded to the new chain.
TNewValue | The type of the new value |
existingValue | An optional existing value |
|
constexpr |
Chain up some code after a unsuccessful extraction.
This must be the last method called in the chain as this return an optional error.
TInvokable | The type of the invokable argument |
f | The invokable argument |
|
nodiscardconstexpr |
Peek without changing the read position a copy of value.
TPeek | The type of the value that will be peeked |
|
constexpr |