diff --git a/.gitignore b/.gitignore index f7ea44e..2718d9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build docs +doxygen-awesome-css .vscode .DS_Store \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..d8da1e4 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "doxygen-awesome-css"] + path = doxygen-awesome-css + url = https://github.com/jothepro/doxygen-awesome-css.git diff --git a/Doxyfile b/Doxyfile index 1c951f7..8677429 100644 --- a/Doxyfile +++ b/Doxyfile @@ -1158,7 +1158,8 @@ FILTER_SOURCE_PATTERNS = # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. -USE_MDFILE_AS_MAINPAGE = +INPUT += README.md +USE_MDFILE_AS_MAINPAGE = README.md # The Fortran standard specifies that for fixed formatted Fortran code all # characters from position 72 are to be considered as comment. A common @@ -1357,7 +1358,8 @@ HTML_STYLESHEET = # documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_EXTRA_STYLESHEET = +HTML_EXTRA_STYLESHEET = doxygen-awesome-css/doxygen-awesome.css \ + doxygen-awesome-css/doxygen-awesome-sidebar-only.css # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note @@ -1380,7 +1382,7 @@ HTML_EXTRA_FILES = # The default value is: AUTO_LIGHT. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_COLORSTYLE = AUTO_LIGHT +HTML_COLORSTYLE = LIGHT # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to @@ -1688,7 +1690,7 @@ DISABLE_INDEX = NO # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. -GENERATE_TREEVIEW = NO +GENERATE_TREEVIEW = YES # When both GENERATE_TREEVIEW and DISABLE_INDEX are set to YES, then the # FULL_SIDEBAR option determines if the side bar is limited to only the treeview diff --git a/README.md b/README.md index 09e5b6a..7509d36 100644 --- a/README.md +++ b/README.md @@ -1 +1,35 @@ # result-cpp + +Result-CPP is a C++ library that provides a `Result` type, which can be used to return and propagate errors. It's inspired by Rust's `std::Result` type. + +## Features + +- `Result` type for returning and propagating errors. +- `Ok` and `Err` static methods for creating successful and unsuccessful `Result` objects respectively. +- `is_ok` and `is_err` methods for checking if the `Result` is successful or unsuccessful. +- `unwrap` and `unwrap_err` methods for extracting the value or error from the `Result`. + +## Usage + +```cpp +#include +#include "result.h" + +res::Result divide(int a, int b) { + if (b == 0) { + return res::Result::Err("Division by zero"); + } else { + return res::Result::Ok(a / b); + } +} + +int main() { + auto result = divide(10, 2); + + if (result.is_ok()) { + std::cout << "Result: " << result.unwrap() << '\n'; + } else { + std::cout << "Error: " << result.unwrap_err() << '\n'; + } +} +```