[med-svn] [Git][med-team/libmcfp][upstream] New upstream version 1.2.3
Maarten L. Hekkelman (@mhekkel-guest)
gitlab at salsa.debian.org
Thu Feb 2 10:15:22 GMT 2023
Maarten L. Hekkelman pushed to branch upstream at Debian Med / libmcfp
Commits:
2938e41e by Maarten L. Hekkelman at 2023-02-02T10:31:05+01:00
New upstream version 1.2.3
- - - - -
7 changed files:
- .gitignore
- CMakeLists.txt
- README.md
- changelog
- include/mcfp/mcfp.hpp
- include/mcfp/text.hpp
- test/unit-test.cpp
Changes:
=====================================
.gitignore
=====================================
@@ -1,2 +1,3 @@
build
.vscode
+cmake/libmcfpConfig.cmake
=====================================
CMakeLists.txt
=====================================
@@ -25,7 +25,7 @@
cmake_minimum_required(VERSION 3.16)
# set the project name
-project(libmcfp VERSION 1.2.2 LANGUAGES CXX)
+project(libmcfp VERSION 1.2.3 LANGUAGES CXX)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
@@ -47,18 +47,21 @@ if(MSVC)
# make msvc standards compliant...
add_compile_options(/permissive-)
- macro(get_WIN32_WINNT version)
- if(WIN32 AND CMAKE_SYSTEM_VERSION)
- set(ver ${CMAKE_SYSTEM_VERSION})
- string(REPLACE "." "" ver ${ver})
- string(REGEX REPLACE "([0-9])" "0\\1" ver ${ver})
-
- set(${version} "0x${ver}")
- endif()
- endmacro()
-
- get_WIN32_WINNT(ver)
- add_definitions(-D_WIN32_WINNT=${ver})
+ if(${CMAKE_SYSTEM_VERSION} GREATER_EQUAL 10) # Windows 10
+ add_definitions(-D _WIN32_WINNT=0x0A00)
+ elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.3) # Windows 8.1
+ add_definitions(-D _WIN32_WINNT=0x0603)
+ elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.2) # Windows 8
+ add_definitions(-D _WIN32_WINNT=0x0602)
+ elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.1) # Windows 7
+ add_definitions(-D _WIN32_WINNT=0x0601)
+ elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.0) # Windows Vista
+ add_definitions(-D _WIN32_WINNT=0x0600)
+ else() # Windows XP (5.1)
+ add_definitions(-D _WIN32_WINNT=0x0501)
+ endif()
+
+ add_definitions(-DNOMINMAX)
endif()
add_library(libmcfp INTERFACE)
@@ -105,7 +108,7 @@ endif()
configure_package_config_file(
${PROJECT_SOURCE_DIR}/cmake/libmcfpConfig.cmake.in
- ${PROJECT_SOURCE_DIR}/cmake/libmcfpConfig.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/libmcfpConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libmcfp
PATH_VARS INCLUDE_INSTALL_DIR
)
@@ -116,15 +119,17 @@ install(EXPORT libmcfpConfig
DESTINATION ${CONFIG_LOC})
install(
- FILES cmake/libmcfpConfig.cmake "${version_config}"
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/libmcfpConfig.cmake "${version_config}"
DESTINATION ${CONFIG_LOC})
if(ENABLE_TESTING)
enable_testing()
+ find_package(Boost REQUIRED)
+
add_executable(libmcfp-unit-test ${PROJECT_SOURCE_DIR}/test/unit-test.cpp)
- target_link_libraries(libmcfp-unit-test libmcfp::libmcfp)
+ target_link_libraries(libmcfp-unit-test libmcfp::libmcfp Boost::boost)
if(MSVC)
# Specify unwind semantics so that MSVC knowns how to handle exceptions
=====================================
README.md
=====================================
@@ -115,3 +115,18 @@ int main(int argc, char * const argv[])
return 0;
}
```
+
+## Installation
+
+Use [cmake](https://cmake.org/) to install _libmcfp_.
+
+```bash
+git clone https://github.com/mhekkel/libmcfp.git
+cd libmcfp
+mkdir build
+cd build
+cmake ..
+cmake --build .
+cmake --install .
+```
+
=====================================
changelog
=====================================
@@ -1,3 +1,6 @@
+Version 1.2.3
+- MSVC compatibility
+
Version 1.2.2
- Added a non-throwing get
- Added extended example code
=====================================
include/mcfp/mcfp.hpp
=====================================
@@ -94,7 +94,7 @@ class config_category_impl : public std::error_category
}
}
- bool equivalent(const std::error_code &code, int condition) const noexcept override
+ bool equivalent(const std::error_code &/*code*/, int /*condition*/) const noexcept override
{
return false;
}
@@ -137,9 +137,9 @@ struct is_container_type : std::false_type
template <typename T>
struct is_container_type<T,
std::enable_if_t<
- std::experimental::is_detected_v<value_type_t, T> and
- std::experimental::is_detected_v<iterator_t, T> and
- not std::experimental::is_detected_v<std_string_npos_t, T>>> : std::true_type
+ is_detected_v<value_type_t, T> and
+ is_detected_v<iterator_t, T> and
+ not is_detected_v<std_string_npos_t, T>>> : std::true_type
{
};
@@ -166,7 +166,7 @@ namespace detail
static value_type set_value(std::string_view argument, std::error_code &ec)
{
value_type value{};
- auto r = charconv<value_type>::from_chars(argument.begin(), argument.end(), value);
+ auto r = charconv<value_type>::from_chars(argument.data(), argument.data() + argument.length(), value);
if (r.ec != std::errc())
ec = std::make_error_code(r.ec);
return value;
@@ -187,7 +187,7 @@ namespace detail
{
using value_type = std::filesystem::path;
- static value_type set_value(std::string_view argument, std::error_code &ec)
+ static value_type set_value(std::string_view argument, std::error_code &/*ec*/)
{
return value_type{ argument };
}
@@ -203,7 +203,7 @@ namespace detail
{
using value_type = std::string;
- static value_type set_value(std::string_view argument, std::error_code &ec)
+ static value_type set_value(std::string_view argument, std::error_code &/*ec*/)
{
return value_type{ argument };
}
@@ -249,7 +249,7 @@ namespace detail
virtual ~option_base() = default;
- virtual void set_value(std::string_view value, std::error_code &ec)
+ virtual void set_value(std::string_view /*value*/, std::error_code &/*ec*/)
{
assert(false);
}
@@ -264,9 +264,9 @@ namespace detail
return {};
}
- uint32_t width() const
+ size_t width() const
{
- uint32_t result = m_name.length();
+ size_t result = m_name.length();
if (result <= 1)
result = 2;
else if (m_short_name != 0)
@@ -280,12 +280,12 @@ namespace detail
return result + 6;
}
- void write(std::ostream &os, uint32_t width) const
+ void write(std::ostream &os, size_t width) const
{
if (m_hidden) // quick exit
return;
- uint32_t w2 = 2;
+ size_t w2 = 2;
os << " ";
if (m_short_name)
{
@@ -499,7 +499,7 @@ class config
{
result = std::any_cast<T>(value);
}
- catch (const std::bad_cast &ex)
+ catch (const std::bad_cast &)
{
ec = make_error_code(config_error::wrong_type_cast);
}
@@ -516,12 +516,12 @@ class config
friend std::ostream &operator<<(std::ostream &os, const config &conf)
{
- uint32_t terminal_width = get_terminal_width();
+ size_t terminal_width = get_terminal_width();
if (not conf.m_usage.empty())
os << conf.m_usage << std::endl;
- uint32_t options_width = conf.m_impl->get_option_width();
+ size_t options_width = conf.m_impl->get_option_width();
if (options_width > terminal_width / 2)
options_width = terminal_width / 2;
@@ -848,8 +848,8 @@ class config
virtual option_base *get_option(std::string_view name) = 0;
virtual option_base *get_option(char short_name) = 0;
- virtual uint32_t get_option_width() const = 0;
- virtual void write(std::ostream &os, uint32_t width) const = 0;
+ virtual size_t get_option_width() const = 0;
+ virtual void write(std::ostream &os, size_t width) const = 0;
std::vector<std::string> m_operands;
};
@@ -898,16 +898,16 @@ class config
}
}
- virtual uint32_t get_option_width() const override
+ virtual size_t get_option_width() const override
{
return std::apply([](Options const& ...opts) {
- uint32_t width = 0;
+ size_t width = 0;
((width = std::max(width, opts.width())), ...);
return width;
}, m_options);
}
- virtual void write(std::ostream &os, uint32_t width) const override
+ virtual void write(std::ostream &os, size_t width) const override
{
std::apply([&os,width](Options const& ...opts) {
(opts.write(os, width), ...);
=====================================
include/mcfp/text.hpp
=====================================
@@ -29,11 +29,76 @@
#include <algorithm>
#include <charconv>
#include <cmath>
+#include <string>
+#include <vector>
+
+#if __has_include(<experimental/type_traits>)
#include <experimental/type_traits>
+#else
+#include <type_traits>
+#endif
namespace mcfp
{
+#if (not defined(__cpp_lib_experimental_detect) or (__cpp_lib_experimental_detect < 201505)) and (not defined(_LIBCPP_VERSION) or _LIBCPP_VERSION < 5000)
+// This code is copied from:
+// https://ld2015.scusa.lsu.edu/cppreference/en/cpp/experimental/is_detected.html
+
+template< class... >
+using void_t = void;
+
+namespace detail
+{
+ template <class Default, class AlwaysVoid,
+ template<class...> class Op, class... Args>
+ struct detector
+ {
+ using value_t = std::false_type;
+ using type = Default;
+ };
+
+ template <class Default, template<class...> class Op, class... Args>
+ struct detector<Default, void_t<Op<Args...>>, Op, Args...> {
+ // Note that std::void_t is a c++17 feature
+ using value_t = std::true_type;
+ using type = Op<Args...>;
+ };
+} // namespace detail
+
+struct nonesuch
+{
+ nonesuch() = delete;
+ ~nonesuch() = delete;
+ nonesuch(nonesuch const&) = delete;
+ void operator=(nonesuch const&) = delete;
+};
+
+template <template<class...> class Op, class... Args>
+using is_detected = typename detail::detector<nonesuch, void, Op, Args...>::value_t;
+
+template <template<class...> class Op, class... Args>
+constexpr inline bool is_detected_v = is_detected<Op,Args...>::value;
+
+template <template<class...> class Op, class... Args>
+using detected_t = typename detail::detector<nonesuch, void, Op, Args...>::type;
+
+template <class Default, template<class...> class Op, class... Args>
+using detected_or = detail::detector<Default, void, Op, Args...>;
+
+template <class Expected, template <class...> class Op, class... Args>
+using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>;
+
+template <class Expected, template<class...> class Op, class... Args>
+constexpr inline bool is_detected_exact_v = is_detected_exact<Expected, Op, Args...>::value;
+
+#else
+
+template <template<class...> class Op, class... Args>
+constexpr inline bool is_detected_v = std::experimental::is_detected<Op,Args...>::value;
+
+#endif
+
template <typename T>
struct my_charconv
{
@@ -199,7 +264,7 @@ template <typename T>
using from_chars_function = decltype(std::from_chars(std::declval<const char *>(), std::declval<const char *>(), std::declval<T &>()));
template <typename T>
-using charconv = typename std::conditional_t<std::experimental::is_detected_v<from_chars_function, T>, std_charconv<T>, my_charconv<T>>;
+using charconv = typename std::conditional_t<is_detected_v<from_chars_function, T>, std_charconv<T>, my_charconv<T>>;
// --------------------------------------------------------------------
/// Simplified line breaking code taken from a decent text editor.
=====================================
test/unit-test.cpp
=====================================
@@ -365,7 +365,7 @@ BOOST_AUTO_TEST_CASE(t_12)
ec = {};
config.parse(argc, argv, ec);
- BOOST_CHECK(ec == std::errc());
+ BOOST_CHECK(not ec);
}
// --------------------------------------------------------------------
@@ -407,7 +407,7 @@ verbose
config.parse_config_file(is, ec);
- BOOST_CHECK(ec == std::errc());
+ BOOST_CHECK(not ec);
BOOST_CHECK(config.has("aap"));
BOOST_CHECK_EQUAL(config.get<std::string>("aap"), "1");
@@ -487,7 +487,7 @@ BOOST_AUTO_TEST_CASE(file_3)
config.parse_config_file("config", "bla-bla.conf", { gTestDir.string() }, ec);
- BOOST_CHECK(ec == std::errc());
+ BOOST_CHECK(not ec);
BOOST_CHECK(config.has("aap"));
BOOST_CHECK_EQUAL(config.get<std::string>("aap"), "aap");
@@ -517,7 +517,7 @@ BOOST_AUTO_TEST_CASE(file_4)
config.parse_config_file("config", "unit-test.conf", { gTestDir.string() }, ec);
- BOOST_CHECK(ec == std::errc());
+ BOOST_CHECK(not ec);
BOOST_CHECK(config.has("aap"));
BOOST_CHECK_EQUAL(config.get<std::string>("aap"), "aap");
View it on GitLab: https://salsa.debian.org/med-team/libmcfp/-/commit/2938e41ea7383899f6d1205821dc5e7bd5518f49
--
View it on GitLab: https://salsa.debian.org/med-team/libmcfp/-/commit/2938e41ea7383899f6d1205821dc5e7bd5518f49
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20230202/7ba40bbc/attachment-0001.htm>
More information about the debian-med-commit
mailing list