Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fast-cpp-csv-parser/20191004 #945

Merged
merged 1 commit into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipes/fast-cpp-csv-parser/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"20191004":
url: "https://github.com/ben-strasser/fast-cpp-csv-parser/archive/713c5fd2ba1b6d145296a21fc7f9dee576daaa4f.zip"
sha256: "cef1aa042b8d82722e02af2f09659d5b8aeba10fcf431b2fe8ce452798423a56"
39 changes: 39 additions & 0 deletions recipes/fast-cpp-csv-parser/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import os

from conans import ConanFile, tools

class FastcppcsvparserConan(ConanFile):
name = "fast-cpp-csv-parser"
description = "C++11 header-only library for reading comma separated value (CSV) files."
license = "BSD-3-Clause"
topics = ("conan", "fast-cpp-csv-parser", "csv", "parser", "header-only")
homepage = "https://github.com/ben-strasser/fast-cpp-csv-parser"
url = "https://github.com/conan-io/conan-center-index"
settings = "os"
no_copy_source = True
options = {"with_thread": [True, False]}
default_options = {"with_thread": True}

@property
def _source_subfolder(self):
return "source_subfolder"

def source(self):
tools.get(**self.conan_data["sources"][self.version])
url = self.conan_data["sources"][self.version]["url"]
extracted_dir = self.name + "-" + os.path.splitext(os.path.basename(url))[0]
os.rename(extracted_dir, self._source_subfolder)

def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
self.copy("csv.h", dst=os.path.join("include", "fast-cpp-csv-parser"), src=self._source_subfolder)

def package_id(self):
self.info.header_only()

def package_info(self):
self.cpp_info.includedirs = ["include", os.path.join("include", "fast-cpp-csv-parser")]
if not self.options.with_thread:
self.cpp_info.defines.append("CSV_IO_NO_THREAD")
if self.settings.os == "Linux" and self.options.with_thread:
self.cpp_info.system_libs.append("pthread")
9 changes: 9 additions & 0 deletions recipes/fast-cpp-csv-parser/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 2.8.11)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11)
18 changes: 18 additions & 0 deletions recipes/fast-cpp-csv-parser/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os

from conans import ConanFile, CMake, tools

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
csv_name = os.path.join(self.source_folder, "test_package.csv")
bin_path = os.path.join("bin", "test_package")
self.run("{0} {1}".format(bin_path, csv_name), run_environment=True)
20 changes: 20 additions & 0 deletions recipes/fast-cpp-csv-parser/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <csv.h>

#include <iostream>
#include <string>

int main(int argc, char **argv) {
if (argc < 2) {
std::cerr << "Need at least one argument\n";
return 1;
}

io::CSVReader<3> in(argv[1]);
in.read_header(io::ignore_extra_column, "First Name", "Last Name", "Age");
std::string first_name; std::string last_name; double age;
while (in.read_row(first_name, last_name, age)) {
std::cout << first_name << " " << last_name << " " << age << '\n';
}

return 0;
}
3 changes: 3 additions & 0 deletions recipes/fast-cpp-csv-parser/all/test_package/test_package.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
First Name,Last Name,Age
John,Doe,38
Mary,Blake,25
3 changes: 3 additions & 0 deletions recipes/fast-cpp-csv-parser/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"20191004":
folder: all