Переделана структура проекта
This commit is contained in:
42
src/myx/backports/compiler/CMakeLists.txt
Normal file
42
src/myx/backports/compiler/CMakeLists.txt
Normal file
@ -0,0 +1,42 @@
|
||||
# Название основной цели и имя библиотеки в текущем каталоге
|
||||
set(TRGT backports-compiler)
|
||||
|
||||
# cmake-format: off
|
||||
# Список файлов исходных текстов
|
||||
set(TRGT_cpp)
|
||||
|
||||
# Список заголовочных файлов
|
||||
set(TRGT_hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gcc.hpp
|
||||
)
|
||||
|
||||
set(TRGT_headers ${TRGT_hpp})
|
||||
# cmake-format: on
|
||||
|
||||
add_library(${TRGT} INTERFACE)
|
||||
target_sources(${TRGT} INTERFACE ${TRGT_cpp} ${TRGT_headers})
|
||||
|
||||
# Создание цели для проверки утилитой clang-tidy
|
||||
add_clang_tidy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
|
||||
|
||||
# Создание цели для проверки утилитой clang-analyze
|
||||
add_clang_analyze_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
|
||||
|
||||
# Создание цели для проверки утилитой clazy
|
||||
add_clazy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
|
||||
|
||||
# Создание цели для проверки утилитой pvs-studio
|
||||
add_pvs_check(${TRGT})
|
||||
|
||||
# Создание цели для автоматического форматирования кода
|
||||
add_format_sources(${TRGT} ${TRGT_cpp} ${TRGT_headers})
|
||||
|
||||
target_include_directories(${TRGT} INTERFACE ${CMAKE_SOURCE_DIR}/src)
|
||||
|
||||
generate_pkgconfig(myx-${TRGT} COMPONENT base-dev INSTALL_LIBRARY ${MYXLIB_BUILD_LIBRARIES})
|
||||
install(FILES ${TRGT_headers} COMPONENT base-dev
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/backports/compiler)
|
||||
|
||||
# Цель, используемая только для установки заголовочных файлов без компиляции проекта
|
||||
add_custom_target(${TRGT}-install-headers COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=base-dev -P
|
||||
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
|
29
src/myx/backports/compiler/gcc.hpp
Normal file
29
src/myx/backports/compiler/gcc.hpp
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef MYX_BACKPORTS_COMPILER_GCC_HPP_
|
||||
#define MYX_BACKPORTS_COMPILER_GCC_HPP_
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __GNUC__
|
||||
// NOLINTNEXTLINE
|
||||
#define GCC_VERSION ( __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ )
|
||||
#if GCC_VERSION <= 40702
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wkeyword-macro"
|
||||
#endif
|
||||
|
||||
// NOLINTNEXTLINE
|
||||
#define override
|
||||
|
||||
// NOLINTNEXTLINE
|
||||
#define constexpr const
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif // if GCC_VERSION <= 40702
|
||||
#endif // ifdef __GNUC__
|
||||
|
||||
#endif // ifndef MYX_BACKPORTS_COMPILER_GCC_HPP_
|
43
src/myx/backports/cpp/CMakeLists.txt
Normal file
43
src/myx/backports/cpp/CMakeLists.txt
Normal file
@ -0,0 +1,43 @@
|
||||
# Название основной цели и имя библиотеки в текущем каталоге
|
||||
set(TRGT backports-cpp)
|
||||
|
||||
# cmake-format: off
|
||||
# Список файлов исходных текстов
|
||||
set(TRGT_cpp)
|
||||
|
||||
# Список заголовочных файлов
|
||||
set(TRGT_hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/helpers.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/span.hpp
|
||||
)
|
||||
|
||||
set(TRGT_headers ${TRGT_hpp})
|
||||
# cmake-format: on
|
||||
|
||||
add_library(${TRGT} INTERFACE)
|
||||
target_sources(${TRGT} INTERFACE ${TRGT_cpp} ${TRGT_headers})
|
||||
|
||||
# Создание цели для проверки утилитой clang-tidy
|
||||
add_clang_tidy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
|
||||
|
||||
# Создание цели для проверки утилитой clang-analyze
|
||||
add_clang_analyze_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
|
||||
|
||||
# Создание цели для проверки утилитой clazy
|
||||
add_clazy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
|
||||
|
||||
# Создание цели для проверки утилитой pvs-studio
|
||||
add_pvs_check(${TRGT})
|
||||
|
||||
# Создание цели для автоматического форматирования кода
|
||||
add_format_sources(${TRGT} ${TRGT_cpp} ${TRGT_headers})
|
||||
|
||||
target_include_directories(${TRGT} INTERFACE ${CMAKE_SOURCE_DIR}/src)
|
||||
|
||||
generate_pkgconfig(myx-${TRGT} COMPONENT base-dev INSTALL_LIBRARY ${MYXLIB_BUILD_LIBRARIES})
|
||||
install(FILES ${TRGT_headers} COMPONENT base-dev
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/backports/cpp)
|
||||
|
||||
# Цель, используемая только для установки заголовочных файлов без компиляции проекта
|
||||
add_custom_target(${TRGT}-install-headers COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=base-dev -P
|
||||
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
|
36
src/myx/backports/cpp/helpers.hpp
Normal file
36
src/myx/backports/cpp/helpers.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef MYX_BACKPORTS_CPP_HELPERS_HPP_
|
||||
#define MYX_BACKPORTS_CPP_HELPERS_HPP_
|
||||
|
||||
#pragma once
|
||||
|
||||
#if ( __cplusplus >= 201103L )
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
#if ( __cplusplus >= 201103L ) && ( __cplusplus < 201402L )
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template< class T >
|
||||
using underlying_type_t = typename std::underlying_type< T >::type;
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif
|
||||
|
||||
#if ( __cplusplus >= 201103L ) && ( __cplusplus < 201702L )
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
#if defined( __STRICT_ANSI__ )
|
||||
template< typename ... Ts > struct make_void { typedef void type; };
|
||||
template< typename ... Ts > using void_t = typename make_void< Ts... >::type;
|
||||
#endif
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif
|
||||
|
||||
#endif // ifndef MYX_BACKPORTS_CPP_HELPERS_HPP_
|
240
src/myx/backports/cpp/span.hpp
Normal file
240
src/myx/backports/cpp/span.hpp
Normal file
@ -0,0 +1,240 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef MYX_BACKPORTS_CPP_SPAN_HPP_
|
||||
#define MYX_BACKPORTS_CPP_SPAN_HPP_
|
||||
|
||||
#pragma once
|
||||
|
||||
#if ( __cplusplus >= 201103L ) && ( __cplusplus < 201703L )
|
||||
|
||||
#include <myx/backports/cpp/helpers.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
namespace std {
|
||||
|
||||
template< class T, class E, class = void >
|
||||
struct is_contiguous_container : std::false_type {}; // NOLINT
|
||||
|
||||
template< class T, class E >
|
||||
struct is_contiguous_container< T, E, void_t<
|
||||
decltype(
|
||||
std::declval< std::size_t& >() = std::declval< T const& >().size(),
|
||||
std::declval< E*& >() = std::declval< T& >().data() ),
|
||||
typename std::enable_if<
|
||||
std::is_same<
|
||||
typename std::remove_cv< E >::type,
|
||||
typename std::remove_cv<
|
||||
typename std::remove_pointer<
|
||||
decltype( std::declval< T& >().data() )
|
||||
>::type
|
||||
>::type
|
||||
>::value
|
||||
>::type > > : std::true_type
|
||||
{};
|
||||
|
||||
|
||||
/** A range of bytes expressed as a ContiguousContainer
|
||||
|
||||
This class implements a non-owning reference to a storage
|
||||
area of a certain size and having an underlying integral
|
||||
type with size of 1.
|
||||
|
||||
@tparam T The type pointed to by span iterators
|
||||
*/
|
||||
template< class T >
|
||||
class span // NOLINT
|
||||
{
|
||||
T* m_data = nullptr;
|
||||
std::size_t m_size = 0;
|
||||
|
||||
public:
|
||||
/// The type of value, including cv qualifiers
|
||||
using ElementType = T;
|
||||
|
||||
/// The type of value of each span element
|
||||
using ValueType = typename std::remove_const< T >::type;
|
||||
|
||||
/// The type of integer used to index the span
|
||||
using IndexType = std::ptrdiff_t;
|
||||
|
||||
/// A pointer to a span element
|
||||
using Pointer = T*;
|
||||
|
||||
/// A reference to a span element
|
||||
using Reference = T&;
|
||||
|
||||
/// The iterator used by the container
|
||||
using Iterator = Pointer;
|
||||
|
||||
/// The const pointer used by the container
|
||||
using ConstPointer = T const*;
|
||||
|
||||
/// The const reference used by the container
|
||||
using ConstReference = T const&;
|
||||
|
||||
/// The const iterator used by the container
|
||||
using ConstIterator = ConstPointer;
|
||||
|
||||
/// Constructor
|
||||
span() = default;
|
||||
|
||||
/// Constructor
|
||||
span( span const& ) = default;
|
||||
|
||||
/// Assignment
|
||||
span& operator=( span const& ) = default;
|
||||
|
||||
/** Constructor
|
||||
* @param data A pointer to the beginning of the range of elements
|
||||
* @param size The number of elements pointed to by `data`
|
||||
*/
|
||||
span( T* data, std::size_t size ) :
|
||||
m_data( data ),
|
||||
m_size( size )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/** Constructor
|
||||
* @param container The container to construct from
|
||||
*/
|
||||
template< class ContiguousContainer,
|
||||
class = typename std::enable_if<
|
||||
is_contiguous_container<
|
||||
ContiguousContainer, T >::value >::type
|
||||
>
|
||||
explicit
|
||||
span( ContiguousContainer&& container ) :
|
||||
m_data( container.data() ),
|
||||
m_size( container.size() )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
template< class CharT, class Traits, class Allocator >
|
||||
explicit
|
||||
span( std::basic_string< CharT, Traits, Allocator >& s ) :
|
||||
m_data( &s[0] ),
|
||||
m_size( s.size() )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
template< class CharT, class Traits, class Allocator >
|
||||
explicit
|
||||
span( std::basic_string< CharT, Traits, Allocator > const& s ) :
|
||||
m_data( s.data() ),
|
||||
m_size( s.size() )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/** Assignment
|
||||
* @param container The container to assign from
|
||||
*/
|
||||
template< class ContiguousContainer >
|
||||
typename std::enable_if< is_contiguous_container<
|
||||
ContiguousContainer, T >::value,
|
||||
span& >::type
|
||||
operator=( ContiguousContainer&& container )
|
||||
{
|
||||
m_data = container.data();
|
||||
m_size = container.size();
|
||||
return( *this );
|
||||
}
|
||||
|
||||
|
||||
template< class CharT, class Traits, class Allocator >
|
||||
span&
|
||||
operator=( std::basic_string<
|
||||
CharT, Traits, Allocator >& s )
|
||||
{
|
||||
m_data = &s[0];
|
||||
m_size = s.size();
|
||||
return( *this );
|
||||
}
|
||||
|
||||
|
||||
template< class CharT, class Traits, class Allocator >
|
||||
span&
|
||||
operator=( std::basic_string<
|
||||
CharT, Traits, Allocator > const& s )
|
||||
{
|
||||
m_data = s.data();
|
||||
m_size = s.size();
|
||||
return( *this );
|
||||
}
|
||||
|
||||
|
||||
/// Returns `true` if the span is empty
|
||||
bool
|
||||
empty() const
|
||||
{
|
||||
return( m_size == 0 );
|
||||
}
|
||||
|
||||
|
||||
/// Returns a pointer to the beginning of the span
|
||||
T*
|
||||
data() const
|
||||
{
|
||||
return( m_data );
|
||||
}
|
||||
|
||||
|
||||
/// Returns the number of elements in the span
|
||||
std::size_t
|
||||
size() const
|
||||
{
|
||||
return( m_size );
|
||||
}
|
||||
|
||||
|
||||
/// Returns an iterator to the beginning of the span
|
||||
Iterator
|
||||
begin() const
|
||||
{
|
||||
return( m_data );
|
||||
}
|
||||
|
||||
|
||||
/// Returns an iterator to the beginning of the span
|
||||
ConstIterator
|
||||
cbegin() const
|
||||
{
|
||||
return( m_data );
|
||||
}
|
||||
|
||||
|
||||
/// Returns an iterator to one past the end of the span
|
||||
Iterator
|
||||
end() const
|
||||
{
|
||||
return( m_data + m_size );
|
||||
}
|
||||
|
||||
|
||||
/// Returns an iterator to one past the end of the span
|
||||
ConstIterator
|
||||
cend() const
|
||||
{
|
||||
return( m_data + m_size );
|
||||
}
|
||||
}; // class span
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif // if ( __cplusplus >= 201103L ) && ( __cplusplus < 201703L )
|
||||
|
||||
#endif // ifndef MYX_BACKPORTS_CPP_SPAN_HPP_
|
42
src/myx/backports/qt/CMakeLists.txt
Normal file
42
src/myx/backports/qt/CMakeLists.txt
Normal file
@ -0,0 +1,42 @@
|
||||
# Название основной цели и имя библиотеки в текущем каталоге
|
||||
set(TRGT backports-qt)
|
||||
|
||||
# cmake-format: off
|
||||
# Список файлов исходных текстов
|
||||
set(TRGT_cpp)
|
||||
|
||||
# Список заголовочных файлов
|
||||
set(TRGT_hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/common.hpp
|
||||
)
|
||||
|
||||
set(TRGT_headers ${TRGT_hpp})
|
||||
# cmake-format: on
|
||||
|
||||
add_library(${TRGT} INTERFACE)
|
||||
target_sources(${TRGT} INTERFACE ${TRGT_cpp} ${TRGT_headers})
|
||||
|
||||
# Создание цели для проверки утилитой clang-tidy
|
||||
add_clang_tidy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
|
||||
|
||||
# Создание цели для проверки утилитой clang-analyze
|
||||
add_clang_analyze_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
|
||||
|
||||
# Создание цели для проверки утилитой clazy
|
||||
add_clazy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
|
||||
|
||||
# Создание цели для проверки утилитой pvs-studio
|
||||
add_pvs_check(${TRGT})
|
||||
|
||||
# Создание цели для автоматического форматирования кода
|
||||
add_format_sources(${TRGT} ${TRGT_cpp} ${TRGT_headers})
|
||||
|
||||
target_include_directories(${TRGT} INTERFACE ${CMAKE_SOURCE_DIR}/src)
|
||||
|
||||
install(FILES ${TRGT_headers} COMPONENT base-dev
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/backports/qt)
|
||||
generate_pkgconfig(myx-${TRGT} COMPONENT base-dev INSTALL_LIBRARY ${MYXLIB_BUILD_LIBRARIES})
|
||||
|
||||
# Цель, используемая только для установки заголовочных файлов без компиляции проекта
|
||||
add_custom_target(${TRGT}-install-headers COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=base-dev -P
|
||||
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
|
37
src/myx/backports/qt/common.hpp
Normal file
37
src/myx/backports/qt/common.hpp
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef MYX_BACKPORTS_QT_COMMON_HPP_
|
||||
#define MYX_BACKPORTS_QT_COMMON_HPP_
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined( QT_VERSION )
|
||||
|
||||
#if QT_VERSION <= 0x050700
|
||||
#include <QtGlobal>
|
||||
template< typename ... Args >
|
||||
struct QOverload
|
||||
{
|
||||
template< typename C, typename R >
|
||||
static constexpr auto of( R ( C::* pmf )( Args... ) ) -> decltype( pmf )
|
||||
{
|
||||
return( pmf );
|
||||
}
|
||||
};
|
||||
|
||||
// this adds const to non-const objects (like std::as_const)
|
||||
template < typename T >
|
||||
Q_DECL_CONSTEXPR typename std::add_const< T >::type& qAsConst( T& t ) noexcept
|
||||
{
|
||||
return( t );
|
||||
}
|
||||
|
||||
|
||||
// prevent rvalue arguments:
|
||||
template < typename T >
|
||||
void qAsConst( const T&& ) = delete;
|
||||
|
||||
|
||||
#endif // if QT_VERSION <= 0x050700
|
||||
|
||||
#endif // if defined( QT_VERSION )
|
||||
|
||||
#endif // MYX_BACKPORTS_QT_COMMON_HPP_
|
Reference in New Issue
Block a user