2023-10-17 06:52:54 +00:00
|
|
|
template <typename T, size_t N>
|
|
|
|
class ArrayWrapper1D : public std::array<T, N>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VULKAN_HPP_CONSTEXPR ArrayWrapper1D() VULKAN_HPP_NOEXCEPT : std::array<T, N>() {}
|
|
|
|
|
|
|
|
VULKAN_HPP_CONSTEXPR ArrayWrapper1D( std::array<T, N> const & data ) VULKAN_HPP_NOEXCEPT : std::array<T, N>( data ) {}
|
|
|
|
|
|
|
|
template <typename B = T, typename std::enable_if<std::is_same<B, char>::value, int>::type = 0>
|
|
|
|
VULKAN_HPP_CONSTEXPR_14 ArrayWrapper1D( std::string const & data ) VULKAN_HPP_NOEXCEPT
|
2022-07-28 15:09:08 +00:00
|
|
|
{
|
2023-10-17 06:52:54 +00:00
|
|
|
copy( data.data(), data.length() );
|
|
|
|
}
|
2022-07-28 15:09:08 +00:00
|
|
|
|
2023-10-17 06:52:54 +00:00
|
|
|
#if 17 <= VULKAN_HPP_CPP_VERSION
|
|
|
|
template <typename B = T, typename std::enable_if<std::is_same<B, char>::value, int>::type = 0>
|
|
|
|
VULKAN_HPP_CONSTEXPR_14 ArrayWrapper1D( std::string_view data ) VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
copy( data.data(), data.length() );
|
|
|
|
}
|
|
|
|
#endif
|
2022-07-28 15:09:08 +00:00
|
|
|
|
|
|
|
#if ( VK_USE_64_BIT_PTR_DEFINES == 0 )
|
2023-10-17 06:52:54 +00:00
|
|
|
// on 32 bit compiles, needs overloads on index type int to resolve ambiguities
|
|
|
|
VULKAN_HPP_CONSTEXPR T const & operator[]( int index ) const VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return std::array<T, N>::operator[]( index );
|
|
|
|
}
|
2022-07-28 15:09:08 +00:00
|
|
|
|
2023-10-17 06:52:54 +00:00
|
|
|
T & operator[]( int index ) VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return std::array<T, N>::operator[]( index );
|
|
|
|
}
|
2022-07-28 15:09:08 +00:00
|
|
|
#endif
|
|
|
|
|
2023-10-17 06:52:54 +00:00
|
|
|
operator T const *() const VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return this->data();
|
|
|
|
}
|
2022-07-28 15:09:08 +00:00
|
|
|
|
2023-10-17 06:52:54 +00:00
|
|
|
operator T *() VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return this->data();
|
|
|
|
}
|
2022-07-28 15:09:08 +00:00
|
|
|
|
2023-10-17 06:52:54 +00:00
|
|
|
template <typename B = T, typename std::enable_if<std::is_same<B, char>::value, int>::type = 0>
|
|
|
|
operator std::string() const
|
|
|
|
{
|
2023-11-14 15:49:01 +00:00
|
|
|
return std::string( this->data(), strnlen( this->data(), N ) );
|
2023-10-17 06:52:54 +00:00
|
|
|
}
|
2022-07-28 15:09:08 +00:00
|
|
|
|
|
|
|
#if 17 <= VULKAN_HPP_CPP_VERSION
|
2023-10-17 06:52:54 +00:00
|
|
|
template <typename B = T, typename std::enable_if<std::is_same<B, char>::value, int>::type = 0>
|
|
|
|
operator std::string_view() const
|
|
|
|
{
|
2023-11-14 15:49:01 +00:00
|
|
|
return std::string_view( this->data(), strnlen( this->data(), N ) );
|
2023-10-17 06:52:54 +00:00
|
|
|
}
|
2022-07-28 15:09:08 +00:00
|
|
|
#endif
|
|
|
|
|
2023-10-17 06:52:54 +00:00
|
|
|
private:
|
2023-10-17 10:41:14 +00:00
|
|
|
VULKAN_HPP_CONSTEXPR_14 void copy( char const * data, size_t len ) VULKAN_HPP_NOEXCEPT
|
2022-07-28 15:09:08 +00:00
|
|
|
{
|
2024-06-06 06:35:49 +00:00
|
|
|
size_t n = std::min( N - 1, len );
|
2023-10-17 06:52:54 +00:00
|
|
|
for ( size_t i = 0; i < n; ++i )
|
|
|
|
{
|
|
|
|
( *this )[i] = data[i];
|
|
|
|
}
|
2024-06-06 06:35:49 +00:00
|
|
|
( *this )[n] = 0;
|
2022-07-28 15:09:08 +00:00
|
|
|
}
|
2023-10-17 06:52:54 +00:00
|
|
|
};
|
|
|
|
|
2024-06-06 06:35:49 +00:00
|
|
|
// relational operators between ArrayWrapper1D of chars with potentially different sizes
|
|
|
|
#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR )
|
|
|
|
template <size_t N, size_t M>
|
|
|
|
std::strong_ordering operator<=>( ArrayWrapper1D<char, N> const & lhs, ArrayWrapper1D<char, M> const & rhs ) VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
int result = strcmp( lhs.data(), rhs.data() );
|
|
|
|
return ( result < 0 ) ? std::strong_ordering::less : ( ( result > 0 ) ? std::strong_ordering::greater : std::strong_ordering::equal );
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
template <size_t N, size_t M>
|
|
|
|
bool operator<( ArrayWrapper1D<char, N> const & lhs, ArrayWrapper1D<char, M> const & rhs ) VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return strcmp( lhs.data(), rhs.data() ) < 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <size_t N, size_t M>
|
|
|
|
bool operator<=( ArrayWrapper1D<char, N> const & lhs, ArrayWrapper1D<char, M> const & rhs ) VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return strcmp( lhs.data(), rhs.data() ) <= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <size_t N, size_t M>
|
|
|
|
bool operator>( ArrayWrapper1D<char, N> const & lhs, ArrayWrapper1D<char, M> const & rhs ) VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return strcmp( lhs.data(), rhs.data() ) > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <size_t N, size_t M>
|
|
|
|
bool operator>=( ArrayWrapper1D<char, N> const & lhs, ArrayWrapper1D<char, M> const & rhs ) VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return strcmp( lhs.data(), rhs.data() ) >= 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
template <size_t N, size_t M>
|
|
|
|
bool operator==( ArrayWrapper1D<char, N> const & lhs, ArrayWrapper1D<char, M> const & rhs ) VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return strcmp( lhs.data(), rhs.data() ) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <size_t N, size_t M>
|
|
|
|
bool operator!=( ArrayWrapper1D<char, N> const & lhs, ArrayWrapper1D<char, M> const & rhs ) VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return strcmp( lhs.data(), rhs.data() ) != 0;
|
|
|
|
}
|
|
|
|
|
2023-10-17 06:52:54 +00:00
|
|
|
// specialization of relational operators between std::string and arrays of chars
|
2024-06-06 06:35:49 +00:00
|
|
|
#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR )
|
|
|
|
template <size_t N>
|
|
|
|
std::strong_ordering operator<=>( std::string const & lhs, ArrayWrapper1D<char, N> const & rhs ) VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return lhs <=> rhs.data();
|
|
|
|
}
|
|
|
|
#else
|
2023-10-17 06:52:54 +00:00
|
|
|
template <size_t N>
|
|
|
|
bool operator<( std::string const & lhs, ArrayWrapper1D<char, N> const & rhs ) VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return lhs < rhs.data();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <size_t N>
|
|
|
|
bool operator<=( std::string const & lhs, ArrayWrapper1D<char, N> const & rhs ) VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return lhs <= rhs.data();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <size_t N>
|
|
|
|
bool operator>( std::string const & lhs, ArrayWrapper1D<char, N> const & rhs ) VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return lhs > rhs.data();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <size_t N>
|
|
|
|
bool operator>=( std::string const & lhs, ArrayWrapper1D<char, N> const & rhs ) VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return lhs >= rhs.data();
|
|
|
|
}
|
2024-06-06 06:35:49 +00:00
|
|
|
#endif
|
2023-10-17 06:52:54 +00:00
|
|
|
|
|
|
|
template <size_t N>
|
|
|
|
bool operator==( std::string const & lhs, ArrayWrapper1D<char, N> const & rhs ) VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return lhs == rhs.data();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <size_t N>
|
|
|
|
bool operator!=( std::string const & lhs, ArrayWrapper1D<char, N> const & rhs ) VULKAN_HPP_NOEXCEPT
|
|
|
|
{
|
|
|
|
return lhs != rhs.data();
|
|
|
|
}
|