/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #pragma once #include #include #include #include namespace openVulkanoCpp { class Utils { public: static void SetThreadName(const std::string& name); static inline std::vector toCString(const std::vector& values) { std::vector result; result.reserve(values.size()); for (const auto& string : values) { result.push_back(string.c_str()); } return result; } static inline std::vector toCString(const std::set& values) { std::vector result; result.reserve(values.size()); for (const auto& string : values) { result.push_back(string.c_str()); } return result; } template static inline bool Contains(std::vector& vec, const T& element) { return (std::find(vec.begin(), vec.end(), element) != vec.end()); } template static inline void Remove(std::vector& vec, const T& element) { vec.erase(std::remove(vec.begin(), vec.end(), element), vec.end()); } template static inline auto EnumAsInt(Enumeration const value) -> typename std::underlying_type::type { return static_cast::type>(value); } static inline constexpr size_t Align(size_t size, size_t alignment) { return (size + alignment - 1) & ~(alignment - 1); } }; }