diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ffbfc17b..6d558ffe 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -70,6 +70,7 @@ add_mp_units_module( include/mp-units/framework/system_reference.h include/mp-units/framework/unit.h include/mp-units/framework/unit_concepts.h + include/mp-units/framework/unit_symbol_formatting.h include/mp-units/framework/value_cast.h include/mp-units/compat_macros.h include/mp-units/concepts.h diff --git a/src/core/include/mp-units/framework.h b/src/core/include/mp-units/framework.h index b20b322a..0e9d4d19 100644 --- a/src/core/include/mp-units/framework.h +++ b/src/core/include/mp-units/framework.h @@ -43,5 +43,6 @@ #include #include #include +#include #include // IWYU pragma: end_exports diff --git a/src/core/include/mp-units/framework/unit.h b/src/core/include/mp-units/framework/unit.h index 233f892c..e4a79f14 100644 --- a/src/core/include/mp-units/framework/unit.h +++ b/src/core/include/mp-units/framework/unit.h @@ -40,6 +40,7 @@ #include #include #include +#include #ifndef MP_UNITS_IN_MODULE_INTERFACE #include @@ -757,29 +758,6 @@ constexpr bool space_before_unit_symbol = true; template<> MP_UNITS_INLINE constexpr bool space_before_unit_symbol = false; -// get_unit_symbol - -// NOLINTNEXTLINE(readability-enum-initial-value) -enum class unit_symbol_solidus : std::int8_t { - one_denominator, // m/s; kg m⁻¹ s⁻¹ - always, // m/s; kg/(m s) - never, // m s⁻¹; kg m⁻¹ s⁻¹ - default_denominator = one_denominator -}; - -// NOLINTNEXTLINE(readability-enum-initial-value) -enum class unit_symbol_separator : std::int8_t { - space, // kg m²/s² - half_high_dot, // kg⋅m²/s² (valid only for unicode encoding) - default_separator = space -}; - -struct unit_symbol_formatting { - text_encoding encoding = text_encoding::default_encoding; - unit_symbol_solidus solidus = unit_symbol_solidus::default_denominator; - unit_symbol_separator separator = unit_symbol_separator::default_separator; -}; - MP_UNITS_EXPORT_END namespace detail { diff --git a/src/core/include/mp-units/framework/unit_symbol_formatting.h b/src/core/include/mp-units/framework/unit_symbol_formatting.h new file mode 100644 index 00000000..422d512f --- /dev/null +++ b/src/core/include/mp-units/framework/unit_symbol_formatting.h @@ -0,0 +1,61 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +// IWYU pragma: private, include +#include +#include + +#ifndef MP_UNITS_IN_MODULE_INTERFACE +#ifdef MP_UNITS_IMPORT_STD +import std; +#else +#include +#endif +#endif + +MP_UNITS_EXPORT +namespace mp_units { + +// NOLINTNEXTLINE(readability-enum-initial-value) +enum class unit_symbol_solidus : std::int8_t { + one_denominator, // m/s; kg m⁻¹ s⁻¹ + always, // m/s; kg/(m s) + never, // m s⁻¹; kg m⁻¹ s⁻¹ + default_denominator = one_denominator +}; + +// NOLINTNEXTLINE(readability-enum-initial-value) +enum class unit_symbol_separator : std::int8_t { + space, // kg m²/s² + half_high_dot, // kg⋅m²/s² (valid only for unicode encoding) + default_separator = space +}; + +struct unit_symbol_formatting { + text_encoding encoding = text_encoding::default_encoding; + unit_symbol_solidus solidus = unit_symbol_solidus::default_denominator; + unit_symbol_separator separator = unit_symbol_separator::default_separator; +}; + +} // namespace mp_units