Device interface library for multiple platforms including Mbed.
Dependents: DeepCover Embedded Security in IoT MaximInterface MAXREFDES155#
Maxim Interface is a library framework focused on providing flexible and expressive hardware interfaces. Both communication interfaces such as I2C and 1-Wire and device interfaces such as DS18B20 are supported. Modern C++ concepts are used extensively while keeping compatibility with C++98/C++03 and requiring no external dependencies. The embedded-friendly design does not depend on exceptions or RTTI.
The full version of the project is hosted on GitLab: https://gitlab.com/iabenz/MaximInterface
Diff: Utilities/FlagSet.hpp
- Revision:
- 6:471901a04573
- Parent:
- 5:a8c83a2e6fa4
--- a/Utilities/FlagSet.hpp Wed Jan 23 13:11:04 2019 -0600 +++ b/Utilities/FlagSet.hpp Mon Mar 04 08:10:00 2019 -0600 @@ -38,6 +38,7 @@ namespace MaximInterface { +/// @brief /// Provides functionality similar to std::bitset except using a bit flag, /// typically of an enum type, as the indexer. template <typename Flag, size_t flagBits> class FlagSet { @@ -87,6 +88,7 @@ /// @name Element access /// @{ + bool operator[](Flag flag) const { return test(flag); } reference operator[](Flag flag) { return reference(*this, flag); } @@ -98,15 +100,19 @@ bool none() const { return bits.none(); } size_t count() const { return bits.count(); } + /// @} /// @name Capacity /// @{ + size_t size() const { return bits.size(); } + /// @} /// @name Modifiers /// @{ + FlagSet & operator&=(const FlagSet & other) { bits &= other.bits; return *this; @@ -154,16 +160,19 @@ bits ^= flag; return *this; } + /// @} /// @name Conversions /// @{ + template <typename CharT, typename Traits, typename Allocator> std::basic_string<CharT, Traits, Allocator> to_string() const { return bits.template to_string<CharT, Traits, Allocator>(); } unsigned long to_ulong() const { return bits.to_ulong(); } + /// @} private: