Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed Dec 4, 2024
1 parent 2225972 commit 9ee9e84
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 20 deletions.
8 changes: 6 additions & 2 deletions include/tao/pq/parameter_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ namespace tao::pq
template< typename T >
struct parameter_traits;

template< typename T >
concept parameter_type_has_element = requires( const parameter_traits< std::decay_t< T > >& t, std::string& s ) {
{ t.template element< 0 >( s ) } -> std::same_as< void >;
};

template< typename T >
concept parameter_type_direct = requires( const parameter_traits< std::decay_t< T > >& t, std::string& s ) {
{ parameter_traits< std::decay_t< T > >::columns } -> std::same_as< const std::size_t& >;
Expand All @@ -74,9 +79,8 @@ namespace tao::pq
{ t.template value< 0 >() } -> std::same_as< const char* >;
{ t.template length< 0 >() } -> std::same_as< int >;
{ t.template format< 0 >() } -> std::same_as< int >;
{ t.template element< 0 >( s ) } -> std::same_as< void >;
{ t.template copy_to< 0 >( s ) } -> std::same_as< void >;
};
} && ( ( parameter_traits< std::decay_t< T > >::columns >= 2 ) || parameter_type_has_element< T > );

template<>
struct parameter_traits< null_t >
Expand Down
8 changes: 5 additions & 3 deletions include/tao/pq/parameter_traits_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace tao::pq
namespace internal
{
template< typename T >
requires( !pq::is_array_parameter< T > ) && ( parameter_traits< T >::columns == 1 )
requires( !pq::is_array_parameter< T > )
void to_array( std::string& data, const T& v )
{
parameter_traits< T >( v ).template element< 0 >( data );
Expand All @@ -72,10 +72,12 @@ namespace tao::pq
}
}

template< typename T >
concept array_parameter_type = ( pq::is_array_parameter< T > && ( pq::is_array_parameter< typename T::value_type > || ( parameter_traits< typename T::value_type >::columns == 1 ) ) );

} // namespace internal

template< typename T >
requires is_array_parameter< T >
template< internal::array_parameter_type T >
struct parameter_traits< T >
{
private:
Expand Down
6 changes: 0 additions & 6 deletions include/tao/pq/parameter_traits_pair.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ struct tao::pq::parameter_traits< std::pair< T, U > >
return std::get< gen::template outer< I > >( m_pair ).template format< gen::template inner< I > >();
}

template< std::size_t I >
void element( std::string& data ) const
{
std::get< gen::template outer< I > >( m_pair ).template element< gen::template inner< I > >( data );
}

template< std::size_t I >
void copy_to( std::string& data ) const
{
Expand Down
6 changes: 0 additions & 6 deletions include/tao/pq/parameter_traits_tuple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ struct tao::pq::parameter_traits< std::tuple< Ts... > >
return std::get< gen::template outer< I > >( m_tuple ).template format< gen::template inner< I > >();
}

template< std::size_t I >
void element( std::string& data ) const
{
std::get< gen::template outer< I > >( m_tuple ).template element< gen::template inner< I > >( data );
}

template< std::size_t I >
void copy_to( std::string& data ) const
{
Expand Down
8 changes: 5 additions & 3 deletions include/tao/pq/result_traits_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace tao::pq
[[nodiscard]] auto parse_unquoted( const char*& value ) -> std::string;

template< typename T >
requires( !pq::is_array_result< T > ) && ( result_traits_size< T > == 1 )
requires( !pq::is_array_result< T > )
[[nodiscard]] auto parse( const char*& value ) -> T
{
if( *value == '"' ) {
Expand Down Expand Up @@ -104,10 +104,12 @@ namespace tao::pq
}
}

template< typename T >
concept array_result_type = ( pq::is_array_result< T > && ( pq::is_array_result< typename T::value_type > || ( result_traits_size< typename T::value_type > == 1 ) ) );

} // namespace internal

template< typename T >
requires is_array_result< T >
template< internal::array_result_type T >
struct result_traits< T >
{
static auto from( const char* value ) -> T
Expand Down

0 comments on commit 9ee9e84

Please sign in to comment.