mirror of
https://github.com/red0124/ssp.git
synced 2025-08-01 10:22:31 +02:00
Compare commits
5 Commits
544ecddf1a
...
d23b826113
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d23b826113 | ||
![]() |
322aaf9c16 | ||
![]() |
41ae9d98c7 | ||
53c5b779d4 | |||
107a122718 |
77
.github/workflows/ubuntu-latest-icc.yml
vendored
77
.github/workflows/ubuntu-latest-icc.yml
vendored
@ -1,77 +0,0 @@
|
||||
name: ubuntu-latest-icc-ci
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- feature/**
|
||||
- improvement/**
|
||||
- bugfix/**
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- feature/**
|
||||
- improvement/**
|
||||
- bugfix/**
|
||||
|
||||
env:
|
||||
LINUX_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/irc_nas/17431/l_BaseKit_p_2021.1.0.2659_offline.sh
|
||||
LINUX_HPCKIT_URL:
|
||||
https://registrationcenter-download.intel.com/akdlm/irc_nas/17427/l_HPCKit_p_2021.1.0.2684_offline.sh
|
||||
|
||||
jobs:
|
||||
icc_tests:
|
||||
if: >-
|
||||
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
||||
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
container:
|
||||
image: gcc:10
|
||||
options: -v /usr/local:/host_usr_local
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: cache install
|
||||
id: cache-install
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
/opt/intel/oneapi/compiler
|
||||
key: >-
|
||||
install-${{env.LINUX_HPCKIT_URL}}-
|
||||
${{env.LINUX_CPP_COMPONENTS_WEB}}-
|
||||
compiler-${{hashFiles('**/scripts/cache_exclude_linux.sh')}}
|
||||
|
||||
- name: Install icc
|
||||
run: >-
|
||||
script/ci_install_icc.sh $LINUX_HPCKIT_URL $LINUX_CPP_COMPONENTS_WEB
|
||||
|
||||
- name: CMake
|
||||
run: echo "/host_usr_local/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Install dependencies
|
||||
run: script/ci_install_deps.sh
|
||||
|
||||
- name: Configure
|
||||
run: >-
|
||||
source script/ci_setup_icc.sh &&
|
||||
cmake -S test -B build -D CMAKE_BUILD_TYPE=Debug
|
||||
|
||||
- name: Build
|
||||
run: >-
|
||||
source script/ci_setup_icc.sh &&
|
||||
cmake --build build -j ${{steps.cores.outputs.count}}
|
||||
|
||||
- name: Run
|
||||
working-directory: build
|
||||
run: ctest --output-on-failure
|
6
.github/workflows/win-msvc.yml
vendored
6
.github/workflows/win-msvc.yml
vendored
@ -31,14 +31,14 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
- os: windows-2019
|
||||
vs: "Visual Studio 16 2019"
|
||||
- os: windows-2025
|
||||
vs: "Visual Studio 18 2025"
|
||||
|
||||
- os: windows-latest
|
||||
vs: "Visual Studio 17 2022"
|
||||
|
||||
build: [Debug, Release]
|
||||
platform: [Win32, x64]
|
||||
platform: [x64]
|
||||
|
||||
runs-on: ${{matrix.config.os}}
|
||||
|
||||
|
7
.github/workflows/win-msys2-clang.yml
vendored
7
.github/workflows/win-msys2-clang.yml
vendored
@ -31,7 +31,7 @@ jobs:
|
||||
fail-fast: false
|
||||
|
||||
matrix:
|
||||
os: [windows-2019, windows-latest]
|
||||
os: [windows-2025, windows-latest]
|
||||
type: [Release, Debug]
|
||||
config:
|
||||
- msystem: "MINGW64"
|
||||
@ -39,11 +39,6 @@ jobs:
|
||||
git mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja
|
||||
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}}
|
||||
|
||||
name: "${{matrix.config.msystem}}: ${{matrix.os}}: ${{matrix.type}}"
|
||||
|
7
.github/workflows/win-msys2-gcc.yml
vendored
7
.github/workflows/win-msys2-gcc.yml
vendored
@ -31,7 +31,7 @@ jobs:
|
||||
fail-fast: false
|
||||
|
||||
matrix:
|
||||
os: [windows-2019, windows-latest]
|
||||
os: [windows-2025, windows-latest]
|
||||
type: [Release, Debug]
|
||||
config:
|
||||
- msystem: "MINGW64"
|
||||
@ -39,11 +39,6 @@ jobs:
|
||||
git mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja
|
||||
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}}
|
||||
|
||||
name: "${{matrix.config.msystem}}: ${{matrix.os}}: ${{matrix.type}}"
|
||||
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
project(
|
||||
ssp
|
||||
VERSION 1.7.2
|
||||
VERSION 1.8.0
|
||||
DESCRIPTION "csv parser"
|
||||
HOMEPAGE_URL "https://github.com/red0124/ssp"
|
||||
LANGUAGES CXX
|
||||
|
41
README.md
41
README.md
@ -13,7 +13,6 @@
|
||||
[](https://github.com/red0124/ssp/actions/workflows/single-header.yml)
|
||||
[](https://github.com/red0124/ssp/actions/workflows/ubuntu-latest-gcc.yml)
|
||||
[](https://github.com/red0124/ssp/actions/workflows/ubuntu-latest-clang.yml)
|
||||
[](https://github.com/red0124/ssp/actions/workflows/ubuntu-latest-icc.yml)
|
||||
[](https://github.com/red0124/ssp/actions/workflows/win-msys2-gcc.yml)
|
||||
[](https://github.com/red0124/ssp/actions/workflows/win-msys2-clang.yml)
|
||||
[](https://github.com/red0124/ssp/actions/workflows/win-msvc.yml)
|
||||
@ -74,7 +73,7 @@ Bill (Heath) Gates 65 3.3
|
||||
|
||||
# Single header
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
# Installation
|
||||
|
||||
@ -92,7 +91,7 @@ The library supports [CMake](#Cmake) and [meson](#Meson) build systems
|
||||
|
||||
## Headers
|
||||
|
||||
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.
|
||||
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.
|
||||
```shell
|
||||
$ cat students_with_header.csv
|
||||
Id,Age,Grade
|
||||
@ -116,7 +115,7 @@ James Bailey 2.5
|
||||
Brian S. Wolfe 1.9
|
||||
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.
|
||||
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.
|
||||
```cpp
|
||||
ss::parser<ss::ignore_header> p{file_name};
|
||||
```
|
||||
@ -124,10 +123,10 @@ The fields with which the parser works with can be modified at any given time. T
|
||||
```cpp
|
||||
// ...
|
||||
ss::parser<ss::throw_on_error> p{"students_with_header.csv"};
|
||||
p.use_fields("Id", "Grade");
|
||||
p.use_fields("Grade");
|
||||
|
||||
const auto& [id, grade] = p.get_next<std::string, float>();
|
||||
std::cout << id << ' ' << grade << std::endl;
|
||||
const auto& grade = p.get_next<std::string>();
|
||||
std::cout << grade << std::endl;
|
||||
|
||||
if (p.field_exists("Id")) {
|
||||
p.use_fields("Grade", "Id");
|
||||
@ -139,10 +138,32 @@ The fields with which the parser works with can be modified at any given time. T
|
||||
```
|
||||
```shell
|
||||
$ ./a.out
|
||||
James Bailey 2.5
|
||||
40 Brian S. Wolfe
|
||||
65 Bill (Heath) Gates
|
||||
2.5
|
||||
1.9 Brian S. Wolfe
|
||||
3.3 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
|
||||
An alternate loop to the example above would look like:
|
||||
```cpp
|
||||
|
@ -6,7 +6,7 @@ project(
|
||||
'cpp_std=c++17',
|
||||
'buildtype=debugoptimized',
|
||||
'wrap_mode=forcefallback'],
|
||||
version: '1.7.2',
|
||||
version: '1.8.0',
|
||||
meson_version:'>=0.54.0')
|
||||
|
||||
fast_float_dep = dependency('fast_float')
|
||||
|
Loading…
Reference in New Issue
Block a user