Skip to content

Commit

Permalink
Merge pull request #5 from yumetodo/feat/support_string_view
Browse files Browse the repository at this point in the history
Feat: support string_view
  • Loading branch information
yumetodo authored Jul 14, 2018
2 parents 35067b1 + 8dd9bdb commit a79c7f8
Show file tree
Hide file tree
Showing 31 changed files with 2,385 additions and 1,850 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[Rr]eleases/
[Xx]64/
[Xx]86/
[Bb]uild/
[Bb]uild*/
bld/
[Bb]in/
[Oo]bj/
Expand Down
16 changes: 14 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,19 @@ install:
fi
language: cpp
script:
- make Release USE_COVERAGE=0 && ./test/test.out && ./sample/sample.out && make clean && make Debug && ./test/test.out && ./sample/sample.out
- mkdir build_release
- mkdir build_debug
- cd build_release
- cmake -DCMAKE_BUILD_TYPE=Release ..
- make ci
- cd ../build_debug
- cmake -DSTRING_SPLIT_ENABLE_COVERAGE="${USE_COVERALLS}" -DCMAKE_BUILD_TYPE=Debug ..
- make ci
after_success:
# Coverage
- if [ "${USE_COVERALLS}" = '1' ]; then cd ./test; make send-coveralls; fi
- pwd
- cd $TRAVIS_BUILD_DIR
- ls $TRAVIS_BUILD_DIR
- ls "$TRAVIS_BUILD_DIR/build_debug"
- ls "$TRAVIS_BUILD_DIR/build_debug/test"
- if [ "${USE_COVERALLS}" = '1' ]; then lcoveralls --retry-count 3 "$TRAVIS_BUILD_DIR/build_debug/test/test_coverage.info.cleaned" ; fi
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.7)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules)
add_subdirectory(sample)
add_subdirectory(benchmark)
add_subdirectory(test)

add_custom_target(ci
DEPENDS benchmark run_sample
)
if((CMAKE_BUILD_TYPE STREQUAL "Debug") AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") AND STRING_SPLIT_ENABLE_COVERAGE)
add_dependencies(ci test_coverage)
else()
add_dependencies(ci run_test)
endif()
17 changes: 0 additions & 17 deletions Makefile

This file was deleted.

24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# string split like chain method
# string split like chain method

[![Run Status](https://api.shippable.com/projects/577cc6213be4f4faa56be97c/badge?branch=master)](https://app.shippable.com/projects/577cc6213be4f4faa56be97c)
[![Build Status](https://travis-ci.org/yumetodo/string_split.svg?branch=master)](https://travis-ci.org/yumetodo/string_split)
[![Coverage Status](https://coveralls.io/repos/github/yumetodo/string_split/badge.svg?branch=master)](https://coveralls.io/github/yumetodo/string_split?branch=master)
[![Boost Software License](https://img.shields.io/badge/license-boost-blue.svg)](http://www.boost.org/LICENSE_1_0.txt)

This is a **C++ header only** library to split string.

# Usage
## Usage

just include ``include/string_split.hpp``.
Just include `include/string_split.hpp`.

```cpp
#include "../include/string_split.hpp"
Expand All @@ -33,9 +34,20 @@ int main()
}
```

Temporary ``std::vector<std::string>`` **will not be created** becase the priority of ``operator[]/operator>>`` is higher than ``operator|``
Temporary `std::vector<std::string>` **will not be created** becase the priority of `operator[]/operator>>` is higher than `operator|`

## Compiler requirement

# Compiler require
C++11 support is required(need C++14 support is required to compile testcase).

However, we support Visual Studio 2015 update2 or later.
However, we support Visual Studio 2015 update2 or later.

### `std::string_view`

We are supporting `std::basic_string_view`.

Enable C++17 mode and use below:

- Visual Studio 2017
- GCC 7.1 or later
- clang 4 or later
30 changes: 30 additions & 0 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.7)
enable_language(CXX)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/../cmake/modules)

#
# C++ version
#
include(DecideCXXStanderd)
DECIDE_CXX_STANDERD()
message("CMAKE_CXX_STANDARD:${CMAKE_CXX_STANDARD}")

set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
set(CMAKE_CXX_EXTENSIONS OFF) #...without compiler extensions like gnu++11

#
# Set our project name
#
project(benchmark)

#
# Source files
#
set(benchmark_src
"./benchmark.cpp"
)

#
# Compile
#
add_executable(benchmark ${benchmark_src})
42 changes: 0 additions & 42 deletions benchmark/Makefile

This file was deleted.

7 changes: 5 additions & 2 deletions benchmark/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,12 @@ std::string generate_random_string(std::size_t len, std::size_t split_num, char
void benchmark_split_only(split_func_t split_f, const char* func_name, const std::string& s, char delim, std::size_t cnt) {
namespace ch = std::chrono;
const auto t_start = ch::high_resolution_clock::now();
#pragma warning(push)
#pragma warning(disable: 5030)
for ([[gnu::unused]] auto&& i : rep(cnt - 1)) {
split_f(s, delim);
}
#pragma warning(pop)
const auto re = split_f(s, delim);
const auto t_stop = ch::high_resolution_clock::now();
std::cout
Expand All @@ -146,13 +149,13 @@ void benchmark_split_extract(split_func_t split_f, const char* func_name, const
std::string re;
if (split_our_library == split_f) {
for ([[gnu::unused]] auto&& i : rep(cnt - 1)) {
s | split(delim)[extract_i];
(void)(s | split(delim)[extract_i]);
}
re = s | split(delim)[extract_i];
}
else {
for ([[gnu::unused]] auto&& i : rep(cnt - 1)) {
split_f(s, delim)[extract_i];
(void)split_f(s, delim)[extract_i];
}
re = split_f(s, delim)[extract_i];
}
Expand Down
Loading

0 comments on commit a79c7f8

Please sign in to comment.