diff --git a/include/csv2/reader.hpp b/include/csv2/reader.hpp index 45ffb80..78b21cd 100644 --- a/include/csv2/reader.hpp +++ b/include/csv2/reader.hpp @@ -5,6 +5,9 @@ #include #include #include +#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) + #include +#endif namespace csv2 { @@ -50,6 +53,13 @@ class Reader { friend class CellIterator; public: + + // returns a view on the cell's contents if C++17 available + #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) + std::string_view read_view() const { + return std::string_view (buffer_ + start_, end_ - start_); + } + #endif // Returns the raw_value of the cell without handling escaped // content, e.g., cell containing """foo""" will be returned // as is @@ -86,6 +96,9 @@ class Reader { friend class Reader; public: + // returns the char length of the row + size_t length() const { return end_ - start_; } + // Returns the raw_value of the row template void read_raw_value(Container &result) const { if (start_ >= end_) @@ -252,4 +265,4 @@ class Reader { return result; } }; -} // namespace csv2 \ No newline at end of file +} // namespace csv2 diff --git a/single_include/csv2/csv2.hpp b/single_include/csv2/csv2.hpp index f9997e0..078415b 100644 --- a/single_include/csv2/csv2.hpp +++ b/single_include/csv2/csv2.hpp @@ -1616,6 +1616,9 @@ template struct first_row_is_header { // #include #include #include +#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) +#include +#endif namespace csv2 { @@ -1661,6 +1664,11 @@ class Reader { friend class CellIterator; public: + // returns a view on the cell's contents if C++17 available + #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) + std::string_view read_view() const { return std::string_view(buffer_ + start_, end_ - start_); } + #endif + // Returns the raw_value of the cell without handling escaped // content, e.g., cell containing """foo""" will be returned // as is @@ -1697,6 +1705,9 @@ class Reader { friend class Reader; public: + // returns the char length of the row + size_t length() const { return end_ - start_; } + // Returns the raw_value of the row template void read_raw_value(Container &result) const { if (start_ >= end_) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3ae9155..398be57 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,9 +2,11 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() +IF (NOT MSVC) set(CMAKE_CXX_FLAGS "-Wall -Wextra") set(CMAKE_CXX_FLAGS_DEBUG "-g") set(CMAKE_CXX_FLAGS_RELEASE "-O3") +ENDIF (NOT MSVC) set_source_files_properties(main.cpp PROPERTIES