Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 308563a

Browse files
Deploy
0 parents commit 308563a

File tree

11 files changed

+393
-0
lines changed

11 files changed

+393
-0
lines changed

‎.github/workflows/macos.yml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: MacOS
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
env:
10+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
11+
BUILD_TYPE: "Unix Makefiles"
12+
13+
jobs:
14+
build:
15+
# The CMake configure and build commands are platform agnostic and should work equally
16+
# well on Windows or Mac. You can convert this to a matrix build if you need
17+
# cross-platform coverage.
18+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
19+
runs-on: macos-latest
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: Build
25+
# Build your program with the given configuration
26+
run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -G "Unix Makefiles"
27+
28+
- name: Configure build directory
29+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
30+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
31+
run: cmake --build build

‎.github/workflows/ubuntu.yml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Ubuntu
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
env:
10+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
11+
BUILD_TYPE: "Unix Makefiles"
12+
13+
jobs:
14+
build:
15+
# The CMake configure and build commands are platform agnostic and should work equally
16+
# well on Windows or Mac. You can convert this to a matrix build if you need
17+
# cross-platform coverage.
18+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: Build
25+
# Build your program with the given configuration
26+
run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -G "Unix Makefiles"
27+
28+
- name: Configure build directory
29+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
30+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
31+
run: cmake --build build

‎.github/workflows/windows.yml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Windows
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
env:
10+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
11+
BUILD_TYPE: "Unix Makefiles"
12+
13+
jobs:
14+
build:
15+
# The CMake configure and build commands are platform agnostic and should work equally
16+
# well on Windows or Mac. You can convert this to a matrix build if you need
17+
# cross-platform coverage.
18+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
19+
runs-on: windows-latest
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: Build
25+
# Build your program with the given configuration
26+
run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -G "Unix Makefiles"
27+
28+
- name: Configure build directory
29+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
30+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
31+
run: cmake --build build

‎.gitignore‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Prerequisites
2+
*.d
3+
4+
# Compiled Object files
5+
*.slo
6+
*.lo
7+
*.o
8+
*.obj
9+
10+
# Precompiled Headers
11+
*.gch
12+
*.pch
13+
14+
# Compilation folders
15+
obj/
16+
bin/
17+
18+
#MacOS Files
19+
.DS_Store
20+
21+
#CLion Files
22+
.idea/
23+
24+
# Visual code
25+
.vscode
26+
.vs
27+
28+
# CMake
29+
*cmake-build-*/
30+
CMakeLists.txt.user
31+
CMakeCache.txt
32+
CMakeFiles
33+
CMakeScripts
34+
Testing
35+
cmake_install.cmake
36+
install_manifest.txt
37+
compile_commands.json
38+
CTestTestfile.cmake
39+
_deps

‎CMakeLists.txt‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
cmake_minimum_required(VERSION 3.17)
2+
3+
project(string_utils)
4+
5+
# Project settings
6+
set(CMAKE_CXX_STANDARD 17)
7+
set (CMAKE_CXX_FLAGS "--coverage")
8+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build)
9+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build)
10+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
11+
12+
# Google testing framework
13+
include(FetchContent)
14+
FetchContent_Declare(
15+
googletest
16+
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
17+
)
18+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
19+
FetchContent_MakeAvailable(googletest)
20+
21+
# Include directories
22+
include_directories("${PROJECT_SOURCE_DIR}")
23+
include_directories("${PROJECT_SOURCE_DIR}/src")
24+
include_directories("${PROJECT_SOURCE_DIR}/test")
25+
26+
# Project source files
27+
set(string_utils_sources
28+
src/wniemiec/data/cpp/StringUtils.cpp
29+
)
30+
31+
add_executable(string_utils ${string_utils_sources})
32+
33+
# Google testing framework
34+
enable_testing()
35+
target_link_libraries(
36+
string_utils
37+
gtest_main
38+
)
39+
include(GoogleTest)
40+
gtest_discover_tests(string_utils)

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 William Niemiec
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎Makefile‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
OBJS = StringUtils.o
2+
SOURCE = src/wniemiec/data/cpp/StringUtils.cpp
3+
CC = g++
4+
FLAGS = -c
5+
LFLAGS =
6+
7+
all: $(OBJS)
8+
$(CC) -c $(OBJS) $(LFLAGS) -std=c++17
9+
10+
StringUtils.o: src/wniemiec/data/cpp/StringUtils.cpp
11+
$(CC) $(FLAGS) src/wniemiec/data/cpp/StringUtils.cpp -std=c++17
12+
13+
clean:
14+
rm -f $(OBJS) $(OUT)

