11namespace Arp {
namespace Base {
namespace Core
24 using U =
typename std::underlying_type<T>::type;
30 static constexpr T
Zero =
static_cast<T
>(0);
36 static bool TryParse(
const char* input, T& result);
41 operator T(
void)
const;
72 return os << arg.value;
123 return lhs.value == rhs.value;
132 return lhs.value < rhs.value;
141 return lhs.value > rhs.value;
150 return lhs.value <= rhs.value;
159 return lhs.value >= rhs.value;
171 return lhs.value == rhs;
180 return lhs.value < rhs;
189 return lhs.value > rhs;
198 return lhs.value <= rhs;
207 return lhs.value >= rhs;
219 return lhs == rhs.value;
228 return lhs < rhs.value;
237 return lhs > rhs.value;
246 return lhs <= rhs.value;
255 return lhs >= rhs.value;
273template<
class T>
struct fmt::formatter<
Arp::Base::Core::Enum<T>> :
public fmt::ostream_formatter {};
275#include "Arp/Base/Core/Detail/Enum.ipp"
Adapter class for enums to make them loggable and parsable from e.g. XML files.
Definition: Enum.hxx:21
friend std::ostream & operator<<(std::ostream &os, Enum arg)
Makes the Enum class loggable and streamable.
Definition: Enum.hxx:70
friend bool operator>=(Enum lhs, Enum rhs)
Greater or equal operator for class Enum.
Definition: Enum.hxx:157
friend Enum operator&(Enum lhs, Enum rhs)
Bitwise And operator for class Enum.
Definition: Enum.hxx:108
friend bool operator<(Enum lhs, Enum rhs)
Less operator for class Enum.
Definition: Enum.hxx:130
friend bool operator>(Enum lhs, Enum rhs)
Greater operator for class Enum.
Definition: Enum.hxx:139
friend bool operator>(T lhs, Enum rhs)
Greater operator for class Enum.
Definition: Enum.hxx:235
friend bool operator==(Enum lhs, T rhs)
Equality operator of class Enum.
Definition: Enum.hxx:169
friend bool operator<(Enum lhs, T rhs)
Less operator for class Enum.
Definition: Enum.hxx:178
friend bool operator<=(T lhs, Enum rhs)
Less or equal operator for class Enum.
Definition: Enum.hxx:244
friend bool operator==(Enum lhs, Enum rhs)
Equality operator of class Enum.
Definition: Enum.hxx:121
friend bool operator<(T lhs, Enum rhs)
Less operator for class Enum.
Definition: Enum.hxx:226
friend bool operator<=(Enum lhs, Enum rhs)
Less or equal operator for class Enum.
Definition: Enum.hxx:148
friend bool operator>(Enum lhs, T rhs)
Greater operator for class Enum.
Definition: Enum.hxx:187
friend bool operator>=(Enum lhs, T rhs)
Greater or equal operator for class Enum.
Definition: Enum.hxx:205
static constexpr T Zero
Zero initialized Enum value.
Definition: Enum.hxx:30
T Value
The adapted enum class type.
Definition: Enum.hxx:23
friend bool operator==(T lhs, Enum rhs)
Equality operator of class Enum.
Definition: Enum.hxx:217
typename std::underlying_type< T >::type U
The underlying integral type of the adapted enum class type.
Definition: Enum.hxx:24
friend bool operator>=(T lhs, Enum rhs)
Greater or equal operator for class Enum.
Definition: Enum.hxx:253
friend std::istream & operator>>(std::istream &is, Enum &arg)
Makes the Enum class parsable.
Definition: Enum.hxx:79
friend bool operator<=(Enum lhs, T rhs)
Less or equal operator for class Enum.
Definition: Enum.hxx:196
friend Enum operator|(Enum lhs, Enum rhs)
Bitwise Or operator for class Enum.
Definition: Enum.hxx:97
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39
Enum< T > make_enum(T value)
Global make function to adapt any enum class by class Enum.
Definition: Enum.ipp:222
Enum & operator=(Value arg)
The assignment operator for a value of the adapted type.
Definition: Enum.ipp:126
T GetValue(void) const
Gets the adapted enum value.
Definition: Enum.ipp:155
bool HasAnyFlag(Value flags)
Determines if this enum value has any of the the supplied flags set.
Definition: Enum.ipp:173
Enum & operator&=(Enum rhs)
The assignment AND operator.
Definition: Enum.ipp:136
Enum & operator|=(Enum rhs)
The assignment OR operator.
Definition: Enum.ipp:146
static bool TryParse(const String &input, Enum &result)
Tries to parse the given input string.
Definition: Enum.ipp:45
String ToString(bool throwIfInvalid=true) const
Converts this instance to its string representation.
Definition: Enum.ipp:199
U ToUnderlyingType(void) const
Converts this instance to the underlying integral type of its adapted enum type
Definition: Enum.ipp:190
Enum(Value initialValue=Zero)
Constructs an instance of Enum with the given value.
Definition: Enum.ipp:25
static Enum Parse(const String &input)
Parses the given input string.
Definition: Enum.ipp:90
bool HasAllFlags(Value flags)
Determines if this enum value has all of the supplied flag set.
Definition: Enum.ipp:182
bool HasFlag(Value flag)
Determines if this enum value has the supplied flag set.
Definition: Enum.ipp:164
Root namespace for the PLCnext API