src/utilities/core/EnumHelpers.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #ifndef UTILITIES_CORE_ENUMHELPERS_HPP | ||
| 7 | #define UTILITIES_CORE_ENUMHELPERS_HPP | ||
| 8 | |||
| 9 | #include "Containers.hpp" | ||
| 10 | |||
| 11 | namespace openstudio { | ||
| 12 | |||
| 13 | template <class _enum_name> | ||
| 14 | 2 | bool isMember(const _enum_name& e, const StringVector& strValues) { | |
| 15 |
2/2✓ Branch 5 taken 5 times.
✓ Branch 6 taken 1 time.
|
6 | for (const std::string& str : strValues) { |
| 16 | try { | ||
| 17 |
1/1✓ Branch 1 taken 3 times.
|
5 | _enum_name setMember(str); |
| 18 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 2 times.
|
3 | if (e == setMember) { |
| 19 | 1 | return true; | |
| 20 | } | ||
| 21 |
1/1✓ Branch 2 taken 2 times.
|
2 | } catch (...) { |
| 22 | } | ||
| 23 | } | ||
| 24 | 1 | return false; | |
| 25 | } | ||
| 26 | |||
| 27 | } // namespace openstudio | ||
| 28 | |||
| 29 | #endif // UTILITIES_CORE_ENUMHELPERS_HPP | ||
| 30 |