‎README.md‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
![](https://github.com/wniemiec-util-cpp/string-utils/blob/master/docs/img/logo/logo.jpg)
2+
3+
<h1 align='center'>String Utils</h1>
4+
<p align='center'>Contains methods that perform string manipulation.</p>
5+
<p align="center">
6+
<a href="https://github.com/wniemiec-util-cpp/string-utils/actions/workflows/windows.yml"><img src="https://github.com/wniemiec-util-cpp/string-utils/actions/workflows/windows.yml/badge.svg" alt=""></a>
7+
<a href="https://github.com/wniemiec-util-cpp/string-utils/actions/workflows/macos.yml"><img src="https://github.com/wniemiec-util-cpp/string-utils/actions/workflows/macos.yml/badge.svg" alt=""></a>
8+
<a href="https://github.com/wniemiec-util-cpp/string-utils/actions/workflows/ubuntu.yml"><img src="https://github.com/wniemiec-util-cpp/string-utils/actions/workflows/ubuntu.yml/badge.svg" alt=""></a>
9+
<a href="https://codecov.io/gh/wniemiec-util-cpp/string-utils"><img src="https://codecov.io/gh/wniemiec-util-cpp/string-utils/branch/master/graph/badge.svg?token=R2SFS4SP86" alt="Coverage status"></a>
10+
<a href="https://docs.microsoft.com/en-us/cpp/"><img src="https://img.shields.io/badge/C++-17+-D0008F.svg" alt="Cpp compatibility"></a>
11+
<a href="https://github.com/wniemiec-util-cpp/string-utils/releases"><img src="https://img.shields.io/github/v/release/wniemiec-util-cpp/string-utils" alt="Release"></a>
12+
<a href="https://github.com/wniemiec-util-cpp/string-utils/blob/master/LICENSE"><img src="https://img.shields.io/github/license/wniemiec-util-cpp/string-utils" alt="License"></a>
13+
</p>
14+
<hr />
15+
16+
## ❇ Introduction
17+
Methods package that perform string manipulation.
18+
19+
## ❓ How to use
20+
1. Add the content of the [`src`](https://github.com/wniemiec-util-cpp/string-utils/blob/master/src) folder to the folder containing your project's source files
21+
22+
2. Add the content of the [`include`](https://github.com/wniemiec-util-cpp/string-utils/blob/master/include) folder to the folder containing your project's header files
23+
24+
3. Copy the [`Makefile`](https://github.com/wniemiec-util-cpp/string-utils/blob/master/Makefile) to your project's root folder (if you already has one, merge the files)
25+
26+
4. Run the following commands:
27+
```
28+
$ make clean
29+
$ make
30+
```
31+
32+
5. Use it
33+
```
34+
[...]
35+
36+
#include "wniemiec/data/cpp/StringUtils.hpp";
37+
38+
[...]
39+
40+
std::string text = "hello world";
41+
42+
std::vector<std::string> words = StringUtils::split(text, " "); // Returns ["hello", "world"]
43+
44+
std::cout << StringUtils::to_upper("hello world") << std::endl; // Returns "HELLO WORLD"
45+
46+
[...]
47+
```
48+
49+
**Note:** You can use cmake if you wish. To do this, use the [`CMakeLists.txt`](https://github.com/wniemiec-util-cpp/string-utils/blob/master/CMakeLists.txt) file.
50+
51+
52+
## 📖 Documentation
53+
| Property |Type|Description|Default|
54+
|----------------|-------------------------------|-----------------------------|--------|
55+
|split |`str: std::string, sep: std::string`|Returns a list of the words in the string, separated by the delimiter string| - |
56+
|to_upper |`str: std::string`|Returns a copy of the string in UPPER CASE| - |
57+
58+
59+
## 🚩 Changelog
60+
Details about each version are documented in the [releases section](https://github.com/williamniemiec/wniemiec-util-cpp/string-utils/releases).
61+
62+
## 🤝 Contribute!
63+
See the documentation on how you can contribute to the project [here](https://github.com/wniemiec-util-cpp/string-utils/blob/master/CONTRIBUTING.md).
64+
65+
## 📁 Files
66+
67+
### /
68+
| Name |Type|Description|
69+
|----------------|-------------------------------|-----------------------------|
70+
|dist |`Directory`|Released versions|
71+
|docs |`Directory`|Documentation files|
72+
|src |`Directory`| Source files|
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Copyright (c) William Niemiec.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#pragma once
9+
10+
#include <iostream>
11+
#include <vector>
12+
13+
namespace wniemiec { namespace data { namespace cpp {
14+
15+
/**
16+
* Contains methods that perform string manipulation.
17+
*/
18+
class StringUtils
19+
{
20+
//-------------------------------------------------------------------------
21+
// Constructor
22+
//-------------------------------------------------------------------------
23+
private:
24+
StringUtils();
25+
26+
27+
//-------------------------------------------------------------------------
28+
// Methods
29+
//-------------------------------------------------------------------------
30+
public:
31+
/**
32+
* Returns a list of the words in the string, separated by the
33+
* delimiter string.
34+
*
35+
* @param str String to be splited.
36+
* @param sep Character dividing the string into split groups.
37+
*
38+
* @return Vector with split groups
39+
*
40+
* @throws std::invalid_argument If string is null or if separator
41+
* is null
42+
*/
43+
static std::vector<std::string> split(std::string str, std::string sep);
44+
45+
/**
46+
* Returns a copy of the string in UPPER CASE.
47+
*
48+
* @param str Some string
49+
*
50+
* @return String in upper case
51+
*
52+
* @throws std::invalid_argument If string is null
53+
*/
54+
static std::string to_upper(std::string str);
55+
};
56+
}}}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /