14#include <egt/detail/enum.h>
15#include <egt/detail/meta.h>
16#include <egt/detail/string.h>
17#include <egt/flagsbase.h>
18#include <egt/signal.h>
44 constexpr Flags() noexcept = default;
57 explicit
Flags(const std::
string& str)
73 constexpr Flags(T flag) noexcept
91 const auto res = (*
this != rhs);
116 bool set(std::initializer_list<T> flags)
noexcept
162 std::ostringstream ss;
166 const auto container = this->
get();
167 for (
const auto& item : container)
187 std::vector<std::string> tokens;
189 for (
auto& flag : tokens)
196static_assert(detail::rule_of_5<Flags<RuleE>>(),
"must fulfill rule of 5");
202 return lhs.
raw() == rhs.
raw();
209 return !(lhs == rhs);
216 return os << flags.tostring();
Utility class for managing a set of flags.
Definition flagsbase.h:34
EGT_NODISCARD std::set< T > get() const
Get a std::set of all set flags.
Definition flagsbase.h:153
EGT_NODISCARD constexpr bool empty() const noexcept
Returns true if there are no flags set.
Definition flagsbase.h:136
EGT_NODISCARD constexpr const Underlying & raw() const
Get the raw underlying value.
Definition flagsbase.h:167
Underlying m_flags
The flags.
Definition flagsbase.h:188
constexpr bool set(const T flag) noexcept
Set the specified flag.
Definition flagsbase.h:87
constexpr FlagsBase() noexcept=default
typename std::underlying_type< T >::type Underlying
This is the underlying type of the flags, which is used internally for efficient bitwise operation on...
Definition flagsbase.h:41
constexpr bool clear() noexcept
Unset all flags.
Definition flagsbase.h:145
Utility class for managing a set of flags with the ability to observe changes to the flags.
Definition flags.h:40
constexpr Flags(T flag) noexcept
Set a single flag.
Definition flags.h:73
Flags(Flags &&) noexcept=default
bool set(std::initializer_list< T > flags) noexcept
Set multiple flags.
Definition flags.h:116
void from_string(const std::string &str)
Convert from string.
Definition flags.h:184
constexpr Flags() noexcept=default
static constexpr const char FLAGS_DELIMITER
Delimiter used to separate flags in string representation.
Definition flags.h:155
bool clear(T flag) noexcept
Clear a single flag.
Definition flags.h:125
constexpr Flags(const Flags &rhs) noexcept
Copy constructor.
Definition flags.h:79
EGT_NODISCARD std::string to_string() const
Convert the flags to strings.
Definition flags.h:160
Signal on_change
Event signal.
Definition flags.h:51
constexpr Flags< T > operator|(const T &flag) const noexcept
Or operator.
Definition flags.h:143
constexpr Flags< T > operator&(const T &flag) const noexcept
And operator.
Definition flags.h:149
Flags & operator=(const Flags &rhs)
Assignment operator.
Definition flags.h:87
bool set(T flag) noexcept
Set a single flag.
Definition flags.h:107
Flags(const char *str)
Definition flags.h:65
bool clear() noexcept
Clear all flags.
Definition flags.h:134
Signal class used for defining a signal and dispatching events.
Definition signal.h:30
void invoke(Args... args)
Invoke all handlers with the specified args.
Definition signal.h:85
EGT_API std::string trim(const std::string &source, const std::string &t=" \t\n\r")
Trim delimiters off both sides of a std::string.
EGT_API void tokenize(const std::string &str, char delimiter, std::vector< std::string > &tokens)
Tokenize a std::string.
constexpr const char * enum_to_string(T const &e)
Convert an enum to a string.
Definition enum.h:55
constexpr bool operator!=(const Color &lhs, const Color &rhs)
Color operator.
Definition color.h:509
EGT_API std::ostream & operator<<(std::ostream &os, const Color &color)
Overloaded std::ostream insertion operator.
constexpr bool operator==(const Color &lhs, const Color &rhs)
Color operator.
Definition color.h:500
EGT framework namespace.
Definition animation.h:24