Skip to content

Commit

Permalink
Fix edge case, prepare types with more than one column
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed Dec 3, 2024
1 parent 571e5ab commit c2458df
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions include/tao/pq/result_traits_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef TAO_PQ_RESULT_TRAITS_ARRAY_HPP
#define TAO_PQ_RESULT_TRAITS_ARRAY_HPP

#include <cassert>
#include <cstring>
#include <list>
#include <set>
Expand Down Expand Up @@ -59,7 +60,13 @@ namespace tao::pq
template< typename T >
[[nodiscard]] auto parse_element( const char*& value ) -> T
{
if( *value == '"' ) {
if constexpr( result_traits_size< T > >= 2 ) {
if( *value++ != '{' ) {
throw std::invalid_argument( "expected '{'" );
}
throw std::runtime_error( "NOT YET IMPLEMENTED" );
}
else if( *value == '"' ) {
++value;
std::string input;
while( const auto* pos = std::strpbrk( value, "\\\"" ) ) {
Expand All @@ -68,11 +75,14 @@ namespace tao::pq
input += *pos++;
value = pos;
}
else {
else if( *pos == '"' ) {
input.append( value, pos++ );
value = pos;
break;
}
else {
throw std::invalid_argument( "unterminated quoted string" );
}
}
return result_traits< T >::from( input.c_str() );
}
Expand Down

0 comments on commit c2458df

Please sign in to comment.