forked from mpusz/mp-units
refactor: unit_symbol_formatting
moved to a dedicated header file
This commit is contained in:
@@ -70,6 +70,7 @@ add_mp_units_module(
|
|||||||
include/mp-units/framework/system_reference.h
|
include/mp-units/framework/system_reference.h
|
||||||
include/mp-units/framework/unit.h
|
include/mp-units/framework/unit.h
|
||||||
include/mp-units/framework/unit_concepts.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/framework/value_cast.h
|
||||||
include/mp-units/compat_macros.h
|
include/mp-units/compat_macros.h
|
||||||
include/mp-units/concepts.h
|
include/mp-units/concepts.h
|
||||||
|
@@ -43,5 +43,6 @@
|
|||||||
#include <mp-units/framework/system_reference.h>
|
#include <mp-units/framework/system_reference.h>
|
||||||
#include <mp-units/framework/unit.h>
|
#include <mp-units/framework/unit.h>
|
||||||
#include <mp-units/framework/unit_concepts.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/framework/value_cast.h>
|
||||||
// IWYU pragma: end_exports
|
// IWYU pragma: end_exports
|
||||||
|
@@ -40,6 +40,7 @@
|
|||||||
#include <mp-units/framework/quantity_spec_concepts.h>
|
#include <mp-units/framework/quantity_spec_concepts.h>
|
||||||
#include <mp-units/framework/symbol_text.h>
|
#include <mp-units/framework/symbol_text.h>
|
||||||
#include <mp-units/framework/unit_concepts.h>
|
#include <mp-units/framework/unit_concepts.h>
|
||||||
|
#include <mp-units/framework/unit_symbol_formatting.h>
|
||||||
|
|
||||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||||
#include <mp-units/ext/contracts.h>
|
#include <mp-units/ext/contracts.h>
|
||||||
@@ -757,29 +758,6 @@ constexpr bool space_before_unit_symbol = true;
|
|||||||
template<>
|
template<>
|
||||||
MP_UNITS_INLINE constexpr bool space_before_unit_symbol<one> = false;
|
MP_UNITS_INLINE constexpr bool space_before_unit_symbol<one> = 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
|
MP_UNITS_EXPORT_END
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
61
src/core/include/mp-units/framework/unit_symbol_formatting.h
Normal file
61
src/core/include/mp-units/framework/unit_symbol_formatting.h
Normal file
@@ -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 <mp-units/framework.h>
|
||||||
|
#include <mp-units/bits/module_macros.h>
|
||||||
|
#include <mp-units/framework/symbol_text.h>
|
||||||
|
|
||||||
|
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||||
|
#ifdef MP_UNITS_IMPORT_STD
|
||||||
|
import std;
|
||||||
|
#else
|
||||||
|
#include <cstdint>
|
||||||
|
#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
|
Reference in New Issue
Block a user