Skip to content

Commit

Permalink
Fixed compilation in C++17 / gcc.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashaduri committed Feb 11, 2021
1 parent 7edfb9f commit c0acb9a
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions csv_parser/csv_cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,25 +284,21 @@ inline std::optional<double> readDouble(std::string_view cell);



/// Constructor. Cleans up the data in cell, creating a buffer with.
template<std::size_t Size>
constexpr CellStringBuffer<Size>::CellStringBuffer(std::string_view cell, bool has_escaped_quotes)
: buffer_(prepareBuffer(cell, has_escaped_quotes))
{ }



/// Check if the buffer was successfully created and contains a cleaned up string
template<std::size_t Size>
[[nodiscard]] constexpr bool CellStringBuffer<Size>::isValid() const noexcept
{
return buffer_.valid;
}


/// Return string view to stored buffer.
/// The returned view has collapsed consecutive double-quotes inside.
/// \throw std::out_of_range if buffer is invalid (of insufficient size)

template<std::size_t Size>
[[nodiscard]] constexpr std::string_view CellStringBuffer<Size>::getStringView() const
{
Expand All @@ -313,9 +309,7 @@ template<std::size_t Size>
}


/// Return string view to stored buffer.
/// The returned view has collapsed consecutive double-quotes inside.
/// \return std::nullopt if buffer is invalid (of insufficient size)

template<std::size_t Size>
[[nodiscard]] constexpr std::optional<std::string_view> CellStringBuffer<Size>::getOptionalStringView() const noexcept
{
Expand All @@ -327,7 +321,6 @@ template<std::size_t Size>



/// Create a buffer object, with cleaned-up input in it
template<std::size_t Size>
constexpr typename CellStringBuffer<Size>::Buffer CellStringBuffer<Size>::prepareBuffer(std::string_view input, bool
has_escaped_quotes)
Expand All @@ -338,7 +331,7 @@ has_escaped_quotes)
if (has_escaped_quotes) {
return cleanString(input);
}
std::array<char, Size> buffer;
std::array<char, Size> buffer = { };
for (std::size_t pos = 0; pos < std::min(Size, input.size()); ++pos) {
buffer[pos] = input[pos];
}
Expand All @@ -347,7 +340,6 @@ has_escaped_quotes)



/// Unescape a string view to newly created buffer
template<std::size_t Size>
constexpr typename CellStringBuffer<Size>::Buffer CellStringBuffer<Size>::cleanString(std::string_view input)
{
Expand Down

0 comments on commit c0acb9a

Please sign in to comment.