4 Commits

Author SHA1 Message Date
Ado
544ecddf1a Update README 2025-05-28 02:22:12 +02:00
Ado
40f320ace0 Remove icc CI 2025-05-28 02:06:08 +02:00
Ado
4972e651d9 Update CMAKE version requirements 2025-05-28 01:52:21 +02:00
ado
c7cf402283 [skip ci] Update version 2025-05-28 01:52:21 +02:00
10 changed files with 75 additions and 54 deletions

View File

@@ -25,10 +25,10 @@ jobs:
strategy: strategy:
matrix: matrix:
xcode: ['15.2'] xcode: ['13.4.1', '14.1']
type: [Release, Debug] type: [Release, Debug]
runs-on: macos-latest runs-on: macos-12
env: env:
DEVELOPER_DIR: /Applications/Xcode_${{matrix.xcode}}.app/Contents/Developer DEVELOPER_DIR: /Applications/Xcode_${{matrix.xcode}}.app/Contents/Developer
@@ -42,7 +42,7 @@ jobs:
id: cores id: cores
- name: Install dependencies - name: Install dependencies
run: script/ci_install_deps.sh sudo run: script/ci_install_deps.sh
- name: Configure - name: Configure
run: cmake -S test -B build -DCMAKE_BUILD_TYPE=${{matrix.type}} run: cmake -S test -B build -DCMAKE_BUILD_TYPE=${{matrix.type}}

View File

@@ -31,11 +31,14 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
config: config:
- os: windows-2019
vs: "Visual Studio 16 2019"
- os: windows-latest - os: windows-latest
vs: "Visual Studio 17 2022" vs: "Visual Studio 17 2022"
build: [Debug, Release] build: [Debug, Release]
platform: [x64] platform: [Win32, x64]
runs-on: ${{matrix.config.os}} runs-on: ${{matrix.config.os}}

View File

@@ -31,7 +31,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: [windows-2025, windows-latest] os: [windows-2019, windows-latest]
type: [Release, Debug] type: [Release, Debug]
config: config:
- msystem: "MINGW64" - msystem: "MINGW64"
@@ -39,6 +39,11 @@ jobs:
git mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja git mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja
mingw-w64-x86_64-clang mingw-w64-x86_64-clang
- msystem: "MINGW32"
install: >-
git mingw-w64-i686-cmake mingw-w64-i686-ninja
mingw-w64-i686-clang
runs-on: ${{matrix.os}} runs-on: ${{matrix.os}}
name: "${{matrix.config.msystem}}: ${{matrix.os}}: ${{matrix.type}}" name: "${{matrix.config.msystem}}: ${{matrix.os}}: ${{matrix.type}}"

View File

