Fix decoration for static builds

- Also add improvemnts a few other things in the build system
experiment/meta_header
Martchus 6 years ago
parent cf521a3255
commit d6b08b8ed9
  1. 20
      application/argumentparser.h
  2. 6
      application/commandlineutils.h
  3. 4
      application/failure.h
  4. 2
      application/fakeqtconfigarguments.h
  5. 226
      application/global.h
  6. 2
      chrono/datetime.h
  7. 4
      chrono/period.h
  8. 4
      chrono/timespan.h
  9. 3
      cmake/modules/AppTarget.cmake
  10. 11
      cmake/modules/BasicConfig.cmake
  11. 37
      cmake/modules/LibraryTarget.cmake
  12. 55
      cmake/templates/Config.cmake.in
  13. 9
      cmake/templates/config.h.in
  14. 17
      cmake/templates/global.h.in
  15. 2
      cmake/templates/template.pc.in
  16. 400
      conversion/binaryconversion.h
  17. 38
      conversion/binaryconversionprivate.h
  18. 4
      conversion/conversionexception.h
  19. 48
      conversion/stringconversion.h
  20. 148
      conversion/types.h
  21. 104
      conversion/widen.h
  22. 17
      global.h
  23. 2
      io/ansiescapecodes.h
  24. 678
      io/binaryreader.cpp
  25. 1132
      io/binaryreader.h
  26. 190
      io/binarywriter.cpp
  27. 1067
      io/binarywriter.h
  28. 4
      io/bitreader.h
  29. 72
      io/catchiofailure.cpp
  30. 30
      io/catchiofailure.h
  31. 4
      io/copy.h
  32. 4
      io/inifile.h
  33. 435
      io/path.cpp
  34. 110
      io/path.h
  35. 14
      math/math.h
  36. 250
      misc/random.cpp
  37. 30
      misc/random.h
  38. 8
      tests/testutils.h

