17#ifndef _FGE_NETWORK_MANAGER_HPP_INCLUDED
18#define _FGE_NETWORK_MANAGER_HPP_INCLUDED
20#include "FastEngine/fge_extern.hpp"
21#include "FastEngine/C_scene.hpp"
22#include "FastEngine/network/C_packet.hpp"
76 constexpr ChainedArguments(
Packet const& pck, TValue* existingValue =
nullptr);
77 constexpr ChainedArguments(
Packet const& pck,
Error&& err, TValue* existingValue =
nullptr);
78 constexpr ChainedArguments(ChainedArguments
const& r) =
default;
79 constexpr ChainedArguments(ChainedArguments&& r)
noexcept =
default;
81 constexpr ChainedArguments& operator=(ChainedArguments
const& r) =
default;
82 constexpr ChainedArguments& operator=(ChainedArguments&& r)
noexcept =
default;
91 [[nodiscard]]
constexpr TValue*
extract();
99 [[nodiscard]]
constexpr std::optional<TPeek>
peek();
101 [[nodiscard]]
constexpr operator Packet const&()
const;
102 [[nodiscard]]
constexpr Packet const& packet()
const;
103 [[nodiscard]]
constexpr TValue
const& value()
const;
104 [[nodiscard]]
constexpr TValue& value();
115 template<
class TInvokable>
116 [[nodiscard]]
constexpr typename std::invoke_result_t<TInvokable, ChainedArguments<TValue>&>
131 template<
class TInvokable,
class TIndex>
132 [[nodiscard]]
constexpr ChainedArguments<TValue>&
133 and_for_each(TIndex iStart, TIndex iEnd, TIndex iIncrement, TInvokable&& f);
148 template<
class TInvokable,
class TIndex>
149 [[nodiscard]]
constexpr ChainedArguments<TValue>&
and_for_each(TIndex iStart, TIndex iIncrement, TInvokable&& f);
161 template<
class TInvokable>
162 [[nodiscard]]
constexpr ChainedArguments<TValue>&
and_for_each(TInvokable&& f);
173 template<
class TInvokable>
174 constexpr std::optional<Error>
on_error(TInvokable&& f);
180 [[nodiscard]]
constexpr std::optional<Error>
end();
188 [[nodiscard]]
constexpr std::optional<Error>
final();
196 [[nodiscard]]
constexpr std::optional<Error>
skip()
const;
204 [[nodiscard]]
constexpr std::optional<Error>
stop(
char const* error,
char const* function)
const;
216 constexpr ChainedArguments<TValue>&
apply(TValue& value);
217 template<
class TInvokable>
225 constexpr ChainedArguments<TValue>&
apply(TInvokable&& f);
241 constexpr ChainedArguments<TValue>&
invalidate(
char const* error,
char const* function);
244 using Value = std::variant<TValue, TValue*>;
256enum class ROutputs :
bool
274template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
275constexpr ChainedArguments<TValue>
RRange(TValue
const& min, TValue
const& max, ChainedArguments<TValue>&& args);
276template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
277constexpr ChainedArguments<TValue>
278RRange(TValue
const& min, TValue
const& max,
Packet const& pck, TValue* existingValue =
nullptr)
290template<
class TValue>
291constexpr ChainedArguments<TValue>
RValid(ChainedArguments<TValue>&& args);
292template<
class TValue>
293constexpr ChainedArguments<TValue>
RValid(Packet
const& pck, TValue* existingValue =
nullptr)
295 return RValid<TValue>(ChainedArguments<TValue>{pck, existingValue});
307template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
309template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
324template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
326template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
341template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
343template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
365template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
367template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
369RSizeRange(SizeType min, SizeType max, Packet
const& pck, TValue* existingValue =
nullptr)
373template<
class TString>
375RStringRange(SizeType min, SizeType max, Packet
const& pck, TString* existingValue =
nullptr)
391template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
393template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
398template<
class TString>
415template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
417template<
class TValue, ROutputs TOutput = ROutputs::R_NORMAL>
430#include "network_manager.inl"
A scene contain a collection of object and handle them.
Definition C_scene.hpp:465
Definition C_packet.hpp:52
This is a wrapper around a Packet and a value for safe extraction.
Definition network_manager.hpp:74
constexpr ChainedArguments< TValue > & setError(Error &&err)
Set the error.
Definition network_manager.inl:241
constexpr std::optional< TPeek > peek()
Peek without changing the read position a copy of value.
Definition network_manager.inl:53
constexpr std::optional< Error > skip() const
Helper to "continue" in a and_for_each() loop without returning an error.
Definition network_manager.inl:199
constexpr ChainedArguments< TValue > & apply(TValue &value)
Apply the extracted value to the provided reference.
Definition network_manager.inl:210
constexpr TValue * extract()
Extract and verify the value from the packet.
Definition network_manager.inl:38
constexpr std::invoke_result_t< TInvokable, ChainedArguments< TValue > & > and_then(TInvokable &&f)
Chain up some code after a successful extraction.
Definition network_manager.inl:96
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.
Definition network_manager.inl:107
constexpr std::optional< Error > stop(char const *error, char const *function) const
Helper to "break" in a and_for_each() loop with a custom error.
Definition network_manager.inl:204
constexpr std::optional< Error > on_error(TInvokable &&f)
Chain up some code after an unsuccessful extraction.
Definition network_manager.inl:178
constexpr std::optional< Error > end()
End the chain by doing a last validity check on the packet.
Definition network_manager.inl:188
constexpr ChainedArguments< TValue > & invalidate(Error &&err)
Invalidate the packet and set the error.
Definition network_manager.inl:247
constexpr ChainedArguments< TValue > RRange(TValue const &min, TValue const &max, ChainedArguments< TValue > &&args)
Range rule, check if the value is in the min/max range.
Definition network_manager.inl:262
constexpr ChainedArguments< TValue > RMustValidUtf8(ChainedArguments< TValue > &&args)
Check if the extracted string is a valid UTF8 string.
Definition network_manager.inl:378
constexpr ChainedArguments< TValue > RStrictLess(TValue less, ChainedArguments< TValue > &&args)
Strict less rule, check if the value is strictly lesser than the provided one.
Definition network_manager.inl:310
constexpr ChainedArguments< TValue > RMustEqual(TValue const &a, ChainedArguments< TValue > &&args)
Must equal rule, check if the value is equal to the provided one.
Definition network_manager.inl:293
constexpr ChainedArguments< TValue > RSizeMustEqual(SizeType a, ChainedArguments< TValue > &&args)
Size must equal rule, check if the size is equal to the provided one.
Definition network_manager.inl:361
constexpr ChainedArguments< TValue > RSizeRange(SizeType min, SizeType max, ChainedArguments< TValue > &&args)
Size range rule, check if the size is in the min/max range.
Definition network_manager.inl:344
constexpr ChainedArguments< TValue > RValid(ChainedArguments< TValue > &&args)
Valid rule, check if the value is correctly extracted.
Definition network_manager.inl:279
constexpr ChainedArguments< TValue > RLess(TValue less, ChainedArguments< TValue > &&args)
Less rule, check if the value is lesser than the provided one.
Definition network_manager.inl:327
FGE_API bool WritePacketDataToFile(Packet &pck, std::string const &file)
Utility function to write packet data into a file.
FGE_API uint32_t GetSceneChecksum(fge::Scene &scene)
Get a basic scene checksum.
Definition C_error.hpp:28