From d36829994f3c036127b9d2794461615e42633aa3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 24 May 2024 10:17:56 -0400 Subject: [PATCH] xo-unit: ++ xquantity docs --- docs/CMakeLists.txt | 2 +- docs/quantity-class.rst | 4 ++-- docs/quantity-source-code.rst | 4 ++-- docs/xquantity-class.rst | 12 ++++++++++++ docs/xquantity-reference.rst | 1 + docs/xquantity-source-code.rst | 11 +++++++++++ include/xo/unit/xquantity.hpp | 16 ++++++++++++++++ 7 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 docs/xquantity-source-code.rst diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 9dd4af88..5e986aa8 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -5,7 +5,7 @@ xo_docdir_doxygen_config() xo_docdir_sphinx_config( index.rst examples.rst glossary.rst install.rst implementation.rst quantity-reference.rst quantity-class.rst quantity-factoryfunctions.rst quantity-unitvars.rst quantity-source-code.rst - xquantity-reference.rst xquantity-class.rst + xquantity-reference.rst xquantity-class.rst xquantity-source-code.rst scaled-unit-reference.rst scaled-unit-class.rst scaled-unit-constants.rst natural-unit-class.rst bpu-class.rst diff --git a/docs/quantity-class.rst b/docs/quantity-class.rst index fd9006e3..2262c845 100644 --- a/docs/quantity-class.rst +++ b/docs/quantity-class.rst @@ -127,8 +127,8 @@ Amount-preserving conversion to quantities with different units and/or represent .. doxygengroup:: quantity-unit-conversion -Arithmetic Operators --------------------- +Arithmetic +---------- .. doxygengroup:: quantity-operators diff --git a/docs/quantity-source-code.rst b/docs/quantity-source-code.rst index 4461ee13..bdc2a7fd 100644 --- a/docs/quantity-source-code.rst +++ b/docs/quantity-source-code.rst @@ -3,9 +3,9 @@ Quantity Source Code ==================== -github: `quantity.hpp @github.com`_ +github: `quantity.hpp @github`_ -.. _`quantity.hpp @github.com`: https://github.com/rconybea/xo-unit/blob/main/include/xo/unit/quantity.hpp +.. _`quantity.hpp @github`: https://github.com/rconybea/xo-unit/blob/main/include/xo/unit/quantity.hpp .. literalinclude:: ../include/xo/unit/quantity.hpp :language: c++ diff --git a/docs/xquantity-class.rst b/docs/xquantity-class.rst index abd48fd1..6f1b1cf9 100644 --- a/docs/xquantity-class.rst +++ b/docs/xquantity-class.rst @@ -69,7 +69,19 @@ Access Methods .. doxygengroup:: xquantity-access-methods +Constants +--------- + +.. doxygengroup:: xquantity-constants + General Methods --------------- .. doxygengroup:: xquantity-methods + +Arithmetic +---------- + +Support methods for arithmetic operations + +.. doxygengroup:: xquantity-arithmetic-support diff --git a/docs/xquantity-reference.rst b/docs/xquantity-reference.rst index c3ee4760..2d34cee3 100644 --- a/docs/xquantity-reference.rst +++ b/docs/xquantity-reference.rst @@ -26,3 +26,4 @@ Xquantity Reference :maxdepth: 2 xquantity-class + xquantity-source-code diff --git a/docs/xquantity-source-code.rst b/docs/xquantity-source-code.rst new file mode 100644 index 00000000..5746b0e7 --- /dev/null +++ b/docs/xquantity-source-code.rst @@ -0,0 +1,11 @@ +.. _xquantity-source-code: + +Xquantity Source Code +===================== + +github: `xquantity.hpp @github`_ + +.. _`xquantity.hpp @github`: https://github.com/rconybea/xo-unit/blob/main/include/xo/unit/xquantity.hpp + +.. literalinclude:: ../include/xo/unit/xquantity.hpp + :language: c++ diff --git a/include/xo/unit/xquantity.hpp b/include/xo/unit/xquantity.hpp index 40ada9d0..3a2f1031 100644 --- a/include/xo/unit/xquantity.hpp +++ b/include/xo/unit/xquantity.hpp @@ -86,8 +86,16 @@ namespace xo { ///@} + /** defgroup xqautnity-constants static xquantity constants **/ + ///@{ + + /** false since unit information may be unknown at compile time. + * Coordinates with quantity::always_constexpr_unit + **/ static constexpr bool always_constexpr_unit = false; + ///@} + /** @defgroup xquantity-access-methods xquantity access methods **/ ///@{ @@ -107,6 +115,9 @@ namespace xo { /** @defgroup xquantity-methods xquantity methods **/ ///@{ + /** @defgroup xquantity-arithmetic-support **/ + ///@{ + /** create unit quantity with same unit as @c this **/ constexpr xquantity unit_qty() const { return xquantity(1, unit_); } @@ -116,6 +127,11 @@ namespace xo { /** create quantity representing reciprocal of @c this **/ constexpr xquantity reciprocal() const { return xquantity(1.0 / scale_, unit_.reciprocal()); } + ///@} + + /** @defgroup xquantity-methods xquantity methods **/ + ///@{ + /** create quantity representing the same value, but in units of @p unit2 **/ constexpr auto rescale(const natural_unit & unit2) const {