diff --git a/docs/Doxyfile b/docs/Doxyfile index ecb9b34..5c4148e 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -42,7 +42,7 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "Result C++" +PROJECT_NAME = "result" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version @@ -54,7 +54,7 @@ PROJECT_NUMBER = 0.0.1 # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. -PROJECT_BRIEF = "A modern C++ Result type inspired by Rust" +PROJECT_BRIEF = "A C++ result type inspired by Rust" # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 @@ -943,7 +943,7 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = src +INPUT = result.h # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/result.h b/result.h index 02bd3fe..32f76c5 100644 --- a/result.h +++ b/result.h @@ -1,11 +1,15 @@ -/// result 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. +/// @file +/// @brief result 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. /// -/// author: GregoryKogan -/// My github page: https://github.com/GregoryKogan -/// version: 0.0.0 -/// date: 2023, December 21 +/// This file contains the declaration of the Result class template. +/// @author GregoryKogan +/// @version 0.0.1 +/// @date 2023, December 21 +/// @par License /// This software is released under the GNU GENERAL PUBLIC LICENSE Version 3. +/// @par Contact +/// My github page: https://github.com/GregoryKogan #ifndef RESULT_LIB #define RESULT_LIB @@ -18,6 +22,9 @@ namespace res { template class result; template class result; +/// @brief Err object represents an unsuccessful outcome and can be implicitly converted to a result. +/// @details Err object holds an error of type E. Err object can't be empty, E must not be std::monostate. +/// @tparam E Type of the error. template class err { E error_; @@ -41,6 +48,9 @@ namespace res { template class result; template class result; +/// @brief Ok object represents a successful outcome and can be implicitly converted to a result. +/// @details Ok object holds a value of type T. Empty Ok object can be created if T is std::monostate. +/// @tparam T Type of the value. Defaults to std::monostate. template class ok { T value_; @@ -62,6 +72,12 @@ template template inline ok::operator result is the type used for returning and propagating errors. It holds either a successful value of type T or +/// an error of type E. +/// @tparam T +/// @tparam E template class result { static_assert(!std::is_same_v, "T (value type) must not be void"); static_assert(!std::is_same_v, "E (error type) must not be void"); @@ -85,7 +101,7 @@ template class result { [[nodiscard]] auto error() const -> const E &; }; -// result class specialization for void value type +/// @brief `result` class specialization for void value type. template class result { static_assert(!std::is_same_v, "E (error type) must not be void"); diff --git a/src/err/err.hpp b/src/err/err.hpp index dd827fd..4cfe739 100644 --- a/src/err/err.hpp +++ b/src/err/err.hpp @@ -5,6 +5,9 @@ namespace res { template class result; template class result; +/// @brief Err object represents an unsuccessful outcome and can be implicitly converted to a result. +/// @details Err object holds an error of type E. Err object can't be empty, E must not be std::monostate. +/// @tparam E Type of the error. template class err { E error_; diff --git a/src/ok/ok.hpp b/src/ok/ok.hpp index 0dd409e..4f9b530 100644 --- a/src/ok/ok.hpp +++ b/src/ok/ok.hpp @@ -7,6 +7,9 @@ namespace res { template class result; template class result; +/// @brief Ok object represents a successful outcome and can be implicitly converted to a result. +/// @details Ok object holds a value of type T. Empty Ok object can be created if T is std::monostate. +/// @tparam T Type of the value. Defaults to std::monostate. template class ok { T value_; diff --git a/src/result-wrapper.h b/src/result-wrapper.h index fbf9b03..a273597 100644 --- a/src/result-wrapper.h +++ b/src/result-wrapper.h @@ -1,11 +1,15 @@ -/// result 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. +/// @file +/// @brief result 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. /// -/// author: GregoryKogan -/// My github page: https://github.com/GregoryKogan -/// version: 0.0.0 -/// date: 2023, December 21 +/// This file contains the declaration of the Result class template. +/// @author GregoryKogan +/// @version 0.0.1 +/// @date 2023, December 21 +/// @par License /// This software is released under the GNU GENERAL PUBLIC LICENSE Version 3. +/// @par Contact +/// My github page: https://github.com/GregoryKogan #ifndef RESULT_LIB #define RESULT_LIB diff --git a/src/result/result.hpp b/src/result/result.hpp index 7276a43..0ac3d50 100644 --- a/src/result/result.hpp +++ b/src/result/result.hpp @@ -8,6 +8,12 @@ namespace res { +/// @brief `result` is a type that represents either success or failure. +/// +/// result is the type used for returning and propagating errors. It holds either a successful value of type T or +/// an error of type E. +/// @tparam T +/// @tparam E template class result { static_assert(!std::is_same_v, "T (value type) must not be void"); static_assert(!std::is_same_v, "E (error type) must not be void"); @@ -31,7 +37,7 @@ template class result { [[nodiscard]] auto error() const -> const E &; }; -// result class specialization for void value type +/// @brief `result` class specialization for void value type. template class result { static_assert(!std::is_same_v, "E (error type) must not be void");