Skip to content

Commit 47f86ad

Browse files
authored
MERGE: pull request #26 from threeal/main
Version 0.1.0 Release
2 parents e1cfde4 + c77a9db commit 47f86ad

32 files changed

+1090
-2
lines changed

.clang-format

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
BasedOnStyle: Google

.cmake-format

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"line_width": 120
3+
}

.github/dependabot.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: 'github-actions'
4+
directory: '/'
5+
schedule:
6+
interval: 'daily'

.github/workflows/build.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: build
2+
on:
3+
workflow_dispatch:
4+
push:
5+
jobs:
6+
release:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout this repository
10+
uses: actions/[email protected]
11+
12+
- name: Configure and build this project
13+
uses: threeal/[email protected]
14+
15+
release-msvc:
16+
runs-on: windows-latest
17+
steps:
18+
- name: Checkout this repository
19+
uses: actions/[email protected]
20+
21+
- name: Configure and build this project
22+
uses: threeal/[email protected]
23+
with:
24+
cxx-compiler: cl

.github/workflows/test.yml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: test
2+
on:
3+
workflow_dispatch:
4+
push:
5+
jobs:
6+
unit-tests:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout this repository
10+
uses: actions/[email protected]
11+
12+
- name: Configure, build, and test this project
13+
id: cmake_action
14+
uses: threeal/[email protected]
15+
with:
16+
generator: Ninja
17+
cxx-compiler: clang++
18+
args: -DBUILD_TESTING=ON
19+
run-test: true
20+
test-args: --no-compress-output -T Test
21+
22+
- name: Setup Testspace client
23+
id: setup_testspace
24+
if: steps.cmake_action.outcome == 'success' || steps.cmake_action.outcome == 'failure'
25+
uses: testspace-com/[email protected]
26+
with:
27+
domain: ${{github.repository_owner}}
28+
29+
- name: Send test result to Testspace
30+
if: steps.setup_testspace.outcome == 'success'
31+
run: testspace [Tests]"build/Testing/*/Test.xml"
32+
33+
- name: Generate and send code coverage report to Coveralls
34+
if: steps.cmake_action.outcome == 'success' || steps.cmake_action.outcome == 'failure'
35+
uses: threeal/[email protected]
36+
with:
37+
gcov-executable: llvm-cov gcov
38+
exclude: build/*
39+
coveralls-send: true
40+
github-token: ${{ secrets.GITHUB_TOKEN }}
41+
42+
check-warning:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Checkout this repository
46+
uses: actions/[email protected]
47+
48+
- name: Configure and build this project
49+
uses: threeal/[email protected]
50+
with:
51+
generator: Ninja
52+
cxx-flags: -Werror
53+
args: -DBUILD_TESTING=ON
54+
55+
check-warning-msvc:
56+
runs-on: windows-latest
57+
steps:
58+
- name: Checkout this repository
59+
uses: actions/[email protected]
60+
61+
- name: Configure and build this project
62+
uses: threeal/[email protected]
63+
with:
64+
cxx-compiler: cl
65+
cxx-flags: /WX
66+
args: -DBUILD_TESTING=ON
67+
68+
check-formatting:
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Checkout this repository
72+
uses: actions/[email protected]
73+
74+
- name: Install cmake-format
75+
run: pip3 install cmake-format
76+
77+
- name: Configure and check formatting
78+
uses: threeal/[email protected]
79+
with:
80+
targets: format check-format

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
.*
2+
!.git*
3+
14
build
5+
_xml

.readthedocs.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
build:
3+
os: ubuntu-20.04
4+
tools:
5+
python: "3.9"
6+
sphinx:
7+
configuration: docs/conf.py
8+
python:
9+
install:
10+
- requirements: docs/requirements.txt

CMakeLists.txt

+32
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
11
cmake_minimum_required(VERSION 3.14)
22

33
project(result)
4+
5+
set(CMAKE_CXX_STANDARD 17)
6+
7+
if(MSVC)
8+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive- /W4 /w14640 /EHsc")
9+
else()
10+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wnon-virtual-dtor -Wpedantic")
11+
endif()
12+
13+
add_library(result INTERFACE)
14+
target_include_directories(result INTERFACE include)
15+
16+
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
17+
include(cmake/CPM.cmake)
18+
cpmaddpackage("gh:TheLartians/[email protected]")
19+
20+
if(BUILD_TESTING)
21+
enable_testing()
22+
23+
cpmaddpackage("gh:catchorg/[email protected]")
24+
include("${Catch2_SOURCE_DIR}/extras/Catch.cmake")
25+
26+
if(NOT MSVC)
27+
# set coverage flags (not supported in MSVC)
28+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -fPIC -O0")
29+
endif()
30+
31+
add_executable(result_test test/code_test.cpp test/err_test.cpp test/result_test.cpp test/result_of_test.cpp)
32+
target_link_libraries(result_test PRIVATE result Catch2::Catch2WithMain)
33+
catch_discover_tests(result_test)
34+
endif()
35+
endif()

LICENSE.txt renamed to LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 Alfi Maulana
3+
Copyright (c) 2022-2023 Alfi Maulana
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
# Result
22

3-
A simple C++ alternative of [Abseil Status](https://abseil.io/docs/cpp/guides/status).
3+
[![build status](https://img.shields.io/github/actions/workflow/status/threeal/result/build.yml?branch=main)](https://github.com/threeal/result/actions/workflows/build.yml)
4+
[![test status](https://img.shields.io/github/actions/workflow/status/threeal/result/test.yml?label=test&branch=main)](https://github.com/threeal/result/actions/workflows/test.yml)
5+
[![test results](https://img.shields.io/testspace/pass-ratio/threeal/threeal:result/main)](https://threeal.testspace.com/projects/threeal:result)
6+
[![code coverage](https://img.shields.io/coveralls/github/threeal/result/main)](https://coveralls.io/github/threeal/result)
7+
8+
A simple C++ implementation of [Rust Result](https://doc.rust-lang.org/std/result), an alternative to [Abseil Status](https://abseil.io/docs/cpp/guides/status).
9+
10+
## License
11+
12+
This project is licensed under the terms of the [MIT License](./LICENSE).
13+
14+
Copyright © 2022-2023 [Alfi Maulana](https://github.com/threeal)

cmake/CPM.cmake

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
set(CPM_DOWNLOAD_VERSION 0.36.0)
2+
3+
if(CPM_SOURCE_CACHE)
4+
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
5+
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
6+
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
7+
else()
8+
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
9+
endif()
10+
11+
# Expand relative path. This is important if the provided path contains a tilde (~)
12+
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
13+
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
14+
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
15+
file(DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
16+
${CPM_DOWNLOAD_LOCATION})
17+
endif()
18+
19+
include(${CPM_DOWNLOAD_LOCATION})

docs/Doxyfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
PROJECT_NAME = "Result"
2+
PROJECT_BRIEF= "A simple C++ implementation of Rust Result, an alternative to Abseil Status."
3+
INPUT = ../include
4+
RECURSIVE = YES
5+
EXTRACT_ALL = YES
6+
SORT_MEMBER_DOCS = NO
7+
GENERATE_HTML = NO
8+
GENERATE_LATEX = NO
9+
GENERATE_XML = YES
10+
XML_OUTPUT = _xml

docs/_static/.gitkeep

Whitespace-only changes.

docs/api_docs.rst

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
API Documentation
2+
=================
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
7+
api_docs/result.rst
8+
api_docs/result_of.rst
9+
api_docs/utils.rst

docs/api_docs/result.rst

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Result
2+
======
3+
4+
.. doxygenclass:: res::Result
5+
:members:

docs/api_docs/result_of.rst

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Result of
2+
=========
3+
4+
.. doxygenclass:: res::ResultOf
5+
:members:

docs/api_docs/utilities/error.rst

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Error
2+
=====
3+
4+
.. doxygenstruct:: res::Err
5+
:members:
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Error Stream
2+
============
3+
4+
.. doxygenstruct:: res::ErrStream
5+
:members:

docs/api_docs/utilities/ok.rst

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Ok
2+
===
3+
4+
.. doxygenstruct:: res::Ok
5+
:members:

docs/api_docs/utils.rst

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Utils
2+
=====
3+
4+
.. toctree::
5+
:maxdepth: 1
6+
7+
utilities/ok.rst
8+
utilities/error.rst
9+
utilities/error_stream.rst

docs/conf.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os, subprocess
2+
3+
project = 'result'
4+
copyright = '2022-2023, Alfi Maulana'
5+
author = 'Alfi Maulana'
6+
7+
extensions = ['breathe']
8+
9+
dir_path = os.path.dirname(os.path.realpath(__file__))
10+
subprocess.call('cd %s && doxygen' % dir_path, shell=True)
11+
12+
breathe_projects = {"result": "_xml"}
13+
breathe_default_project = "result"
14+
15+
html_theme = 'sphinx_rtd_theme'
16+
html_static_path = ['_static']

docs/index.rst

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Result
2+
======
3+
4+
|build_status_badge|_ |test_status_badge|_ |test_results_badge|_ |code_coverage_badge|_
5+
6+
A simple C++ implementation of `Rust Result`_, an alternative to `Abseil Status`_.
7+
8+
.. toctree::
9+
:maxdepth: 1
10+
11+
api_docs.rst
12+
license.rst
13+
14+
.. |build_status_badge| image:: https://img.shields.io/github/actions/workflow/status/threeal/result/build.yml?branch=main
15+
.. _build_status_badge: https://github.com/threeal/result/actions/workflows/build.yml
16+
17+
.. |test_status_badge| image:: https://img.shields.io/github/actions/workflow/status/threeal/result/test.yml?label=test&branch=main
18+
.. _test_status_badge: https://github.com/threeal/result/actions/workflows/test.yml
19+
20+
.. |test_results_badge| image:: https://img.shields.io/testspace/pass-ratio/threeal/threeal:result/main
21+
.. _test_results_badge: https://threeal.testspace.com/projects/threeal:result
22+
23+
.. |code_coverage_badge| image:: https://img.shields.io/coveralls/github/threeal/result/main
24+
.. _code_coverage_badge: https://coveralls.io/github/threeal/result
25+
26+
.. _Abseil Status: https://abseil.io/docs/cpp/guides/status
27+
.. _Rust Result: https://doc.rust-lang.org/std/result

docs/license.rst

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
License
2+
=======
3+
4+
.. image:: https://opensource.org/wp-content/uploads/2022/10/osi-badge-dark.svg
5+
:width: 150
6+
:align: right
7+
:target: https://opensource.org/licenses
8+
9+
This project is licensed under the terms of the `MIT License`_.
10+
11+
Copyright © 2022-2023 `Alfi Maulana`_
12+
13+
Permission is hereby granted, free of charge, to any person obtaining a copy
14+
of this software and associated documentation files (the "Software"), to deal
15+
in the Software without restriction, including without limitation the rights
16+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17+
copies of the Software, and to permit persons to whom the Software is
18+
furnished to do so, subject to the following conditions:
19+
20+
The above copyright notice and this permission notice shall be included in all
21+
copies or substantial portions of the Software.
22+
23+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29+
SOFTWARE.
30+
31+
.. _Alfi Maulana: https://github.com/threeal
32+
.. _MIT License: https://opensource.org/licenses/MIT

docs/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
breathe

0 commit comments

Comments
 (0)