@ -1,7 +1,7 @@
#ifndef APPLICATION_UTILITIES_ARGUMENTPARSER_H
#define APPLICATION_UTILITIES_ARGUMENTPARSER_H
#include "./global.h"
#include "../global.h"
#include <vector>
#include <initializer_list>
@ -14,10 +14,10 @@ class ArgumentParserTests;
namespace ApplicationUtilities {
LIB_EXPORT extern const char *applicationName;
LIB_EXPORT extern const char *applicationAuthor;
LIB_EXPORT extern const char *applicationVersion;
LIB_EXPORT extern const char *applicationUrl;
CPP_UTILITIES_EXPORT extern const char *applicationName;
CPP_UTILITIES_EXPORT extern const char *applicationAuthor;
CPP_UTILITIES_EXPORT extern const char *applicationVersion;
CPP_UTILITIES_EXPORT extern const char *applicationUrl;
#define SET_APPLICATION_INFO \
::ApplicationUtilities::applicationName = APP_NAME; \
@ -68,12 +68,12 @@ constexpr bool operator&(ValueCompletionBehavior lhs, ValueCompletionBehavior rh
}
/// \endcond
Argument LIB_EXPORT *firstPresentUncombinableArg(const ArgumentVector &args, const Argument *except);
Argument CPP_UTILITIES_EXPORT *firstPresentUncombinableArg(const ArgumentVector &args, const Argument *except);
/*!
* \brief The ArgumentOccurrence struct holds argument values for an occurrence of an argument.
*/
struct LIB_EXPORT ArgumentOccurrence
struct CPP_UTILITIES_EXPORT ArgumentOccurrence
{
ArgumentOccurrence(std::size_t index);
ArgumentOccurrence(std::size_t index, const std::vector<Argument *> parentPath, Argument *parent);
@ -119,7 +119,7 @@ inline ArgumentOccurrence::ArgumentOccurrence(std::size_t index, const std::vect
}
}
class LIB_EXPORT Argument
class CPP_UTILITIES_EXPORT Argument
{
friend class ArgumentParser;
@ -200,7 +200,7 @@ private:
const char *m_preDefinedCompletionValues;
};
class LIB_EXPORT ArgumentParser
class CPP_UTILITIES_EXPORT ArgumentParser
{
friend ArgumentParserTests;
public:
@ -767,7 +767,7 @@ inline void ArgumentParser::setDefaultArgument(Argument *argument)
m_defaultArg = argument;
}
class LIB_EXPORT HelpArgument : public Argument
class CPP_UTILITIES_EXPORT HelpArgument : public Argument
{
public:
HelpArgument(ArgumentParser &parser);

@ -1,7 +1,7 @@
#ifndef APPLICATIONUTILITIES_COMMANDLINEUTILS_H
#define APPLICATIONUTILITIES_COMMANDLINEUTILS_H
#include "./global.h"
#include "../global.h"
namespace ApplicationUtilities {
@ -15,10 +15,10 @@ enum class Response
No
};
bool LIB_EXPORT confirmPrompt(const char *message, Response defaultResponse = Response::None);
bool CPP_UTILITIES_EXPORT confirmPrompt(const char *message, Response defaultResponse = Response::None);
#ifdef PLATFORM_WINDOWS
void LIB_EXPORT startConsole();
void CPP_UTILITIES_EXPORT startConsole();
# define CMD_UTILS_START_CONSOLE ::ApplicationUtilities::startConsole();
#else
# define CMD_UTILS_START_CONSOLE

@ -1,14 +1,14 @@
#ifndef APPLICATION_UTILITIES_FAILURE_H
#define APPLICATION_UTILITIES_FAILURE_H
#include "./global.h"
#include "../global.h"
#include <exception>
#include <string>
namespace ApplicationUtilities {
class LIB_EXPORT Failure : public std::exception
class CPP_UTILITIES_EXPORT Failure : public std::exception
{
public:
Failure();

@ -5,7 +5,7 @@
namespace ApplicationUtilities {
class LIB_EXPORT FakeQtConfigArguments
class CPP_UTILITIES_EXPORT FakeQtConfigArguments
{
public:
FakeQtConfigArguments();

@ -1,113 +1,113 @@
#ifndef APPLICATION_UTILITIES_GLOBAL_H
#define APPLICATION_UTILITIES_GLOBAL_H
#ifdef _WIN32
# ifndef PLATFORM_WINDOWS
/// \brief Defined when compiling for Windows.
# define PLATFORM_WINDOWS
# endif
# if defined(__MINGW32__) || defined(__MINGW64__)
# ifndef PLATFORM_MINGW
/// \brief Defined when compiling with mingw(-w64).
# define PLATFORM_MINGW
# endif
# endif
#elif __unix__
# ifndef PLATFORM_UNIX
/// \brief Defined when compiling for any UNIX (like) system.
# define PLATFORM_UNIX
# endif
#endif
#ifdef __linux__
# ifndef PLATFORM_LINUX
/// \brief Defined when compiling for Linux.
# define PLATFORM_LINUX
# endif
#endif
/*!
* \def LIB_EXPORT
* \brief Marks a symbol for shared library export.
*/
/*!
* \def LIB_IMPORT
* \brief Declares a symbol to be an import from a shared library.
*/
/*!
* \def LIB_HIDDEN
* \brief Hidden visibility indicates that the symbol will not be placed into
* the dynamic symbol table, so no other module (executable or shared library)
* can reference it directly.
*/
#ifdef PLATFORM_WINDOWS
# define LIB_EXPORT __declspec(dllexport)
# define LIB_IMPORT __declspec(dllimport)
# define LIB_HIDDEN
#else
# define LIB_EXPORT __attribute__((visibility("default")))
# define LIB_IMPORT __attribute__((visibility("default")))
# define LIB_HIDDEN __attribute__((visibility("hidden")))
#endif
/*!
* \def USE_NOTHROW
* \brief Marks a function as never throwing, under no circumstances.
* \remarks If the function does nevertheless throw, the behaviour is undefined.
*/
#ifndef USE_NOTHROW
# if __cplusplus >= 201103L
# define USE_NOTHROW noexcept
# else
# define USE_NOTHROW throw()
# endif
#endif
/*!
* \def DECLARE_ENUM
* \brief Declares an enum without preventing lupdate to parse the file correctly.
*/
#define DECLARE_ENUM(name, base) enum name : base
/*!
* \def DECLARE_ENUM_CLASS
* \brief Declares an enum without preventing lupdate to parse the file correctly.
*/
#define DECLARE_ENUM_CLASS(name, base) enum class name : base
/*!
* \def VAR_UNUSED
* \brief Prevents warnings about unused variables.
*/
#define VAR_UNUSED(x) (void)x;
/*!
* \def IF_DEBUG_BUILD
* \brief Wraps debug-only lines conveniently.
*/
#ifdef DEBUG_BUILD
# define IF_DEBUG_BUILD(x) x
#else
# define IF_DEBUG_BUILD(x)
#endif
/*!
* \def FALLTHROUGH
* \brief Prevents clang from warning about missing break in switch-case.
* \remarks Does nothing if another compiler is used.
*/
#ifdef __clang__
# define FALLTHROUGH [[clang::fallthrough]]
# else
# define FALLTHROUGH
#endif
#endif // APPLICATION_UTILITIES_GLOBAL_H
#ifndef APPLICATION_UTILITIES_GLOBAL_H
#define APPLICATION_UTILITIES_GLOBAL_H
#ifdef _WIN32
# ifndef PLATFORM_WINDOWS
/// \brief Defined when compiling for Windows.
# define PLATFORM_WINDOWS
# endif
# if defined(__MINGW32__) || defined(__MINGW64__)
# ifndef PLATFORM_MINGW
/// \brief Defined when compiling with mingw(-w64).
# define PLATFORM_MINGW
# endif
# endif
#elif __unix__
# ifndef PLATFORM_UNIX
/// \brief Defined when compiling for any UNIX (like) system.
# define PLATFORM_UNIX
# endif
#endif
#ifdef __linux__
# ifndef PLATFORM_LINUX
/// \brief Defined when compiling for Linux.
# define PLATFORM_LINUX
# endif
#endif
/*!
* \def LIB_EXPORT
* \brief Marks a symbol for shared library export.
*/
/*!
* \def LIB_IMPORT
* \brief Declares a symbol to be an import from a shared library.
*/
/*!
* \def LIB_HIDDEN
* \brief Hidden visibility indicates that the symbol will not be placed into
* the dynamic symbol table, so no other module (executable or shared library)
* can reference it directly.
*/
#ifdef PLATFORM_WINDOWS
# define LIB_EXPORT __declspec(dllexport)
# define LIB_IMPORT __declspec(dllimport)
# define LIB_HIDDEN
#else
# define LIB_EXPORT __attribute__((visibility("default")))
# define LIB_IMPORT __attribute__((visibility("default")))
# define LIB_HIDDEN __attribute__((visibility("hidden")))
#endif
/*!
* \def USE_NOTHROW
* \brief Marks a function as never throwing, under no circumstances.
* \remarks If the function does nevertheless throw, the behaviour is undefined.
*/
#ifndef USE_NOTHROW
# if __cplusplus >= 201103L
# define USE_NOTHROW noexcept
# else
# define USE_NOTHROW throw()
# endif
#endif
/*!
* \def DECLARE_ENUM
* \brief Declares an enum without preventing lupdate to parse the file correctly.
*/
#define DECLARE_ENUM(name, base) enum name : base
/*!
* \def DECLARE_ENUM_CLASS
* \brief Declares an enum without preventing lupdate to parse the file correctly.
*/
#define DECLARE_ENUM_CLASS(name, base) enum class name : base
/*!
* \def VAR_UNUSED
* \brief Prevents warnings about unused variables.
*/
#define VAR_UNUSED(x) (void)x;
/*!
* \def IF_DEBUG_BUILD
* \brief Wraps debug-only lines conveniently.
*/
#ifdef DEBUG_BUILD
# define IF_DEBUG_BUILD(x) x
#else
# define IF_DEBUG_BUILD(x)
#endif
/*!
* \def FALLTHROUGH
* \brief Prevents clang from warning about missing break in switch-case.
* \remarks Does nothing if another compiler is used.
*/
#ifdef __clang__
# define FALLTHROUGH [[clang::fallthrough]]
# else
# define FALLTHROUGH
#endif
#endif // APPLICATION_UTILITIES_GLOBAL_H

@ -52,7 +52,7 @@ enum class DatePart
Day /**< day */
};
class LIB_EXPORT DateTime
class CPP_UTILITIES_EXPORT DateTime
{
public:
explicit constexpr DateTime();

@ -3,11 +3,9 @@
#include "./datetime.h"
#include "../application/global.h"
namespace ChronoUtilities {
class LIB_EXPORT Period
class CPP_UTILITIES_EXPORT Period
{
public:
Period(const DateTime &beg, const DateTime &end);

@ -1,7 +1,7 @@
#ifndef CHRONO_UTILITIES_TIMESPAN_H
#define CHRONO_UTILITIES_TIMESPAN_H
#include "../application/global.h"
#include "../global.h"
#include "../conversion/types.h"
#include <string>
@ -25,7 +25,7 @@ enum class TimeSpanOutputFormat
WithMeasures /**< measures are used, eg.: 34 d 5 h 10 min 7 s 31 ms */
};
class LIB_EXPORT TimeSpan
class CPP_UTILITIES_EXPORT TimeSpan
{
friend class DateTime;
public:

@ -18,6 +18,7 @@ else()
set(ACTUAL_ADDITIONAL_LINK_FLAGS ${ADDITIONAL_LINK_FLAGS})
set(ACTUAL_ADDITIONAL_COMPILE_DEFINITIONS ${ADDITIONAL_COMPILE_DEFINITIONS})
endif()
# add target for building the application
add_executable(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} ${GUI_TYPE} ${HEADER_FILES} ${SRC_FILES} ${WIDGETS_FILES} ${QML_FILES} ${RES_FILES} ${QM_FILES} ${WINDOWS_ICON_PATH})
target_link_libraries(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} ${ACTUAL_ADDITIONAL_LINK_FLAGS} ${LIBRARIES})
@ -33,7 +34,6 @@ install(TARGETS ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
RUNTIME DESTINATION bin
COMPONENT binary
)
if(NOT TARGET install-binary)
add_custom_target(install-binary
DEPENDS ${META_PROJECT_NAME}
@ -64,7 +64,6 @@ foreach(ICON_FILE ${ICON_FILES})
COMPONENT desktop
)
endforeach()
if(NOT TARGET install-desktop)
add_custom_target(install-desktop
DEPENDS ${META_PROJECT_NAME}

@ -39,7 +39,7 @@ set(TARGET_EXECUTABLE "${CMAKE_INSTALL_PREFIX}/bin/${TARGET_PREFIX}${META_PROJEC
option(FORCE_OLD_ABI "specifies whether usage of old ABI should be forced" OFF)
if(FORCE_OLD_ABI)
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
set(META_REQUIRED_CFLAGS "${META_REQUIRED_CFLAGS} -D-D_GLIBCXX_USE_CXX11_ABI=0")
set(META_REQUIRED_BUILD_FLAGS "${META_REQUIRED_BUILD_CFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
message(STATUS "Forcing usage of old CXX11 ABI.")
else()
message(STATUS "Using default CXX11 ABI (not forcing old CX11 ABI).")
@ -59,9 +59,14 @@ if(LOGGING_ENABLED)
endif()
# options for deciding whether to build static and/or shared libraries
if((NOT ${META_PROJECT_TYPE} STREQUAL "library") AND (NOT ${META_PROJECT_TYPE} STREQUAL ""))
if(("${META_PROJECT_TYPE}" STREQUAL "library") OR ("${META_PROJECT_TYPE}" STREQUAL ""))
option(BUILD_STATIC_LIBS "whether to build static libraries (disabled by default)" OFF)
option(BUILD_SHARED_LIBS "whether to build dynamic libraries (enabled by default)" ON)
option(DISABLE_SHARED_LIBS "whether building dynamic libraries is disabled (prevents BUILD_SHARED_LIBS being re-enabled when using Qt Creator)" OFF)
if(DISABLE_SHARED_LIBS)
set(BUILD_SHARED_LIBS OFF)
else()
option(BUILD_SHARED_LIBS "whether to build dynamic libraries (enabled by default)" ON)
endif()
endif()
# options for forcing static linkage when building applications or dynamic libraries

@ -30,6 +30,7 @@ set(LIB_INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${SELECTED_LIB_SUFFIX}")
set(CMAKE_MODULE_INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}/share/${META_PROJECT_NAME}/cmake/modules")
set(CMAKE_CONFIG_INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}/share/${META_PROJECT_NAME}/cmake")
# remove library prefix when building with mingw-w64 (just for consistency with qmake)
if(MINGW)
set(CMAKE_SHARED_LIBRARY_PREFIX "")
@ -40,6 +41,29 @@ if(MINGW)
set(WINDOWS_EXT "dll")
endif(MINGW)
# create global header and define build flags
if(NOT META_SHARED_LIB_COMPILE_DEFINITIONS)
set(META_SHARED_LIB_COMPILE_DEFINITIONS ${META_COMPILE_DEFINITIONS})
endif()
if(NOT META_STATIC_LIB_COMPILE_DEFINITIONS)
set(META_STATIC_LIB_COMPILE_DEFINITIONS ${META_COMPILE_DEFINITIONS} ${META_PROJECT_VARNAME_UPPER}_STATIC)
endif()
# add global library-specific header
include(TemplateFinder)
find_template_file("global.h" CPP_UTILITIES GLOBAL_H_TEMPLATE_FILE)
if("${META_PROJECT_NAME}" STREQUAL "c++utilities")
set(GENERAL_GLOBAL_H_INCLUDE_PATH "\"./application/global.h\"")
else()
set(GENERAL_GLOBAL_H_INCLUDE_PATH "<c++utilities/application/global.h>")
endif()
configure_file(
"${GLOBAL_H_TEMPLATE_FILE}"
"${CMAKE_CURRENT_SOURCE_DIR}/global.h" # simply add this to source to ease inclusion
NEWLINE_STYLE UNIX # since this goes to sources ensure consistency
)
list(APPEND HEADER_FILES global.h)
# add target for building the library
if(BUILD_SHARED_LIBS)
# use correct linker flags and compile definitions (depend on linkage)
@ -65,6 +89,8 @@ endif()
# add target for building a static version of the library
if(BUILD_STATIC_LIBS)
set(ACTUAL_ADDITIONAL_COMPILE_DEFINITIONS ${ADDITIONAL_STATIC_COMPILE_DEFINITIONS})
list(APPEND ACTUAL_ADDITIONAL_COMPILE_DEFINITIONS ${META_STATIC_LIB_COMPILE_DEFINITIONS})
add_library(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_static STATIC ${HEADER_FILES} ${SRC_FILES} ${WIDGETS_FILES} ${QML_FILES} ${RES_FILES} ${QM_FILES} ${WINDOWS_ICON_PATH})
# add target link libraries for the static lib also because otherwise Qt header files can not be located
target_link_libraries(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_static ${STATIC_LIBRARIES})
@ -73,7 +99,7 @@ if(BUILD_STATIC_LIBS)
SOVERSION ${META_VERSION_MAJOR}
OUTPUT_NAME ${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
CXX_STANDARD 11
COMPILE_DEFINITIONS "${ADDITIONAL_STATIC_COMPILE_DEFINITIONS}"
COMPILE_DEFINITIONS "${ACTUAL_ADDITIONAL_COMPILE_DEFINITIONS}"
)
set(META_STATIC_LIB_DEPENDS ${${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}_static_LIB_DEPENDS}) # used in config file
endif()
@ -101,7 +127,6 @@ write_basic_package_version_file(
# create pkg-config file from template
# will (currently) not contain Libs.private if static libs haven't been built anyways
include(TemplateFinder)
find_template_file("template.pc" CPP_UTILITIES PKGCONFIG_TEMPLATE_FILE)
configure_file(
"${PKGCONFIG_TEMPLATE_FILE}"
@ -119,7 +144,6 @@ install(
COMPONENT
cmake-config
)
if(NOT TARGET install-cmake-config)
add_custom_target(install-cmake-config
DEPENDS ${META_PROJECT_NAME}
@ -152,7 +176,6 @@ if(BUILD_SHARED_LIBS)
COMPONENT binary
)
endif()
if(NOT TARGET install-binary)
add_custom_target(install-binary
DEPENDS ${META_PROJECT_NAME}
@ -190,7 +213,6 @@ foreach(HEADER_FILE ${HEADER_FILES} ${ADDITIONAL_HEADER_FILES})
COMPONENT header
)
endforeach()
if(NOT TARGET install-header)
add_custom_target(install-header
DEPENDS ${META_PROJECT_NAME}
@ -207,7 +229,6 @@ foreach(CMAKE_MODULE_FILE ${CMAKE_MODULE_FILES})
COMPONENT cmake-modules
)
endforeach()
if(NOT TARGET install-cmake-modules)
add_custom_target(install-cmake-modules
DEPENDS ${META_PROJECT_NAME}
@ -224,7 +245,6 @@ foreach(CMAKE_TEMPLATE_FILE ${CMAKE_TEMPLATE_FILES})
COMPONENT cmake-templates
)
endforeach()
if(NOT TARGET install-cmake-templates)
add_custom_target(install-cmake-templates
DEPENDS ${META_PROJECT_NAME}
@ -245,21 +265,18 @@ if(NOT TARGET install-mingw-w64)
DEPENDS install-binary install-header install-cmake-stuff ${LOCALIZATION_TARGET}
)
endif()
if(NOT TARGET install-mingw-w64-importlib-strip)
add_custom_target(install-mingw-w64-importlib-strip
DEPENDS install-binary-strip
COMMAND "${CMAKE_FIND_ROOT_PATH}/bin/strip" --strip-unneeded "\$\{DESTDIR\}\$\{DESTDIR:+/\}${CMAKE_INSTALL_PREFIX}/lib/lib${META_PROJECT_NAME}.dll.a"
)
endif()
if(NOT TARGET install-mingw-w64-staticlib-strip)
add_custom_target(install-mingw-w64-staticlib-strip
DEPENDS install-binary-strip
COMMAND "${CMAKE_FIND_ROOT_PATH}/bin/strip" -g "\$\{DESTDIR\}\$\{DESTDIR:+/\}${CMAKE_INSTALL_PREFIX}/lib/lib${META_PROJECT_NAME}.a"
)
endif()
if(NOT TARGET install-mingw-w64-strip)
add_custom_target(install-mingw-w64-strip
DEPENDS install-binary-strip install-mingw-w64-importlib-strip install-mingw-w64-staticlib-strip install-header install-cmake-stuff ${LOCALIZATION_TARGET}

@ -1,41 +1,44 @@
@PACKAGE_INIT@
set(@META_PROJECT_VARNAME@_HAS_SHARED_LIB "@BUILD_SHARED_LIBS@")
set(@META_PROJECT_VARNAME@_SHARED_LIB "@META_PROJECT_NAME@")
set(@META_PROJECT_VARNAME@_HAS_STATIC_LIB "@BUILD_STATIC_LIBS@")
set(@META_PROJECT_VARNAME@_STATIC_LIB "@META_PROJECT_NAME@.a")
set(@META_PROJECT_VARNAME@_STATIC_LIB_DEPENDS @META_STATIC_LIB_DEPENDS@)
set(@META_PROJECT_VARNAME@_INCLUDE_DIRS "@PACKAGE_HEADER_INSTALL_DESTINATION@")
set(@META_PROJECT_VARNAME@_BIN_DIR "@PACKAGE_BIN_INSTALL_DESTINATION@")
set(@META_PROJECT_VARNAME@_LIB_DIR "@PACKAGE_LIB_INSTALL_DESTINATION@")
set(@META_PROJECT_VARNAME@_MODULE_DIRS "@PACKAGE_CMAKE_MODULE_INSTALL_DESTINATION@")
set(@META_PROJECT_VARNAME@_CONFIG_DIRS "@PACKAGE_CMAKE_CONFIG_INSTALL_DESTINATION@")
set(@META_PROJECT_VARNAME@_REQUIRED_CFLAGS "@META_REQUIRED_CFLAGS@")
set(@META_PROJECT_VARNAME_UPPER@_HAS_SHARED_LIB "@BUILD_SHARED_LIBS@")
set(@META_PROJECT_VARNAME_UPPER@_SHARED_LIB "@META_PROJECT_NAME@")
set(@META_PROJECT_VARNAME_UPPER@_SHARED_LIB_COMPILE_DEFINITIONS @META_SHARED_LIB_COMPILE_DEFINITIONS@)
set(@META_PROJECT_VARNAME_UPPER@_HAS_STATIC_LIB "@BUILD_STATIC_LIBS@")
set(@META_PROJECT_VARNAME_UPPER@_STATIC_LIB "@META_PROJECT_NAME@.a")
set(@META_PROJECT_VARNAME_UPPER@_STATIC_LIB_DEPENDS @META_STATIC_LIB_DEPENDS@)
set(@META_PROJECT_VARNAME_UPPER@_STATIC_LIB_COMPILE_DEFINITIONS @META_STATIC_LIB_COMPILE_DEFINITIONS@)
set(@META_PROJECT_VARNAME_UPPER@_INCLUDE_DIRS "@PACKAGE_HEADER_INSTALL_DESTINATION@")
set(@META_PROJECT_VARNAME_UPPER@_BIN_DIR "@PACKAGE_BIN_INSTALL_DESTINATION@")
set(@META_PROJECT_VARNAME_UPPER@_LIB_DIR "@PACKAGE_LIB_INSTALL_DESTINATION@")
set(@META_PROJECT_VARNAME_UPPER@_MODULE_DIRS "@PACKAGE_CMAKE_MODULE_INSTALL_DESTINATION@")
set(@META_PROJECT_VARNAME_UPPER@_CONFIG_DIRS "@PACKAGE_CMAKE_CONFIG_INSTALL_DESTINATION@")
if(@META_PROJECT_VARNAME@_HAS_SHARED_LIB)
set(@META_PROJECT_VARNAME@_LIB "${@META_PROJECT_VARNAME@_SHARED_LIB}")
if(@META_PROJECT_VARNAME_UPPER@_HAS_SHARED_LIB)
set(@META_PROJECT_VARNAME_UPPER@_LIB "${@META_PROJECT_VARNAME_UPPER@_SHARED_LIB}")
else()
set(@META_PROJECT_VARNAME@_LIB "${@META_PROJECT_VARNAME@_STATIC_LIB}")
set(@META_PROJECT_VARNAME_UPPER@_LIB "${@META_PROJECT_VARNAME_UPPER@_STATIC_LIB}")
endif()
macro(use_@META_PROJECT_VARNAME@)
include_directories(BEFORE SYSTEM ${@META_PROJECT_VARNAME@_INCLUDE_DIRS})
link_directories(${@META_PROJECT_VARNAME@_LIB_DIR})
macro(use_@META_PROJECT_VARNAME_UPPER@)
include_directories(BEFORE SYSTEM ${@META_PROJECT_VARNAME_UPPER@_INCLUDE_DIRS})
link_directories(${@META_PROJECT_VARNAME_UPPER@_LIB_DIR})
# add library to list of libraries to link against when building dynamic libraries or applications
if(@META_PROJECT_VARNAME@_HAS_STATIC_LIB AND ((NOT ARGV0 AND ((STATIC_LINKAGE AND "${META_PROJECT_TYPE}" STREQUAL "application") OR (STATIC_LIBRARY_LINKAGE AND ("${META_PROJECT_TYPE}" STREQUAL "" OR "${META_PROJECT_TYPE}" STREQUAL "library")))) OR ("${ARGV0}" STREQUAL "STATIC") OR (NOT ARGV0 AND NOT @META_PROJECT_VARNAME@_HAS_SHARED_LIB)))
list(APPEND LIBRARIES ${@META_PROJECT_VARNAME@_STATIC_LIB} ${@META_PROJECT_VARNAME@_STATIC_LIB_DEPENDS})
message(STATUS "Linking ${META_PROJECT_NAME} statically against @META_PROJECT_NAME@ (${@META_PROJECT_VARNAME@_STATIC_LIB} ${@META_PROJECT_VARNAME@_STATIC_LIB_DEPENDS}).")
elseif(@META_PROJECT_VARNAME@_HAS_SHARED_LIB AND (NOT ARGV0 OR ("${ARGV0}" STREQUAL "SHARED")))
list(APPEND LIBRARIES ${@META_PROJECT_VARNAME@_SHARED_LIB})
message(STATUS "Linking ${META_PROJECT_NAME} dynamically against @META_PROJECT_NAME@ (${@META_PROJECT_VARNAME@_SHARED_LIB}).")
if(@META_PROJECT_VARNAME_UPPER@_HAS_STATIC_LIB AND ((NOT ARGV0 AND ((STATIC_LINKAGE AND "${META_PROJECT_TYPE}" STREQUAL "application") OR (STATIC_LIBRARY_LINKAGE AND ("${META_PROJECT_TYPE}" STREQUAL "" OR "${META_PROJECT_TYPE}" STREQUAL "library")))) OR ("${ARGV0}" STREQUAL "STATIC") OR (NOT ARGV0 AND NOT @META_PROJECT_VARNAME_UPPER@_HAS_SHARED_LIB)))
list(APPEND LIBRARIES ${@META_PROJECT_VARNAME_UPPER@_STATIC_LIB} ${@META_PROJECT_VARNAME_UPPER@_STATIC_LIB_DEPENDS})
message(STATUS "Linking ${META_PROJECT_NAME} statically against @META_PROJECT_NAME@ (${@META_PROJECT_VARNAME_UPPER@_STATIC_LIB} ${@META_PROJECT_VARNAME_UPPER@_STATIC_LIB_DEPENDS}).")
list(APPEND ADDITIONAL_STATIC_COMPILE_DEFINITIONS ${@META_PROJECT_VARNAME_UPPER@_STATIC_LIB_COMPILE_DEFINITIONS})
elseif(@META_PROJECT_VARNAME_UPPER@_HAS_SHARED_LIB AND (NOT ARGV0 OR ("${ARGV0}" STREQUAL "SHARED")))
list(APPEND LIBRARIES ${@META_PROJECT_VARNAME_UPPER@_SHARED_LIB})
message(STATUS "Linking ${META_PROJECT_NAME} dynamically against @META_PROJECT_NAME@ (${@META_PROJECT_VARNAME_UPPER@_SHARED_LIB}).")
list(APPEND ADDITIONAL_SHARED_COMPILE_DEFINITIONS ${@META_PROJECT_VARNAME_UPPER@_SHARED_LIB_COMPILE_DEFINITIONS})
elseif(ARGV0)
message(FATAL_ERROR "Can not link ${META_PROJECT_NAME} against @META_PROJECT_NAME@ with the specified linkage ${ARGV0}.")
else()
message(FATAL_ERROR "Can not link ${META_PROJECT_NAME} against @META_PROJECT_NAME@.")
endif()
# add library (including dependencies) to list of libraries to be provided as transitive dependencies when building static libraries
list(APPEND STATIC_LIBRARIES ${@META_PROJECT_VARNAME@_STATIC_LIB} ${@META_PROJECT_VARNAME@_STATIC_LIB_DEPENDS})
message(STATUS "Adding ${@META_PROJECT_VARNAME@_STATIC_LIB} ${@META_PROJECT_VARNAME@_STATIC_LIB_DEPENDS} to static library dependencies of ${META_PROJECT_NAME}.")
list(APPEND STATIC_LIBRARIES ${@META_PROJECT_VARNAME_UPPER@_STATIC_LIB} ${@META_PROJECT_VARNAME_UPPER@_STATIC_LIB_DEPENDS})
message(STATUS "Adding ${@META_PROJECT_VARNAME_UPPER@_STATIC_LIB} ${@META_PROJECT_VARNAME_UPPER@_STATIC_LIB_DEPENDS} to static library dependencies of ${META_PROJECT_NAME}.")
# make CMake modules of the project available
list(APPEND CMAKE_MODULE_PATH ${@META_PROJECT_VARNAME@_MODULE_DIRS})
list(APPEND CMAKE_MODULE_PATH ${@META_PROJECT_VARNAME_UPPER@_MODULE_DIRS})
endmacro()

@ -1,5 +1,8 @@
#ifndef APP_METADATA_AVAIL
#define APP_METADATA_AVAIL
// Created via CMake from template config.h.in
// WARNING! Any changes to this file will be overwritten by the next CMake run!
#ifndef APPLICATION_CONFIG
#define APPLICATION_CONFIG
#define PROJECT_NAME @META_PROJECT_NAME_STR@
#define APP_NAME @META_APP_NAME_STR@
@ -12,4 +15,4 @@
#cmakedefine SVG_SUPPORT
#cmakedefine SVG_ICON_SUPPORT
#endif // APP_METADATA_AVAIL
#endif // APPLICATION_CONFIG

@ -0,0 +1,17 @@
// Created via CMake from template global.h.in
// WARNING! Any changes to this file will be overwritten by the next CMake run!
#ifndef @META_PROJECT_VARNAME_UPPER@_GLOBAL
#define @META_PROJECT_VARNAME_UPPER@_GLOBAL
#include @GENERAL_GLOBAL_H_INCLUDE_PATH@
#ifdef @META_PROJECT_VARNAME_UPPER@_STATIC
# define @META_PROJECT_VARNAME_UPPER@_EXPORT
# define @META_PROJECT_VARNAME_UPPER@_IMPORT
#else
# define @META_PROJECT_VARNAME_UPPER@_EXPORT LIB_EXPORT
# define @META_PROJECT_VARNAME_UPPER@_IMPORT LIB_IMPORT
#endif
#endif // @META_PROJECT_VARNAME_UPPER@_GLOBAL

@ -10,4 +10,4 @@ URL: @META_APP_URL@
Libs: -L${libdir} -l@TARGET_PREFIX@@META_PROJECT_NAME@@TARGET_SUFFIX@
Libs.private: @META_STATIC_LIB_DEPENDS@
Cflags: -I${includedir} @META_REQUIRED_CFLAGS@
Cflags: -I${includedir}

@ -1,200 +1,200 @@
#ifndef CONVERSION_UTILITIES_BINARY_CONVERSION_H
#define CONVERSION_UTILITIES_BINARY_CONVERSION_H
#include "./types.h"
#include "../application/global.h"
#ifdef __BYTE_ORDER__
# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_LITTLE_ENDIAN false
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_BIG_ENDIAN true
# define CONVERSION_UTILITIES_BYTE_ORDER_BIG_ENDIAN
# elif __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_LITTLE_ENDIAN false
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_BIG_ENDIAN false
# define CONVERSION_UTILITIES_BYTE_ORDER_MIDDLE_ENDIAN
# elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_LITTLE_ENDIAN true
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_BIG_ENDIAN false
# define CONVERSION_UTILITIES_BYTE_ORDER_LITTLE_ENDIAN
# endif
#endif
#ifdef __FLOAT_WORD_ORDER__
# if __FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__
# define CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_BIG_ENDIAN
# elif __FLOAT_WORD_ORDER__ == __ORDER_PDP_ENDIAN__
# define CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_MIDDLE_ENDIAN
# elif __FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_LITTLE_ENDIAN
# endif
#endif
#if defined(__BYTE_ORDER__) && defined(__FLOAT_WORD_ORDER__)
#else
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) || defined(__LITTLE_ENDIAN__) || defined(_little_endian__) || defined(_LITTLE_ENDIAN) || defined(_WIN32_WCE) || defined(WINAPI_FAMILY)
# ifndef __BYTE_ORDER__
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_LITTLE_ENDIAN true
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_BIG_ENDIAN false
# define CONVERSION_UTILITIES_BYTE_ORDER_LITTLE_ENDIAN
# endif
# ifndef __FLOAT_WORD_ORDER__
# define CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_LITTLE_ENDIAN
# endif
# elif defined(__MIPSEB__) || defined(__s390__) || defined(__BIG_ENDIAN__) || defined(_big_endian__) || defined(_BIG_ENDIAN)
# ifndef __BYTE_ORDER__
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_LITTLE_ENDIAN false
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_BIG_ENDIAN true
# define CONVERSION_UTILITIES_BYTE_ORDER_BIG_ENDIAN
# endif
# ifndef __FLOAT_WORD_ORDER__
# define CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_BIG_ENDIAN
# endif
# else
# error "Unable to determine byte order!"
# endif
#endif
#if defined(CONVERSION_UTILITIES_BYTE_ORDER_MIDDLE_ENDIAN)
# error "Middle endian byte order is not supported!"
#endif
#if defined(CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_MIDDLE_ENDIAN)
# error "Middle endian byte order is not supported!"
#endif
/*!
* \namespace ConversionUtilities
* \brief Contains several functions providing conversions between different data types.
*
* binaryconversion.h declares functions which convert base data types to an array of bytes and vice versa.
* stringconversion.h declares different functions around string conversion such as converting a number to a string and vice versa.
*/
namespace ConversionUtilities
{
/*!
* \brief Encapsulates binary conversion functions using the big endian byte order.
* \sa <a href="http://en.wikipedia.org/wiki/Endianness">Endianness - Wikipedia</a>
*/
namespace BE {
#if defined(CONVERSION_UTILITIES_BYTE_ORDER_LITTLE_ENDIAN)
# define CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL 0
#elif defined(CONVERSION_UTILITIES_BYTE_ORDER_BIG_ENDIAN)
# define CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL 1
#endif
#include "./binaryconversionprivate.h"
#undef CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL
}
/*!
* \brief Encapsulates binary conversion functions using the little endian byte order.
* \sa <a href="http://en.wikipedia.org/wiki/Endianness">Endianness - Wikipedia</a>
*/
namespace LE {
#if defined(CONVERSION_UTILITIES_BYTE_ORDER_LITTLE_ENDIAN)
# define CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL 1
#elif defined(CONVERSION_UTILITIES_BYTE_ORDER_BIG_ENDIAN)
# define CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL 0
#endif
#include "./binaryconversionprivate.h"
#undef CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL
}
/*!
* \brief Returns the 8.8 fixed point representation converted from the specified 32-bit floating point number.
*/
LIB_EXPORT constexpr uint16 toFixed8(float32 float32value)
{
return static_cast<uint16>(float32value * 256.0f);
}
/*!
* \brief Returns a 32-bit floating point number converted from the specified 8.8 fixed point representation.
*/
LIB_EXPORT constexpr float32 toFloat32(uint16 fixed8value)
{
return static_cast<float32>(fixed8value) / 256.0f;
}
/*!
* \brief Returns the 16.16 fixed point representation converted from the specified 32-bit floating point number.
*/
LIB_EXPORT constexpr uint32 toFixed16(float32 float32value)
{
return static_cast<uint32>(float32value * 65536.0f);
}
/*!
* \brief Returns a 32-bit floating point number converted from the specified 16.16 fixed point representation.
*/
LIB_EXPORT constexpr float32 toFloat32(uint32 fixed16value)
{
return static_cast<float32>(fixed16value) / 65536.0f;
}
/*!
* \brief Returns a 32-bit synchsafe integer converted from a normal 32-bit integer.
* \remarks Synchsafe integers appear in ID3 tags that are attached to an MP3 file.
* \sa <a href="http://id3.org/id3v2.4.0-structure">ID3 tag version 2.4.0 - Main Structure</a>
*/
LIB_EXPORT constexpr uint32 toSynchsafeInt(uint32 normalInt)
{
return ((normalInt & 0x0000007fu) )
| ((normalInt & 0x00003f80u) << 1)
| ((normalInt & 0x001fc000u) << 2)
| ((normalInt & 0x0fe00000u) << 3);
}
/*!
* \brief Returns a normal 32-bit integer converted from a 32-bit synchsafe integer.
* \remarks Synchsafe integers appear in ID3 tags that are attached to an MP3 file.
* \sa <a href="http://id3.org/id3v2.4.0-structure">ID3 tag version 2.4.0 - Main Structure</a>
*/
LIB_EXPORT constexpr uint32 toNormalInt(uint32 synchsafeInt)
{
return ((synchsafeInt & 0x0000007fu) )
| ((synchsafeInt & 0x00007f00u) >> 1)
| ((synchsafeInt & 0x007f0000u) >> 2)
| ((synchsafeInt & 0x7f000000u) >> 3);
}
/*!
* \brief Swaps the byte order of the specified 16-bit unsigned integer.
*/
LIB_EXPORT constexpr uint16 swapOrder(uint16 value)
{
return (value >> 8) | (value << 8);
}
/*!
* \brief Swaps the byte order of the specified 32-bit unsigned integer.
*/
LIB_EXPORT constexpr uint32 swapOrder(uint32 value)
{
return (value >> 24)
| ((value & 0x00FF0000) >> 8)
| ((value & 0x0000FF00) << 8)
| (value << 24);
}
/*!
* \brief Swaps the byte order of the specified 64-bit unsigned integer.
*/
LIB_EXPORT constexpr uint64 swapOrder(uint64 value)
{
return(value >> (7 * 8))
| ((value & 0x00FF000000000000) >> (5 * 8))
| ((value & 0x0000FF0000000000) >> (3 * 8))
| ((value & 0x000000FF00000000) >> (1 * 8))
| ((value & 0x00000000FF000000) << (1 * 8))
| ((value & 0x0000000000FF0000) << (3 * 8))
| ((value & 0x000000000000FF00) << (5 * 8))
| ((value) << (7 * 8));
}
}
#endif // CONVERSION_UTILITIES_BINARY_CONVERSION_H
#ifndef CONVERSION_UTILITIES_BINARY_CONVERSION_H
#define CONVERSION_UTILITIES_BINARY_CONVERSION_H
#include "./types.h"
#include "../global.h"
#ifdef __BYTE_ORDER__
# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_LITTLE_ENDIAN false
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_BIG_ENDIAN true
# define CONVERSION_UTILITIES_BYTE_ORDER_BIG_ENDIAN
# elif __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_LITTLE_ENDIAN false
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_BIG_ENDIAN false
# define CONVERSION_UTILITIES_BYTE_ORDER_MIDDLE_ENDIAN
# elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_LITTLE_ENDIAN true
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_BIG_ENDIAN false
# define CONVERSION_UTILITIES_BYTE_ORDER_LITTLE_ENDIAN
# endif
#endif
#ifdef __FLOAT_WORD_ORDER__
# if __FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__
# define CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_BIG_ENDIAN
# elif __FLOAT_WORD_ORDER__ == __ORDER_PDP_ENDIAN__
# define CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_MIDDLE_ENDIAN
# elif __FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_LITTLE_ENDIAN
# endif
#endif
#if defined(__BYTE_ORDER__) && defined(__FLOAT_WORD_ORDER__)
#else
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) || defined(__LITTLE_ENDIAN__) || defined(_little_endian__) || defined(_LITTLE_ENDIAN) || defined(_WIN32_WCE) || defined(WINAPI_FAMILY)
# ifndef __BYTE_ORDER__
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_LITTLE_ENDIAN true
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_BIG_ENDIAN false
# define CONVERSION_UTILITIES_BYTE_ORDER_LITTLE_ENDIAN
# endif
# ifndef __FLOAT_WORD_ORDER__
# define CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_LITTLE_ENDIAN
# endif
# elif defined(__MIPSEB__) || defined(__s390__) || defined(__BIG_ENDIAN__) || defined(_big_endian__) || defined(_BIG_ENDIAN)
# ifndef __BYTE_ORDER__
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_LITTLE_ENDIAN false
# define CONVERSION_UTILITIES_IS_BYTE_ORDER_BIG_ENDIAN true
# define CONVERSION_UTILITIES_BYTE_ORDER_BIG_ENDIAN
# endif
# ifndef __FLOAT_WORD_ORDER__
# define CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_BIG_ENDIAN
# endif
# else
# error "Unable to determine byte order!"
# endif
#endif
#if defined(CONVERSION_UTILITIES_BYTE_ORDER_MIDDLE_ENDIAN)
# error "Middle endian byte order is not supported!"
#endif
#if defined(CONVERSION_UTILITIES_FLOAT_BYTE_ORDER_MIDDLE_ENDIAN)
# error "Middle endian byte order is not supported!"
#endif
/*!
* \namespace ConversionUtilities
* \brief Contains several functions providing conversions between different data types.
*
* binaryconversion.h declares functions which convert base data types to an array of bytes and vice versa.
* stringconversion.h declares different functions around string conversion such as converting a number to a string and vice versa.
*/
namespace ConversionUtilities
{
/*!
* \brief Encapsulates binary conversion functions using the big endian byte order.
* \sa <a href="http://en.wikipedia.org/wiki/Endianness">Endianness - Wikipedia</a>
*/
namespace BE {
#if defined(CONVERSION_UTILITIES_BYTE_ORDER_LITTLE_ENDIAN)
# define CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL 0
#elif defined(CONVERSION_UTILITIES_BYTE_ORDER_BIG_ENDIAN)
# define CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL 1
#endif
#include "./binaryconversionprivate.h"
#undef CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL
}
/*!
* \brief Encapsulates binary conversion functions using the little endian byte order.
* \sa <a href="http://en.wikipedia.org/wiki/Endianness">Endianness - Wikipedia</a>
*/
namespace LE {
#if defined(CONVERSION_UTILITIES_BYTE_ORDER_LITTLE_ENDIAN)
# define CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL 1
#elif defined(CONVERSION_UTILITIES_BYTE_ORDER_BIG_ENDIAN)
# define CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL 0
#endif
#include "./binaryconversionprivate.h"
#undef CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL
}
/*!
* \brief Returns the 8.8 fixed point representation converted from the specified 32-bit floating point number.
*/
CPP_UTILITIES_EXPORT constexpr uint16 toFixed8(float32 float32value)
{
return static_cast<uint16>(float32value * 256.0f);
}
/*!
* \brief Returns a 32-bit floating point number converted from the specified 8.8 fixed point representation.
*/
CPP_UTILITIES_EXPORT constexpr float32 toFloat32(uint16 fixed8value)
{
return static_cast<float32>(fixed8value) / 256.0f;
}
/*!
* \brief Returns the 16.16 fixed point representation converted from the specified 32-bit floating point number.
*/
CPP_UTILITIES_EXPORT constexpr uint32 toFixed16(float32 float32value)
{
return static_cast<uint32>(float32value * 65536.0f);
}
/*!
* \brief Returns a 32-bit floating point number converted from the specified 16.16 fixed point representation.
*/
CPP_UTILITIES_EXPORT constexpr float32 toFloat32(uint32 fixed16value)
{
return static_cast<float32>(fixed16value) / 65536.0f;
}
/*!
* \brief Returns a 32-bit synchsafe integer converted from a normal 32-bit integer.
* \remarks Synchsafe integers appear in ID3 tags that are attached to an MP3 file.
* \sa <a href="http://id3.org/id3v2.4.0-structure">ID3 tag version 2.4.0 - Main Structure</a>
*/
CPP_UTILITIES_EXPORT constexpr uint32 toSynchsafeInt(uint32 normalInt)
{
return ((normalInt & 0x0000007fu) )
| ((normalInt & 0x00003f80u) << 1)
| ((normalInt & 0x001fc000u) << 2)
| ((normalInt & 0x0fe00000u) << 3);
}
/*!
* \brief Returns a normal 32-bit integer converted from a 32-bit synchsafe integer.
* \remarks Synchsafe integers appear in ID3 tags that are attached to an MP3 file.
* \sa <a href="http://id3.org/id3v2.4.0-structure">ID3 tag version 2.4.0 - Main Structure</a>
*/
CPP_UTILITIES_EXPORT constexpr uint32 toNormalInt(uint32 synchsafeInt)
{
return ((synchsafeInt & 0x0000007fu) )
| ((synchsafeInt & 0x00007f00u) >> 1)
| ((synchsafeInt & 0x007f0000u) >> 2)
| ((synchsafeInt & 0x7f000000u) >> 3);
}
/*!
* \brief Swaps the byte order of the specified 16-bit unsigned integer.
*/
CPP_UTILITIES_EXPORT constexpr uint16 swapOrder(uint16 value)
{
return (value >> 8) | (value << 8);
}
/*!
* \brief Swaps the byte order of the specified 32-bit unsigned integer.
*/
CPP_UTILITIES_EXPORT constexpr uint32 swapOrder(uint32 value)
{
return (value >> 24)
| ((value & 0x00FF0000) >> 8)
| ((value & 0x0000FF00) << 8)
| (value << 24);
}
/*!
* \brief Swaps the byte order of the specified 64-bit unsigned integer.
*/
CPP_UTILITIES_EXPORT constexpr uint64 swapOrder(uint64 value)
{
return(value >> (7 * 8))
| ((value & 0x00FF000000000000) >> (5 * 8))
| ((value & 0x0000FF0000000000) >> (3 * 8))
| ((value & 0x000000FF00000000) >> (1 * 8))
| ((value & 0x00000000FF000000) << (1 * 8))
| ((value & 0x0000000000FF0000) << (3 * 8))
| ((value & 0x000000000000FF00) << (5 * 8))
| ((value) << (7 * 8));
}
}
#endif // CONVERSION_UTILITIES_BINARY_CONVERSION_H

@ -6,12 +6,12 @@
#include "./types.h"
#include "../application/global.h"
#include "../global.h"
/*!
* \brief Returns a 16-bit signed integer converted from two bytes at a specified position in a char array.
*/
LIB_EXPORT inline int16 toInt16(const char *value)
CPP_UTILITIES_EXPORT inline int16 toInt16(const char *value)
{
#if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
return (static_cast<int16>(value[0]) << 8 & 0xFF00)
@ -25,7 +25,7 @@ LIB_EXPORT inline int16 toInt16(const char *value)
/*!
* \brief Returns a 16-bit unsigned integer converted from two bytes at a specified position in a char array.
*/
LIB_EXPORT inline uint16 toUInt16(const char *value)
CPP_UTILITIES_EXPORT inline uint16 toUInt16(const char *value)
{
#if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
return (static_cast<uint16>(value[0]) << 8 & 0xFF00)
@ -39,7 +39,7 @@ LIB_EXPORT inline uint16 toUInt16(const char *value)
/*!
* \brief Returns a 32-bit signed integer converted from four bytes at a specified position in a char array.
*/
LIB_EXPORT inline int32 toInt32(const char *value)
CPP_UTILITIES_EXPORT inline int32 toInt32(const char *value)
{
#if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
return (static_cast<int32>(value[0]) << 24 & 0xFF000000)
@ -57,7 +57,7 @@ LIB_EXPORT inline int32 toInt32(const char *value)
/*!
* \brief Returns a 32-bit unsigned integer converted from three bytes at a specified position in a char array.
*/
LIB_EXPORT inline uint32 toUInt24(const char *value)
CPP_UTILITIES_EXPORT inline uint32 toUInt24(const char *value)
{
#if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
return (static_cast<uint32>(value[0]) << 16 & 0x00FF0000)
@ -73,7 +73,7 @@ LIB_EXPORT inline uint32 toUInt24(const char *value)
/*!
* \brief Returns a 32-bit unsigned integer converted from four bytes at a specified position in a char array.
*/
LIB_EXPORT inline uint32 toUInt32(const char *value)
CPP_UTILITIES_EXPORT inline uint32 toUInt32(const char *value)
{
#if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
return (static_cast<uint32>(value[0]) << 24 & 0xFF000000)
@ -91,7 +91,7 @@ LIB_EXPORT inline uint32 toUInt32(const char *value)
/*!
* \brief Returns a 64-bit signed integer converted from eight bytes at a specified position in a char array.
*/
LIB_EXPORT inline int64 toInt64(const char *value)
CPP_UTILITIES_EXPORT inline int64 toInt64(const char *value)
{
#if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
return (static_cast<int64>(value[0]) << 56 & 0xFF00000000000000)
@ -117,7 +117,7 @@ LIB_EXPORT inline int64 toInt64(const char *value)
/*!
* \brief Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a char array.
*/
LIB_EXPORT inline uint64 toUInt64(const char *value)
CPP_UTILITIES_EXPORT inline uint64 toUInt64(const char *value)
{
#if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
return (static_cast<uint64>(value[0]) << 56 & 0xFF00000000000000)
@ -143,7 +143,7 @@ LIB_EXPORT inline uint64 toUInt64(const char *value)
/*!
* \brief Returns a 32-bit floating point number converted from four bytes at a specified position in a char array.
*/
LIB_EXPORT inline float32 toFloat32(const char *value)
CPP_UTILITIES_EXPORT inline float32 toFloat32(const char *value)
{
#if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
int32 val = toInt32(value);
@ -159,7 +159,7 @@ LIB_EXPORT inline float32 toFloat32(const char *value)
/*!
* \brief Returns a 64-bit floating point number converted from eight bytes at a specified position in a char array.
*/
LIB_EXPORT inline float64 toFloat64(const char *value)
CPP_UTILITIES_EXPORT inline float64 toFloat64(const char *value)
{
#if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
int64 val = toInt64(value);
@ -175,7 +175,7 @@ LIB_EXPORT inline float64 toFloat64(const char *value)
/*!
* \brief Stores the specified 16-bit signed integer value at a specified position in a char array.
*/
LIB_EXPORT inline void getBytes(int16 value, char *outputbuffer)
CPP_UTILITIES_EXPORT inline void getBytes(int16 value, char *outputbuffer)
{
#if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
outputbuffer[0] = static_cast<char>((value >> 8) & 0xFF);
@ -189,7 +189,7 @@ LIB_EXPORT inline void getBytes(int16 value, char *outputbuffer)
/*!
* \brief Stores the specified 16-bit unsigned integer value at a specified position in a char array.
*/
LIB_EXPORT inline void getBytes(uint16 value, char *outputbuffer)
CPP_UTILITIES_EXPORT inline void getBytes(uint16 value, char *outputbuffer)
{
#if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
outputbuffer[0] = static_cast<char>((value >> 8) & 0xFF);
@ -204,7 +204,7 @@ LIB_EXPORT inline void getBytes(uint16 value, char *outputbuffer)
* \brief Stores the specified 24-bit unsigned integer value at a specified position in a char array.
* \remarks Ignores the most significant byte.
*/
LIB_EXPORT inline void getBytes24(uint32 value, char *outputbuffer)
CPP_UTILITIES_EXPORT inline void getBytes24(uint32 value, char *outputbuffer)
{
#if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
outputbuffer[0] = static_cast<char>((value >> 16) & 0xFF);
@ -220,7 +220,7 @@ LIB_EXPORT inline void getBytes24(uint32 value, char *outputbuffer)
/*!
* \brief Stores the specified 32-bit signed integer value at a specified position in a char array.
*/
LIB_EXPORT inline void getBytes(int32 value, char *outputbuffer)
CPP_UTILITIES_EXPORT inline void getBytes(int32 value, char *outputbuffer)
{
#if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
outputbuffer[0] = static_cast<char>((value >> 24) & 0xFF);
@ -238,7 +238,7 @@ LIB_EXPORT inline void getBytes(int32 value, char *outputbuffer)
/*!
* \brief Stores the specified 32-bit signed integer value at a specified position in a char array.
*/
LIB_EXPORT inline void getBytes(uint32 value, char *outputbuffer)
CPP_UTILITIES_EXPORT inline void getBytes(uint32 value, char *outputbuffer)
{
#if CONVERSION_UTILITIES_BINARY_CONVERSION_INTERNAL == 0
outputbuffer[0] = static_cast<char>((value >> 24) & 0xFF);
@ -256,7 +256,7 @@ LIB_EXPORT inline void getBytes(uint32 value, char *outputbuffer)
/*!
* \brief Stores the specified 64-bit signed integer value at a specified position