mal-packet-weaver
C++20 packet serialization/deserialization library.
Loading...
Searching...
No Matches
common-structures.hpp
Go to the documentation of this file.
1
#pragma once
2
#include "
library-pch.hpp
"
7
namespace
mal_toolkit
8
{
10
class
non_copyable
11
{
12
public
:
13
non_copyable
() =
default
;
14
non_copyable
(
const
non_copyable
&) =
delete
;
15
non_copyable
&
operator=
(
const
non_copyable
&) =
delete
;
16
};
18
class
non_movable
19
{
20
public
:
21
non_movable
() =
default
;
22
non_movable
(
non_movable
&&) =
delete
;
23
non_movable
&
operator=
(
non_movable
&&) =
delete
;
24
};
26
class
non_copyable_non_movable
:
public
non_copyable
,
public
non_movable
27
{
28
public
:
29
non_copyable_non_movable
() =
default
;
30
};
35
class
namable
36
{
37
public
:
38
namable
() =
default
;
39
constexpr
explicit
namable
(std::string
const
&
name
) :
name_
(
name
) {}
40
constexpr
explicit
namable
(std::string &&
name
) :
name_
(
std
::move(
name
)) {}
41
~namable
() =
default
;
42
43
constexpr
void
set_name
(std::string
const
&
name
) {
name_
=
name
; }
44
constexpr
void
set_name
(std::string &&
name
) {
name_
= std::move(
name
); }
45
constexpr
void
clear_name
() {
name_
.clear(); }
46
constexpr
bool
has_name
()
const
{
return
!
name_
.empty(); }
47
[[nodiscard]]
constexpr
std::string_view
name
()
const
{
return
name_
; }
48
49
private
:
50
std::string
name_
;
51
};
57
class
namable_protected
:
public
namable
58
{
59
public
:
60
namable_protected
() =
default
;
61
constexpr
explicit
namable_protected
(std::string
const
&
name
) :
namable
(
name
) {}
62
constexpr
explicit
namable_protected
(std::string &&
name
) :
namable
(
std
::move(
name
)) {}
63
~namable_protected
() =
default
;
64
65
protected
:
66
using
namable::clear_name
;
67
using
namable::set_name
;
68
};
74
class
namable_once
:
private
namable
75
{
76
public
:
77
constexpr
explicit
namable_once
(std::string
const
&
name
) :
namable
(
name
) {}
78
constexpr
explicit
namable_once
(std::string &&
name
) :
namable
(
std
::move(
name
)) {}
79
~namable_once
() =
default
;
80
using
namable::has_name
;
81
using
namable::name
;
82
};
87
class
enableable
88
{
89
public
:
90
enableable
() =
default
;
91
~enableable
() =
default
;
92
93
constexpr
void
enable
() {
enabled_
=
true
; }
94
constexpr
void
disable
() {
enabled_
=
false
; }
95
constexpr
bool
is_enabled
()
const
{
return
enabled_
; }
96
constexpr
bool
is_disabled
()
const
{
return
!
enabled_
; }
97
98
constexpr
bool
enabled
()
const
{
return
enabled_
; }
99
100
private
:
101
bool
enabled_
=
true
;
102
};
103
}
// namespace mal_toolkit
mal_toolkit::enableable
A class that can be enabled or disabled.
Definition
common-structures.hpp:88
mal_toolkit::enableable::enableable
enableable()=default
mal_toolkit::enableable::~enableable
~enableable()=default
mal_toolkit::enableable::enabled_
bool enabled_
Definition
common-structures.hpp:101
mal_toolkit::enableable::enabled
constexpr bool enabled() const
Definition
common-structures.hpp:98
mal_toolkit::enableable::is_disabled
constexpr bool is_disabled() const
Definition
common-structures.hpp:96
mal_toolkit::enableable::disable
constexpr void disable()
Definition
common-structures.hpp:94
mal_toolkit::enableable::is_enabled
constexpr bool is_enabled() const
Definition
common-structures.hpp:95
mal_toolkit::enableable::enable
constexpr void enable()
Definition
common-structures.hpp:93
mal_toolkit::namable_once
A class that contains a name and can be named only once at construction.
Definition
common-structures.hpp:75
mal_toolkit::namable_once::name
constexpr std::string_view name() const
Definition
common-structures.hpp:47
mal_toolkit::namable_once::~namable_once
~namable_once()=default
mal_toolkit::namable_once::namable_once
constexpr namable_once(std::string const &name)
Definition
common-structures.hpp:77
mal_toolkit::namable_once::namable_once
constexpr namable_once(std::string &&name)
Definition
common-structures.hpp:78
mal_toolkit::namable_protected
A class that contains a name and can be named and unnamed, but you cant set the name from outside.
Definition
common-structures.hpp:58
mal_toolkit::namable_protected::namable_protected
constexpr namable_protected(std::string const &name)
Definition
common-structures.hpp:61
mal_toolkit::namable_protected::namable_protected
namable_protected()=default
mal_toolkit::namable_protected::namable_protected
constexpr namable_protected(std::string &&name)
Definition
common-structures.hpp:62
mal_toolkit::namable_protected::~namable_protected
~namable_protected()=default
mal_toolkit::namable
A class that contains a name and can be named and unnamed.
Definition
common-structures.hpp:36
mal_toolkit::namable::namable
namable()=default
mal_toolkit::namable::~namable
~namable()=default
mal_toolkit::namable::namable
constexpr namable(std::string &&name)
Definition
common-structures.hpp:40
mal_toolkit::namable::name_
std::string name_
Definition
common-structures.hpp:50
mal_toolkit::namable::name
constexpr std::string_view name() const
Definition
common-structures.hpp:47
mal_toolkit::namable::namable
constexpr namable(std::string const &name)
Definition
common-structures.hpp:39
mal_toolkit::namable::clear_name
constexpr void clear_name()
Definition
common-structures.hpp:45
mal_toolkit::namable::has_name
constexpr bool has_name() const
Definition
common-structures.hpp:46
mal_toolkit::namable::set_name
constexpr void set_name(std::string const &name)
Definition
common-structures.hpp:43
mal_toolkit::namable::set_name
constexpr void set_name(std::string &&name)
Definition
common-structures.hpp:44
mal_toolkit::non_copyable_non_movable
A class that can't be copied neither moved.
Definition
common-structures.hpp:27
mal_toolkit::non_copyable_non_movable::non_copyable_non_movable
non_copyable_non_movable()=default
mal_toolkit::non_copyable
A class that can't be copied.
Definition
common-structures.hpp:11
mal_toolkit::non_copyable::non_copyable
non_copyable(const non_copyable &)=delete
mal_toolkit::non_copyable::non_copyable
non_copyable()=default
mal_toolkit::non_copyable::operator=
non_copyable & operator=(const non_copyable &)=delete
mal_toolkit::non_movable
A class that can't be moved.
Definition
common-structures.hpp:19
mal_toolkit::non_movable::non_movable
non_movable()=default
mal_toolkit::non_movable::operator=
non_movable & operator=(non_movable &&)=delete
mal_toolkit::non_movable::non_movable
non_movable(non_movable &&)=delete
library-pch.hpp
Precompiled header (PCH) file for common headers used across the library.
mal_toolkit
Contains a collection of tools and utilities provided by the MAL Toolkit library.
Definition
backoffs.hpp:7
std
STL namespace.
third_party
mal-toolkit
mal-toolkit
mal-toolkit
common-structures.hpp
Generated on Sun Jul 14 2024 00:02:52 for mal-packet-weaver by
1.11.0