@@ -31,7 +31,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: [windows-2025, windows-latest] os: [windows-2019, windows-latest]
type: [Release, Debug] type: [Release, Debug]
config: config:
- msystem: "MINGW64" - msystem: "MINGW64"
@@ -39,6 +39,11 @@ jobs:
git mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja git mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja
mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc
- msystem: "MINGW32"
install: >-
git mingw-w64-i686-cmake mingw-w64-i686-ninja
mingw-w64-i686-gcc
runs-on: ${{matrix.os}} runs-on: ${{matrix.os}}
name: "${{matrix.config.msystem}}: ${{matrix.os}}: ${{matrix.type}}" name: "${{matrix.config.msystem}}: ${{matrix.os}}: ${{matrix.type}}"

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14) cmake_minimum_required(VERSION 3.15)
project( project(
ssp ssp

View File

@@ -9,14 +9,14 @@
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![coverage](https://coveralls.io/repos/github/red0124/ssp/badge.svg?branch=master)](https://coveralls.io/github/red0124/ssp?branch=master) [![coverage](https://coveralls.io/repos/github/red0124/ssp/badge.svg?branch=master)](https://coveralls.io/github/red0124/ssp?branch=master)
[![fuzz](https://github.com/red0124/ssp/actions/workflows/fuzz.yml/badge.svg?branch=master)](https://github.com/red0124/ssp/actions/workflows/fuzz.yml) [![fuzz](https://github.com/red0124/ssp/workflows/fuzz-ci/badge.svg?branch=master)](https://github.com/red0124/ssp/actions/workflows/fuzz.yml)
[![single-header](https://github.com/red0124/ssp/actions/workflows/single-header.yml/badge.svg?branch=master)](https://github.com/red0124/ssp/actions/workflows/single-header.yml) [![single-header](https://github.com/red0124/ssp/workflows/single-header-ci/badge.svg?branch=master)](https://github.com/red0124/ssp/actions/workflows/single-header.yml)
[![ubuntu-latest-gcc](https://github.com/red0124/ssp/actions/workflows/ubuntu-latest-gcc.yml/badge.svg?branch=master)](https://github.com/red0124/ssp/actions/workflows/ubuntu-latest-gcc.yml) [![ubuntu-latest-gcc](https://github.com/red0124/ssp/workflows/ubuntu-latest-gcc-ci/badge.svg?branch=master)](https://github.com/red0124/ssp/actions/workflows/ubuntu-latest-gcc.yml)
[![ubuntu-latest-clang](https://github.com/red0124/ssp/actions/workflows/ubuntu-latest-clang.yml/badge.svg?branch=master)](https://github.com/red0124/ssp/actions/workflows/ubuntu-latest-clang.yml) [![ubuntu-latest-clang](https://github.com/red0124/ssp/workflows/ubuntu-latest-clang-ci/badge.svg?branch=master)](https://github.com/red0124/ssp/actions/workflows/ubuntu-latest-clang.yml)
[![windows-msys2-gcc](https://github.com/red0124/ssp/actions/workflows/win-msys2-gcc.yml/badge.svg?branch=master)](https://github.com/red0124/ssp/actions/workflows/win-msys2-gcc.yml) [![windows-msys2-gcc](https://github.com/red0124/ssp/workflows/win-msys2-gcc-ci/badge.svg?branch=master)](https://github.com/red0124/ssp/actions/workflows/win-msys2-gcc.yml)
[![windows-msys2-clang](https://github.com/red0124/ssp/actions/workflows/win-msys2-clang.yml/badge.svg?branch=master)](https://github.com/red0124/ssp/actions/workflows/win-msys2-clang.yml) [![windows-msys2-clang](https://github.com/red0124/ssp/workflows/win-msys2-clang-ci/badge.svg?branch=master)](https://github.com/red0124/ssp/actions/workflows/win-msys2-clang.yml)
[![windows-msvc](https://github.com/red0124/ssp/actions/workflows/win-msvc.yml/badge.svg?branch=master)](https://github.com/red0124/ssp/actions/workflows/win-msvc.yml) [![windows-msvc](https://github.com/red0124/ssp/workflows/win-msvc-ci/badge.svg?branch=master)](https://github.com/red0124/ssp/actions/workflows/win-msvc.yml)
[![macos-apple-clang](https://github.com/red0124/ssp/actions/workflows/macos-apple-clang.yml/badge.svg?branch=master)](https://github.com/red0124/ssp/actions/workflows/macos-apple-clang.yml) [![macos-apple-clang](https://github.com/red0124/ssp/workflows/macos-apple-clang-ci/badge.svg?branch=master)](https://github.com/red0124/ssp/actions/workflows/macos-apple-clang.yml)
A header only CSV parser which is fast and versatile with modern C++ API. Requires compiler with C++17 support. [Can also be used to efficiently convert strings to specific types.](#the-converter) A header only CSV parser which is fast and versatile with modern C++ API. Requires compiler with C++17 support. [Can also be used to efficiently convert strings to specific types.](#the-converter)
@@ -73,7 +73,7 @@ Bill (Heath) Gates 65 3.3
# Single header # Single header
The library can be used with a single header file **`ssp.hpp`**, but it suffers a significant performance loss when converting floating point values since the **`fast_float`** library is not present within the file. The library can be used with a single header file **`ssp.hpp`**, but it suffers a slight performance loss when converting floating point values since the **`fast_float`** library is not present within the file.
# Installation # Installation
@@ -91,7 +91,7 @@ The library supports [CMake](#Cmake) and [meson](#Meson) build systems
## Headers ## Headers
The parser can be told to use only certain columns by parsing the header. This can be done with the **`use_fields`** method. It accepts any number of string-like arguments or even an **`std::vector<std::string>`** with the field names. If any of the fields are not found within the header or if any fields are defined multiple times it will result in an error. The parser can be told to use only certain columns by parsing the header. This can be done by using the **`use_fields`** method. It accepts any number of string-like arguments or even an **`std::vector<std::string>`** with the field names. If any of the fields are not found within the header or if any fields are defined multiple times it will result in an error.
```shell ```shell
$ cat students_with_header.csv $ cat students_with_header.csv
Id,Age,Grade Id,Age,Grade
@@ -115,7 +115,7 @@ James Bailey 2.5
Brian S. Wolfe 1.9 Brian S. Wolfe 1.9
Bill (Heath) Gates 3.3 Bill (Heath) Gates 3.3
``` ```
The header can be ignored using the **`ss::ignore_header`** [setup](#Setup) option or by calling the **`ignore_next`** method after the parser has been constructed. If the header has been ignored calling any method related to header usage will result in a compilation error. The header can be ignored using the **`ss::ignore_header`** [setup](#Setup) option or by calling the **`ignore_next`** method after the parser has been constructed.
```cpp ```cpp
ss::parser<ss::ignore_header> p{file_name}; ss::parser<ss::ignore_header> p{file_name};
``` ```
@@ -123,10 +123,10 @@ The fields with which the parser works with can be modified at any given time. T
```cpp ```cpp
// ... // ...
ss::parser<ss::throw_on_error> p{"students_with_header.csv"}; ss::parser<ss::throw_on_error> p{"students_with_header.csv"};
p.use_fields("Grade"); p.use_fields("Id", "Grade");
const auto& grade = p.get_next<std::string>(); const auto& [id, grade] = p.get_next<std::string, float>();
std::cout << grade << std::endl; std::cout << id << ' ' << grade << std::endl;
if (p.field_exists("Id")) { if (p.field_exists("Id")) {
p.use_fields("Grade", "Id"); p.use_fields("Grade", "Id");
@@ -138,32 +138,10 @@ The fields with which the parser works with can be modified at any given time. T
``` ```
```shell ```shell
$ ./a.out $ ./a.out
2.5 James Bailey 2.5
1.9 Brian S. Wolfe 40 Brian S. Wolfe
3.3 Bill (Heath) Gates 65 Bill (Heath) Gates
``` ```
The header is parsed with the same rules as other rows, the only difference is that **`multiline`** will be disabled when parsing the header. To get the data that is
present in the header as a **`std::vector<std::string>`**, the **`header`** method can be used, and to get the header line before it has been parsed, the **`raw_header`** method can be used:
```cpp
// ...
ss::parser<ss::throw_on_error> p{"students_with_header.csv"};
std::cout << p.raw_header() << std::endl;
for (const auto& field: p.header()) {
std::cout << "> " << field << std::endl;
}
// ...
```
```shell
$ ./a.out
Id,Age,Grade
> Id
> Age
> Grade
```
Methods related to headers can also fail, the error handling of these is done in the same way as for other methods.
## Conversions ## Conversions
An alternate loop to the example above would look like: An alternate loop to the example above would look like:
```cpp ```cpp

View File

@@ -1,9 +1,9 @@
#!/usr/bin/env bash #!/bin/bash
JOBS=4 JOBS=4
BUILD_TYPE=Debug BUILD_TYPE=Debug
set -ex set -eux
git clone https://github.com/red0124/doctest -b master --depth 1 git clone https://github.com/red0124/doctest -b master --depth 1
@@ -12,10 +12,6 @@ cmake -S doctest -B doctest/build \
-D DOCTEST_WITH_MAIN_IN_STATIC_LIB=NO \ -D DOCTEST_WITH_MAIN_IN_STATIC_LIB=NO \
-D DOCTEST_WITH_TESTS=NO -D DOCTEST_WITH_TESTS=NO
if [[ "${1}" == "sudo" ]]; then cmake --build doctest/build --config ${BUILD_TYPE} --target install -j ${JOBS}
sudo cmake --build doctest/build --config ${BUILD_TYPE} --target install -j ${JOBS}
else
cmake --build doctest/build --config ${BUILD_TYPE} --target install -j ${JOBS}
fi
rm -rf doctest rm -rf doctest

23
script/ci_install_icc.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
URL=$1
COMPONENTS=$2
curl --output webimage.sh --url "$URL" --retry 5 --retry-delay 5
chmod +x webimage.sh
./webimage.sh -x -f webimage_extracted --log extract.log
rm -rf webimage.sh
WEBIMAGE_NAME=$(ls -1 webimage_extracted/)
if [ -z "$COMPONENTS" ]; then
webimage_extracted/"$WEBIMAGE_NAME"/bootstrapper -s --action install --eula=accept --continue-with-optional-error=yes --log-dir=.
installer_exit_code=$?
else
webimage_extracted/"$WEBIMAGE_NAME"/bootstrapper -s --action install --components="$COMPONENTS" --eula=accept --continue-with-optional-error=yes --log-dir=.
installer_exit_code=$?
fi
rm -rf webimage_extracted
exit $installer_exit_code

11
script/ci_setup_icc.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#shellcheck disable=SC2010
LATEST_VERSION=$(ls -1 /opt/intel/oneapi/compiler/ | grep -v latest | sort | tail -1)
# shellcheck source=/dev/null
source /opt/intel/oneapi/compiler/"$LATEST_VERSION"/env/vars.sh
CXX=dpcpp

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14) cmake_minimum_required(VERSION 3.15)
project(ssp_tests CXX) project(ssp_tests CXX)