mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-29 18:07:16 +02:00
refactor: core-fmt
and core-ostream
modules merged with core
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
along with this program. If not, see http://www.gnu.org/licenses./
|
||||
*/
|
||||
|
||||
#include <mp-units/compat_fmt_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <iostream>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
|
@ -15,7 +15,7 @@
|
||||
along with this program. If not, see http://www.gnu.org/licenses./
|
||||
*/
|
||||
|
||||
#include <mp-units/compat_fmt_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <iostream>
|
||||
#include <type_traits>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units.core_io;
|
||||
import mp_units.core;
|
||||
#else
|
||||
#include <mp-units/ostream.h>
|
||||
#include <mp-units/quantity.h>
|
||||
|
@ -20,7 +20,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <mp-units/compat_fmt_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <iostream>
|
||||
#include <string_view>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
|
@ -21,7 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "glide_computer_lib.h"
|
||||
#include <mp-units/compat_fmt_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <array>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
|
@ -25,7 +25,7 @@
|
||||
// !!! renders correctly in the documentation "Examples" section. !!!
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
#include <mp-units/compat_fmt_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <iostream>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
|
@ -23,7 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "ranged_representation.h"
|
||||
#include <mp-units/compat_fmt_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <compare>
|
||||
#include <limits>
|
||||
#include <numbers>
|
||||
|
@ -23,7 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
#include <mp-units/compat_fmt_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <ostream>
|
||||
#include <utility>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/compat_fmt_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <tuple>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
|
@ -25,7 +25,7 @@
|
||||
// !!! renders correctly in the documentation "Examples" section. !!!
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
#include <mp-units/compat_fmt_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <iostream>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
|
@ -20,7 +20,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <mp-units/compat_fmt_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <iostream>
|
||||
#include <tuple>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
|
@ -20,7 +20,6 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <mp-units/compat_fmt_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
|
@ -21,7 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "geographic.h"
|
||||
#include <mp-units/compat_fmt_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
|
@ -47,13 +47,11 @@ if(${projectPrefix}AS_SYSTEM_HEADERS)
|
||||
endif()
|
||||
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(core-fmt)
|
||||
add_subdirectory(core-io)
|
||||
add_subdirectory(systems)
|
||||
|
||||
# project-wide wrapper
|
||||
add_units_module(
|
||||
mp-units DEPENDENCIES mp-units::core mp-units::core-io mp-units::core-fmt mp-units::systems
|
||||
mp-units DEPENDENCIES mp-units::core mp-units::systems
|
||||
MODULE_INTERFACE_UNIT mp-units.cpp
|
||||
)
|
||||
|
||||
|
@ -1,43 +0,0 @@
|
||||
# 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.
|
||||
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
option(${projectPrefix}USE_LIBFMT "Enables usage of libfmt instead of the one from 'std'" ON)
|
||||
message(STATUS "${projectPrefix}USE_LIBFMT: ${${projectPrefix}USE_LIBFMT}")
|
||||
|
||||
add_units_module(
|
||||
core-fmt
|
||||
DEPENDENCIES mp-units::core
|
||||
HEADERS include/mp-units/bits/fmt.h include/mp-units/compat_fmt_macros.h include/mp-units/format.h
|
||||
MODULE_INTERFACE_UNIT mp-units-core-fmt.cpp
|
||||
)
|
||||
target_compile_definitions(
|
||||
mp-units-core-fmt ${${projectPrefix}TARGET_SCOPE} ${projectPrefix}USE_LIBFMT=$<BOOL:${${projectPrefix}USE_LIBFMT}>
|
||||
)
|
||||
|
||||
if(${projectPrefix}USE_LIBFMT)
|
||||
if(NOT TARGET fmt::fmt)
|
||||
find_package(fmt CONFIG REQUIRED)
|
||||
endif()
|
||||
target_link_libraries(mp-units-core-fmt ${${projectPrefix}TARGET_SCOPE} fmt::fmt)
|
||||
endif()
|
@ -1,79 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// Formatting library for C++ - the core API for char/UTF-8
|
||||
//
|
||||
// Copyright (c) 2012 - present, Victor Zverovich
|
||||
// All rights reserved.
|
||||
//
|
||||
// For the license information refer to format.h.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/external/hacks.h>
|
||||
|
||||
#ifndef MP_UNITS_USE_LIBFMT
|
||||
#define MP_UNITS_USE_LIBFMT 1
|
||||
#endif
|
||||
|
||||
#if MP_UNITS_USE_LIBFMT
|
||||
|
||||
MP_UNITS_DIAGNOSTIC_PUSH
|
||||
MP_UNITS_DIAGNOSTIC_IGNORE_UNREACHABLE
|
||||
MP_UNITS_DIAGNOSTIC_IGNORE_SHADOW
|
||||
#include <fmt/format.h>
|
||||
MP_UNITS_DIAGNOSTIC_POP
|
||||
|
||||
#define MP_UNITS_STD_FMT fmt
|
||||
#define MP_UNITS_FMT_LOCALE(loc) (loc).template get<std::locale>()
|
||||
#define MP_UNITS_FMT_TO_ARG_ID(arg) static_cast<int>(arg)
|
||||
#define MP_UNITS_FMT_FROM_ARG_ID(arg) static_cast<size_t>(arg)
|
||||
|
||||
// This re-uses code from fmt;
|
||||
#if FMT_EXCEPTIONS
|
||||
#if FMT_MSC_VERSION || defined(__NVCC__)
|
||||
#define MP_UNITS_THROW(x) ::fmt::detail::do_throw(x)
|
||||
#else
|
||||
#define MP_UNITS_THROW(x) throw x
|
||||
#endif
|
||||
#else
|
||||
#define MP_UNITS_THROW(x) \
|
||||
do { \
|
||||
FMT_ASSERT(false, (x).what()); \
|
||||
} while (false)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifndef __cpp_lib_format
|
||||
#error "std::formatting facility not supported"
|
||||
#endif
|
||||
|
||||
#include <format>
|
||||
|
||||
#define MP_UNITS_STD_FMT std
|
||||
#define MP_UNITS_FMT_LOCALE(loc) loc
|
||||
#define MP_UNITS_FMT_TO_ARG_ID(arg) arg
|
||||
#define MP_UNITS_FMT_FROM_ARG_ID(arg) arg
|
||||
#define MP_UNITS_THROW(arg) throw arg
|
||||
|
||||
#endif
|
@ -1,13 +0,0 @@
|
||||
module;
|
||||
|
||||
#include <mp-units/bits/core_gmf.h>
|
||||
#include <mp-units/compat_fmt_macros.h>
|
||||
|
||||
export module mp_units.core_fmt;
|
||||
|
||||
export import mp_units.core;
|
||||
|
||||
export
|
||||
{
|
||||
#include <mp-units/format.h>
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
# 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.
|
||||
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
add_units_module(
|
||||
core-io
|
||||
DEPENDENCIES mp-units::core
|
||||
HEADERS include/mp-units/ostream.h
|
||||
MODULE_INTERFACE_UNIT mp-units-core-io.cpp
|
||||
)
|
@ -1,13 +0,0 @@
|
||||
module;
|
||||
|
||||
#include <mp-units/bits/core_gmf.h>
|
||||
#include <sstream>
|
||||
|
||||
export module mp_units.core_io;
|
||||
|
||||
export import mp_units.core;
|
||||
|
||||
export
|
||||
{
|
||||
#include <mp-units/ostream.h>
|
||||
}
|
@ -42,6 +42,7 @@ add_units_module(
|
||||
include/mp-units/bits/core_gmf.h
|
||||
include/mp-units/bits/dimension_concepts.h
|
||||
include/mp-units/bits/expression_template.h
|
||||
include/mp-units/bits/fmt.h
|
||||
include/mp-units/bits/get_associated_quantity.h
|
||||
include/mp-units/bits/get_common_base.h
|
||||
include/mp-units/bits/magnitude.h
|
||||
@ -63,7 +64,9 @@ add_units_module(
|
||||
include/mp-units/core.h
|
||||
include/mp-units/customization_points.h
|
||||
include/mp-units/dimension.h
|
||||
include/mp-units/format.h
|
||||
include/mp-units/math.h
|
||||
include/mp-units/ostream.h
|
||||
include/mp-units/quantity.h
|
||||
include/mp-units/quantity_point.h
|
||||
include/mp-units/quantity_spec.h
|
||||
@ -74,6 +77,17 @@ add_units_module(
|
||||
MODULE_INTERFACE_UNIT mp-units-core.cpp
|
||||
)
|
||||
|
||||
target_compile_definitions(
|
||||
mp-units-core ${${projectPrefix}TARGET_SCOPE} ${projectPrefix}USE_LIBFMT=$<BOOL:${${projectPrefix}USE_LIBFMT}>
|
||||
)
|
||||
|
||||
if(${projectPrefix}USE_LIBFMT)
|
||||
if(NOT TARGET fmt::fmt)
|
||||
find_package(fmt CONFIG REQUIRED)
|
||||
endif()
|
||||
target_link_libraries(mp-units-core ${${projectPrefix}TARGET_SCOPE} fmt::fmt)
|
||||
endif()
|
||||
|
||||
if(${projectPrefix}BUILD_CXX_MODULES)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18)
|
||||
|
47
src/core/include/mp-units/bits/external/hacks.h
vendored
47
src/core/include/mp-units/bits/external/hacks.h
vendored
@ -99,3 +99,50 @@
|
||||
#define MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(X) X
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef MP_UNITS_USE_LIBFMT
|
||||
#define MP_UNITS_USE_LIBFMT 1
|
||||
#endif
|
||||
|
||||
#if MP_UNITS_USE_LIBFMT
|
||||
|
||||
MP_UNITS_DIAGNOSTIC_PUSH
|
||||
MP_UNITS_DIAGNOSTIC_IGNORE_UNREACHABLE
|
||||
MP_UNITS_DIAGNOSTIC_IGNORE_SHADOW
|
||||
#include <fmt/format.h>
|
||||
MP_UNITS_DIAGNOSTIC_POP
|
||||
|
||||
#define MP_UNITS_STD_FMT fmt
|
||||
#define MP_UNITS_FMT_LOCALE(loc) (loc).template get<std::locale>()
|
||||
#define MP_UNITS_FMT_TO_ARG_ID(arg) static_cast<int>(arg)
|
||||
#define MP_UNITS_FMT_FROM_ARG_ID(arg) static_cast<size_t>(arg)
|
||||
|
||||
// This re-uses code from fmt;
|
||||
#if FMT_EXCEPTIONS
|
||||
#if FMT_MSC_VERSION || defined(__NVCC__)
|
||||
#define MP_UNITS_THROW(x) ::fmt::detail::do_throw(x)
|
||||
#else
|
||||
#define MP_UNITS_THROW(x) throw x
|
||||
#endif
|
||||
#else
|
||||
#define MP_UNITS_THROW(x) \
|
||||
do { \
|
||||
FMT_ASSERT(false, (x).what()); \
|
||||
} while (false)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifndef __cpp_lib_format
|
||||
#error "std::formatting facility not supported"
|
||||
#endif
|
||||
|
||||
#include <format>
|
||||
|
||||
#define MP_UNITS_STD_FMT std
|
||||
#define MP_UNITS_FMT_LOCALE(loc) loc
|
||||
#define MP_UNITS_FMT_TO_ARG_ID(arg) arg
|
||||
#define MP_UNITS_FMT_FROM_ARG_ID(arg) arg
|
||||
#define MP_UNITS_THROW(arg) throw arg
|
||||
|
||||
#endif
|
||||
|
@ -30,7 +30,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
#include <mp-units/compat_fmt_macros.h>
|
||||
#include <mp-units/bits/external/hacks.h>
|
||||
#include <concepts>
|
||||
#include <limits>
|
||||
#include <string_view>
|
@ -27,7 +27,9 @@
|
||||
#include <mp-units/concepts.h>
|
||||
#include <mp-units/customization_points.h>
|
||||
#include <mp-units/dimension.h>
|
||||
#include <mp-units/format.h>
|
||||
#include <mp-units/math.h>
|
||||
#include <mp-units/ostream.h>
|
||||
#include <mp-units/quantity.h>
|
||||
#include <mp-units/quantity_point.h>
|
||||
#include <mp-units/quantity_spec.h>
|
||||
|
@ -21,7 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include <catch2/matchers/catch_matchers_templated.hpp>
|
||||
#include <mp-units/compat_fmt_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <algorithm>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
import mp_units;
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/matchers/catch_matchers_exception.hpp>
|
||||
#include <mp-units/compat_fmt_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <locale>
|
||||
|
@ -21,7 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <mp-units/compat_fmt_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
#include <cmath>
|
||||
#include <matrix>
|
||||
#ifdef MP_UNITS_MODULES
|
||||
|
Reference in New Issue
Block a user