Mercurial > code
changeset 648:5bd9424a523a
misc: extreme cleanup
line wrap: on
line diff
--- a/.editorconfig Wed Aug 01 14:08:40 2018 +0200 +++ b/.editorconfig Thu Oct 04 21:17:55 2018 +0200 @@ -4,6 +4,6 @@ charset = utf-8 end_of_line = lf insert_final_newline = true -indent_style = space -indent_size = 4 trim_trailing_whitespace = true +indent_style = tab +indent_size = 8
--- a/CMakeLists.txt Wed Aug 01 14:08:40 2018 +0200 +++ b/CMakeLists.txt Thu Oct 04 21:17:55 2018 +0200 @@ -23,15 +23,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED On) if (CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") - set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic ${CMAKE_CXX_FLAGS}") - set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_FLAGS_DEBUG}") + set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_FLAGS_DEBUG}") endif () -# Doxygen target. find_package(Doxygen) find_package(Boost REQUIRED COMPONENTS unit_test_framework) -# Extern packages. add_subdirectory(extern/json) enable_testing() @@ -41,11 +39,11 @@ # ------------------------------------------------------------------- # # code_define_module( -# NAME lowercase name -# SOURCES source files -# LIBRARIES (Optional) libraries -# INCLUDES (Optional) include directories -# FLAGS (Optional) flags +# NAME lowercase name +# SOURCES source files +# LIBRARIES (Optional) libraries +# INCLUDES (Optional) include directories +# FLAGS (Optional) flags # ) # # Create a test for the given module. @@ -55,73 +53,72 @@ # If the module has a file test/main.cpp in its directory, a target test-<NAME> is created. # function(code_define_module) - set(oneValueArgs NAME) - set(multiValueArgs SOURCES LIBRARIES INCLUDES FLAGS) + set(oneValueArgs NAME) + set(multiValueArgs SOURCES LIBRARIES INCLUDES FLAGS) - cmake_parse_arguments(MOD "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(MOD "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if (NOT MOD_NAME) - message(FATAL_ERROR "Argument NAME is not set") - endif () + if (NOT MOD_NAME) + message(FATAL_ERROR "Argument NAME is not set") + endif () - # Create the option for enabling the test. - string(TOUPPER ${MOD_NAME} optionname) - option(WITH_${optionname} "Enable ${MOD_NAME}" On) + # Create the option for enabling the test. + string(TOUPPER ${MOD_NAME} optionname) + option(WITH_${optionname} "Enable ${MOD_NAME}" On) - if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/main.cpp AND WITH_${optionname}) - # Create test executable. - add_executable(test-${MOD_NAME} ${MOD_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/test/main.cpp) - set_target_properties( - test-${MOD_NAME} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} - RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR} - RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR} - RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR} - RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_BINARY_DIR} - ) - target_compile_definitions( - test-${MOD_NAME} - PRIVATE - BOOST_TEST_DYN_LINK - ${MOD_FLAGS} - ) - target_include_directories( - test-${MOD_NAME} - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${MOD_INCLUDES} - ) - target_link_libraries( - test-${MOD_NAME} - Boost::unit_test_framework - ${MOD_LIBRARIES} - ) + if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/main.cpp AND WITH_${optionname}) + add_executable(test-${MOD_NAME} ${MOD_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/test/main.cpp) + set_target_properties( + test-${MOD_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} + RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR} + RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR} + RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR} + RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_BINARY_DIR} + ) + target_compile_definitions( + test-${MOD_NAME} + PRIVATE + BOOST_TEST_DYN_LINK + ${MOD_FLAGS} + ) + target_include_directories( + test-${MOD_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${MOD_INCLUDES} + ) + target_link_libraries( + test-${MOD_NAME} + Boost::unit_test_framework + ${MOD_LIBRARIES} + ) - # Register the test. - add_test( - NAME ${MOD_NAME} - COMMAND test-${MOD_NAME} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - endif () + # Register the test. + add_test( + NAME ${MOD_NAME} + COMMAND test-${MOD_NAME} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + endif () endfunction() if (DOXYGEN_FOUND) - set(DOXYGEN_PROJECT_NAME code) - set(DOXYGEN_STRIP_FROM_PATH ${code_SOURCE_DIR}/cpp) - set(DOXYGEN_FILE_PATTERNS "*.hpp") - set(DOXYGEN_WARN_NO_PARAMDOC YES) - set(DOXYGEN_WARN_AS_ERROR YES) - set(DOXYGEN_QUIET YES) + set(DOXYGEN_PROJECT_NAME code) + set(DOXYGEN_STRIP_FROM_PATH ${code_SOURCE_DIR}/cpp) + set(DOXYGEN_FILE_PATTERNS "*.hpp") + set(DOXYGEN_WARN_NO_PARAMDOC YES) + set(DOXYGEN_WARN_AS_ERROR YES) + set(DOXYGEN_QUIET YES) - doxygen_add_docs( - doxygen - ${code_SOURCE_DIR}/cpp - WORKING_DIRECTORY ${code_SOURCE_DIR} - ) + doxygen_add_docs( + doxygen + ${code_SOURCE_DIR}/cpp + WORKING_DIRECTORY ${code_SOURCE_DIR} + ) - add_custom_target(docs ALL DEPENDS doxygen) + add_custom_target(docs ALL DEPENDS doxygen) endif () add_subdirectory(cpp)
--- a/README.md Wed Aug 01 14:08:40 2018 +0200 +++ b/README.md Thu Oct 04 21:17:55 2018 +0200 @@ -1,30 +1,3 @@ # Common code This repository contains common code reusable in C++. - -## Status - -The following status are defined: - - - **Frozen**, the module will not changed and only have bugfixes, - - **Stable**, the module is stable but may still change a little bit, - - **Testing**, the module is being tested and may change, - - **Experimental**, the module is new and completely experimental or unstable, - - **New**, the module is completely new. - -| Module | Status | Tests quality | -|---------------|--------------|---------------| -| base64 | Frozen | \*\*\*\*\* | -| converter | Experimental | no tests | -| date | Experimental | no tests | -| dynlib | Frozen | \*\*\* | -| elapsed-timer | Stable | \*\*\* | -| fs | Experimental | \* | -| hash | Frozen | \*\*\*\* | -| ini | Stable | \*\*\*\* | -| js | New | \* | -| net | Experimental | \*\* | -| options | New | \*\*\* | -| unicode | Frozen | \*\*\* | -| xdg | Frozen | \* | -| zip | Stable | \*\* |
--- a/c/asprintf/asprintf.c Wed Aug 01 14:08:40 2018 +0200 +++ b/c/asprintf/asprintf.c Thu Oct 04 21:17:55 2018 +0200 @@ -39,17 +39,17 @@ int vasprintf(char **res, const char *fmt, va_list ap) { - int total = _vscprintf(fmt, ap); + int total = _vscprintf(fmt, ap); - if (total < 0) { - *res = NULL; - return -1; - } + if (total < 0) { + *res = NULL; + return -1; + } - if ((*res = (char *)malloc(sizeof (total) + 1)) == NULL) - return -1; + if ((*res = (char *)malloc(sizeof (total) + 1)) == NULL) + return -1; - return vsprintf_s(*res, total + 1, fmt, ap); + return vsprintf_s(*res, total + 1, fmt, ap); } #elif __STDC_VERSION__ >= 199901L @@ -60,29 +60,29 @@ int vasprintf(char **res, const char *fmt, va_list ap) { - int total, nwritten; - va_list copy; + int total, nwritten; + va_list copy; - va_copy(copy, ap); - total = vsnprintf(NULL, 0, fmt, copy); - va_end(copy); + va_copy(copy, ap); + total = vsnprintf(NULL, 0, fmt, copy); + va_end(copy); - if (total < 0) { - *res = NULL; - return total; - } + if (total < 0) { + *res = NULL; + return total; + } - if ((*res = malloc(total + 1)) == NULL) - return -1; + if ((*res = malloc(total + 1)) == NULL) + return -1; - if ((nwritten = vsnprintf(*res, total + 1, fmt, ap)) < 0) { - free(*res); - *res = NULL; + if ((nwritten = vsnprintf(*res, total + 1, fmt, ap)) < 0) { + free(*res); + *res = NULL; - return -1; - } + return -1; + } - return nwritten; + return nwritten; } #else @@ -93,24 +93,24 @@ int vasprintf(char **res, const char *format, va_list ap) { - int rvalue, ok; - size_t base = 80; + int rvalue, ok; + size_t base = 80; - if ((*res = malloc(base)) == NULL) - return -1; + if ((*res = malloc(base)) == NULL) + return -1; - ok = 0; - do { - rvalue = vsnprintf(*res, base, format, ap); + ok = 0; + do { + rvalue = vsnprintf(*res, base, format, ap); - if ((signed int)base <= rvalue || rvalue < 0) { - *res = realloc(*res, base * 2); - base *= 2; - } else - ok = 1; - } while (!ok && *res != NULL); + if ((signed int)base <= rvalue || rvalue < 0) { + *res = realloc(*res, base * 2); + base *= 2; + } else + ok = 1; + } while (!ok && *res != NULL); - return rvalue; + return rvalue; } #endif @@ -118,12 +118,12 @@ int asprintf(char **res, const char *fmt, ...) { - va_list ap; - int rvalue; + va_list ap; + int rvalue; - va_start(ap, fmt); - rvalue = vasprintf(res, fmt, ap); - va_end(ap); + va_start(ap, fmt); + rvalue = vasprintf(res, fmt, ap); + va_end(ap); - return rvalue; + return rvalue; }
--- a/c/asprintf/asprintf.h Wed Aug 01 14:08:40 2018 +0200 +++ b/c/asprintf/asprintf.h Thu Oct 04 21:17:55 2018 +0200 @@ -26,9 +26,9 @@ #endif #ifdef __GNUC__ -# define ASPRINTF_FMT(i1, i2) __attribute__ ((format (printf, i1, i2))) +# define ASPRINTF_FMT(i1, i2) __attribute__ ((format (printf, i1, i2))) #else -# define ASPRINTF_FMT(i1, i2) +# define ASPRINTF_FMT(i1, i2) #endif int
--- a/c/err/err.c Wed Aug 01 14:08:40 2018 +0200 +++ b/c/err/err.c Thu Oct 04 21:17:55 2018 +0200 @@ -33,82 +33,82 @@ void err(int val, const char *fmt, ...) { - va_list ap; + va_list ap; - va_start(ap, fmt); - verr(val, fmt, ap); - va_end(ap); + va_start(ap, fmt); + verr(val, fmt, ap); + va_end(ap); } void verr(int val, const char *fmt, va_list ap) { - if (fmt) { - vfprintf(stderr, fmt, ap); - fprintf(stderr, ": "); - } + if (fmt) { + vfprintf(stderr, fmt, ap); + fprintf(stderr, ": "); + } - fprintf(stderr, "%s\n", strerror(errno)); - exit(val); + fprintf(stderr, "%s\n", strerror(errno)); + exit(val); } void errx(int val, const char *fmt, ...) { - va_list ap; + va_list ap; - va_start(ap, fmt); - verrx(val, fmt, ap); - va_end(ap); + va_start(ap, fmt); + verrx(val, fmt, ap); + va_end(ap); } void verrx(int val, const char *fmt, va_list ap) { - if (fmt) - vfprintf(stderr, fmt, ap); + if (fmt) + vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); + fprintf(stderr, "\n"); - exit(val); + exit(val); } void warn(const char *fmt, ...) { - va_list ap; + va_list ap; - va_start(ap, fmt); - vwarn(fmt, ap); - va_end(ap); + va_start(ap, fmt); + vwarn(fmt, ap); + va_end(ap); } void vwarn(const char *fmt, va_list ap) { - if (fmt) { - vfprintf(stderr, fmt, ap); - fprintf(stderr, ": "); - } + if (fmt) { + vfprintf(stderr, fmt, ap); + fprintf(stderr, ": "); + } - fprintf(stderr, "%s\n", strerror(errno)); + fprintf(stderr, "%s\n", strerror(errno)); } void warnx(const char *fmt, ...) { - va_list ap; + va_list ap; - va_start(ap, fmt); - vwarnx(fmt, ap); - va_end(ap); + va_start(ap, fmt); + vwarnx(fmt, ap); + va_end(ap); } void vwarnx(const char *fmt, va_list ap) { - if (fmt) - vfprintf(stderr, fmt, ap); + if (fmt) + vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); + fprintf(stderr, "\n"); }
--- a/c/err/err.h Wed Aug 01 14:08:40 2018 +0200 +++ b/c/err/err.h Thu Oct 04 21:17:55 2018 +0200 @@ -26,9 +26,9 @@ #endif #if defined(__GNUC__) -# define ERR_NORETURN __attribute__ ((noreturn)) +# define ERR_NORETURN __attribute__ ((noreturn)) #elif defined(_MSC_VER) -# define ERR_NORETURN __declspec(noreturn) +# define ERR_NORETURN __declspec(noreturn) #endif void
--- a/c/setprogname/setprogname.c Wed Aug 01 14:08:40 2018 +0200 +++ b/c/setprogname/setprogname.c Thu Oct 04 21:17:55 2018 +0200 @@ -29,17 +29,17 @@ void setprogname(const char *progname) { - const char *p; + const char *p; - /* Seek last / or \ on windows */ - if ((p = strrchr(progname, '/')) || (p = strrchr(progname, '\\'))) - g_pname = &p[1]; - else - g_pname = progname; + /* Seek last / or \ on windows */ + if ((p = strrchr(progname, '/')) || (p = strrchr(progname, '\\'))) + g_pname = &p[1]; + else + g_pname = progname; } const char * getprogname(void) { - return g_pname; + return g_pname; }
--- a/c/strdup/strdup.c Wed Aug 01 14:08:40 2018 +0200 +++ b/c/strdup/strdup.c Thu Oct 04 21:17:55 2018 +0200 @@ -23,13 +23,13 @@ char * strdup(const char *src) { - char *dst; - size_t len; + char *dst; + size_t len; - len = strlen(src); + len = strlen(src); - if ((dst = calloc(len + 1, sizeof (char))) == NULL) - return NULL; + if ((dst = calloc(len + 1, sizeof (char))) == NULL) + return NULL; - return strcpy(dst, src); + return strcpy(dst, src); }
--- a/c/strndup/strndup.c Wed Aug 01 14:08:40 2018 +0200 +++ b/c/strndup/strndup.c Thu Oct 04 21:17:55 2018 +0200 @@ -23,14 +23,14 @@ char * strndup(const char *src, size_t len) { - size_t tocopy; - char *dst; + size_t tocopy; + char *dst; - for (tocopy = 0; tocopy < len && src[tocopy] != '\0'; ++tocopy) - continue; + for (tocopy = 0; tocopy < len && src[tocopy] != '\0'; ++tocopy) + continue; - if ((dst = calloc(tocopy + 1, 1)) != NULL) - strncpy(dst, src, tocopy); + if ((dst = calloc(tocopy + 1, 1)) != NULL) + strncpy(dst, src, tocopy); - return dst; + return dst; }
--- a/c/strsep/strsep.c Wed Aug 01 14:08:40 2018 +0200 +++ b/c/strsep/strsep.c Thu Oct 04 21:17:55 2018 +0200 @@ -22,19 +22,19 @@ char * strsep(char **stringp, const char *delim) { - char *item, *ptr; + char *item, *ptr; - if (*stringp == NULL || delim[0] == '\0') - return NULL; + if (*stringp == NULL || delim[0] == '\0') + return NULL; - item = *stringp; - if ((ptr = strpbrk(*stringp, delim)) == NULL) { - *stringp = NULL; - return item; - } + item = *stringp; + if ((ptr = strpbrk(*stringp, delim)) == NULL) { + *stringp = NULL; + return item; + } - *ptr = '\0'; - *stringp = ptr + 1; + *ptr = '\0'; + *stringp = ptr + 1; - return item; + return item; }
--- a/cmake/FindEditline.cmake Wed Aug 01 14:08:40 2018 +0200 +++ b/cmake/FindEditline.cmake Thu Oct 04 21:17:55 2018 +0200 @@ -13,9 +13,9 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args( - Editline - FOUND_VAR Editline_FOUND - REQUIRED_VARS Editline_LIBRARY Editline_INCLUDE_DIR + Editline + FOUND_VAR Editline_FOUND + REQUIRED_VARS Editline_LIBRARY Editline_INCLUDE_DIR ) set(Editline_LIBRARIES ${Editline_LIBRARY})
--- a/cmake/FindHunspell.cmake Wed Aug 01 14:08:40 2018 +0200 +++ b/cmake/FindHunspell.cmake Thu Oct 04 21:17:55 2018 +0200 @@ -8,18 +8,18 @@ # Hunspell_FOUND, if it is found find_path( - Hunspell_INCLUDE_DIR - NAMES hunspell.hxx - PATH_SUFFIXES hunspell + Hunspell_INCLUDE_DIR + NAMES hunspell.hxx + PATH_SUFFIXES hunspell ) find_library(Hunspell_LIBRARY NAMES libhunspell hunspell) include(FindPackageHandleStandardArgs) find_package_handle_standard_args( - Hunspell - FOUND_VAR Hunspell_FOUND - REQUIRED_VARS Hunspell_LIBRARY Hunspell_INCLUDE_DIR + Hunspell + FOUND_VAR Hunspell_FOUND + REQUIRED_VARS Hunspell_LIBRARY Hunspell_INCLUDE_DIR ) set(Hunspell_LIBRARIES ${Hunspell_LIBRARY})
--- a/cmake/FindIrrlicht.cmake Wed Aug 01 14:08:40 2018 +0200 +++ b/cmake/FindIrrlicht.cmake Thu Oct 04 21:17:55 2018 +0200 @@ -8,22 +8,22 @@ # Irrlicht_INCLUDE_DIR, where to find irrlicht.h find_path( - Irrlicht_INCLUDE_DIR - NAMES irrlicht.h - PATH_SUFFIXES include/irrlicht + Irrlicht_INCLUDE_DIR + NAMES irrlicht.h + PATH_SUFFIXES include/irrlicht ) find_library( - Irrlicht_LIBRARY - NAMES Irrlicht libIrrlicht + Irrlicht_LIBRARY + NAMES Irrlicht libIrrlicht ) include(FindPackageHandleStandardArgs) find_package_handle_standard_args( - Irrlicht - FOUND_VAR Irrlicht_FOUND - REQUIRED_VARS Irrlicht_LIBRARY Irrlicht_INCLUDE_DIR + Irrlicht + FOUND_VAR Irrlicht_FOUND + REQUIRED_VARS Irrlicht_LIBRARY Irrlicht_INCLUDE_DIR ) set(Irrlicht_LIBRARIES ${Irrlicht_LIBRARY})
--- a/cmake/FindJansson.cmake Wed Aug 01 14:08:40 2018 +0200 +++ b/cmake/FindJansson.cmake Thu Oct 04 21:17:55 2018 +0200 @@ -13,9 +13,9 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args( - Jansson - FOUND_VAR Jansson_FOUND - REQUIRED_VARS Jansson_LIBRARY Jansson_INCLUDE_DIR + Jansson + FOUND_VAR Jansson_FOUND + REQUIRED_VARS Jansson_LIBRARY Jansson_INCLUDE_DIR ) set(Jansson_LIBRARIES ${Jansson_LIBRARY})
--- a/cmake/FindKDChart.cmake Wed Aug 01 14:08:40 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -# FindKDChart -# ----------- -# -# Find KDChart library, this modules defines: -# -# KDChart_FOUND Set to TRUE if KDChart was found. -# KDChart_LIBRARIES Path to KDChart libraries. -# KDChart_INCLUDE_DIRS Path to the KDChart include directory. - -find_package(Qt5Widgets QUIET) -find_package(Qt5PrintSupport QUIET) - -find_library(KDChart_LIBRARY NAMES KDChart2 KDChartd2 kdchart2 kdchartd2) - -find_path( - KDChart_Chart_INCLUDE_DIR - NAMES KDChart KDChartGlobal - PATH_SUFFIXES KDChart -) - -find_path( - KDChart_Gantt_INCLUDE_DIR - NAMES KDGantt KDGanttGlobal - PATH_SUFFIXES KDGantt -) - -include(FindPackageHandleStandardArgs) - -find_package_handle_standard_args( - KDChart - FOUND_VAR KDChart_FOUND - REQUIRED_VARS KDChart_LIBRARY KDChart_Chart_INCLUDE_DIR KDChart_Gantt_INCLUDE_DIR Qt5Widgets_FOUND Qt5PrintSupport_FOUND -) - -set(KDChart_LIBRARIES ${KDChart_LIBRARY} Qt5::Widgets Qt5::PrintSupport) -set(KDChart_INCLUDE_DIRS ${KDChart_Chart_INCLUDE_DIR} ${KDChart_Gantt_INCLUDE_DIR}) - -mark_as_advanced(KDChart_LIBRARIES KDChart_INCLUDE_DIR)
--- a/cmake/FindNLS.cmake Wed Aug 01 14:08:40 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -# FindNLS -# ------- -# -# NLS_INCLUDE_DIRS, where to find libintl.h -# NLS_LIBRARIES, where to find library -# NLS_FOUND, if it is found - -include(CheckFunctionExists) - -# find libintl.h -find_path(NLS_INCLUDE_DIR libintl.h) - -# find libintl.so -find_library(NLS_LIBRARY NAMES libintl intl) - -# On Linux gettext is directly in libc -if (NOT NLS_LIBRARY) - check_function_exists(gettext _HAVE_GETTEXT_FUNC) - check_function_exists(bindtextdomain _HAVE_BINDTEXTDOMAIN_FUNC) - set(NLS_LIBRARY "c") -endif () - -include(FindPackageHandleStandardArgs) - -find_package_handle_standard_args( - NLS - REQUIRED_VARS NLS_INCLUDE_DIR NLS_LIBRARY -) - -if (NLS_FOUND) - set(NLS_INCLUDE_DIRS ${NLS_INCLUDE_DIR}) - set(NLS_LIBRARIES ${NLS_LIBRARIES}) -endif () - -mark_as_advanced(NLS_INCLUDE_DIR NLS_LIBRARY)
--- a/cmake/FindNode.cmake Wed Aug 01 14:08:40 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -# FindNode -# -------- -# -# Find Node.js, this module defines: -# -# Node_FOUND, if node was found -# Node_EXECUTABLE, where to find node executable -# Node_VERSION, the version (without leading `v') - -find_program( - Node_EXECUTABLE - NAMES node - DOC "Node executable" -) - -include(FindPackageHandleStandardArgs) - -# Extract the version -if (Node_EXECUTABLE) - execute_process( - COMMAND ${Node_EXECUTABLE} --version - OUTPUT_VARIABLE _node_version_tmp - ) - - if (_node_version_tmp MATCHES "^v([0-9]+\\.[0-9]+\\.[0-9]+)") - set(Node_VERSION "${CMAKE_MATCH_1}") - endif () -endif () - -find_package_handle_standard_args( - Node - FOUND_VAR Node_FOUND Node_VERSION - REQUIRED_VARS Node_EXECUTABLE - VERSION_VAR Node_VERSION -)
--- a/cmake/FindOCC.cmake Wed Aug 01 14:08:40 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -# FindOCC -# ------- -# -# Find vanilla OpenCascade libraries. It has *not* been tested with OpenCascade -# community edition. -# -# This modules defines: -# OCC_INCLUDE_DIRS, where to find OSD.hxx -# OCC_LIBRARIES, where to find components libraries -# OCC_FOUND, if it is found -# -# This module understand components. Just pass the library name to -# the components variable and the following variables will -# be defined: -# -# e.g find_package(OCC COMPONENTS TKbool) -# -# OCC_Xxx_LIBRARY where to find the library -# OCC_Xxx_FOUND if the variable is found -# -# The OCC_LIBRARIES is automatically filled with all components. - -include(FindPackageMessage) - -# find OSD.hxx -find_path( - OCC_INCLUDE_DIR OSD.hxx - PATH_SUFFIXES - OpenCASCADE - inc -) - -foreach (c ${OCC_FIND_COMPONENTS}) - find_library( - OCC_${c}_LIBRARY ${c} - PATH_SUFFIXES - win32/vc11/lib - ) - - if (OCC_${c}_LIBRARY) - set(OCC_${c}_FOUND TRUE) - list(APPEND OCC_LIBRARIES ${OCC_${c}_LIBRARY}) - mark_as_advanced(OCC_${c}_LIBRARY) - endif () -endforeach () - -include(FindPackageHandleStandardArgs) - -find_package_handle_standard_args( - OCC - HANDLE_COMPONENTS - REQUIRED_VARS OCC_INCLUDE_DIR -) - -if (OCC_FOUND) - set(OCC_INCLUDE_DIRS ${OCC_INCLUDE_DIR}) -endif () - -mark_as_advanced(OCC_INCLUDE_DIR OCC_LIBRARIES)
--- a/cmake/FindPandoc.cmake Wed Aug 01 14:08:40 2018 +0200 +++ b/cmake/FindPandoc.cmake Thu Oct 04 21:17:55 2018 +0200 @@ -10,25 +10,25 @@ # This module also defines the following macros: # # pandoc( -# SOURCES file1 [file2 ...] -# OUTPUT output -# [FROM format] -# [TO format] -# [TARGET target] -# [DEPENDS dependency ...] -# [ALL] -# [TOC] -# [STANDALONE] -# [MAKE_DIRECTORY] -# [TEMPLATE file] -# [FILTER filter] -# [HEADER header ...] -# [FOOTER footer ...] -# [BODY body ...] -# [VARIABLE var ...] -# [METADATA meta ...] -# [ARGS argument ...] -# [WORKING_DIRECTORY directory] +# SOURCES file1 [file2 ...] +# OUTPUT output +# [FROM format] +# [TO format] +# [TARGET target] +# [DEPENDS dependency ...] +# [ALL] +# [TOC] +# [STANDALONE] +# [MAKE_DIRECTORY] +# [TEMPLATE file] +# [FILTER filter] +# [HEADER header ...] +# [FOOTER footer ...] +# [BODY body ...] +# [VARIABLE var ...] +# [METADATA meta ...] +# [ARGS argument ...] +# [WORKING_DIRECTORY directory] # ) # # The sources files are listed in the parameter SOURCES, all files are passed @@ -75,9 +75,9 @@ # find_program( - Pandoc_EXECUTABLE - NAMES pandoc - DOC "Pandoc executable" + Pandoc_EXECUTABLE + NAMES pandoc + DOC "Pandoc executable" ) include(FindPackageHandleStandardArgs) @@ -85,147 +85,147 @@ # Extract the version if (Pandoc_EXECUTABLE) - execute_process( - COMMAND ${Pandoc_EXECUTABLE} --version - OUTPUT_VARIABLE _pandoc_version_tmp - ) + execute_process( + COMMAND ${Pandoc_EXECUTABLE} --version + OUTPUT_VARIABLE _pandoc_version_tmp + ) - if (_pandoc_version_tmp MATCHES "^pandoc[^ ]* ([0-9]+\\.[0-9]+\\.[0-9]+)") - set(Pandoc_VERSION "${CMAKE_MATCH_1}") - endif () + if (_pandoc_version_tmp MATCHES "^pandoc[^ ]* ([0-9]+\\.[0-9]+\\.[0-9]+)") + set(Pandoc_VERSION "${CMAKE_MATCH_1}") + endif () endif () find_package_handle_standard_args( - Pandoc - FOUND_VAR Pandoc_FOUND - VERSION_VAR Pandoc_VERSION - REQUIRED_VARS Pandoc_EXECUTABLE + Pandoc + FOUND_VAR Pandoc_FOUND + VERSION_VAR Pandoc_VERSION + REQUIRED_VARS Pandoc_EXECUTABLE ) if (Pandoc_FOUND) - function(pandoc) - set(options MAKE_DIRECTORY STANDALONE TOC) - set(oneValueArgs FILTER FROM TARGET TEMPLATE TO OUTPUT WORKING_DIRECTORY) - set(multiValueArgs ARGS FOOTER HEADER METADATA SOURCES VARIABLE) + function(pandoc) + set(options MAKE_DIRECTORY STANDALONE TOC) + set(oneValueArgs FILTER FROM TARGET TEMPLATE TO OUTPUT WORKING_DIRECTORY) + set(multiValueArgs ARGS FOOTER HEADER METADATA SOURCES VARIABLE) - # - # The following variables will be set in that scope: - # _pandoc_arguments - List of all arguments that will passed to pandoc invocation. - # _pandoc_depends - List of all dependencies attached to the add_custom_command. - # _pandoc_mkdir - The mkdir command if MAKE_DIRECTORY is set - # _pandoc_output_base - The base output directory - # - cmake_parse_arguments(PANDOC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + # + # The following variables will be set in that scope: + # _pandoc_arguments - List of all arguments that will passed to pandoc invocation. + # _pandoc_depends - List of all dependencies attached to the add_custom_command. + # _pandoc_mkdir - The mkdir command if MAKE_DIRECTORY is set + # _pandoc_output_base - The base output directory + # + cmake_parse_arguments(PANDOC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - # - # Output and sources are mandatory - # - if (NOT PANDOC_OUTPUT) - message(FATAL_ERROR "Please define OUTPUT") - elseif (NOT PANDOC_SOURCES) - message(FATAL_ERROR "Please defines SOURCES") - endif () + # + # Output and sources are mandatory + # + if (NOT PANDOC_OUTPUT) + message(FATAL_ERROR "Please define OUTPUT") + elseif (NOT PANDOC_SOURCES) + message(FATAL_ERROR "Please defines SOURCES") + endif () - # - # Handle the filter with care. - # - # 1. If it is a target, depend on it and use a generator - # expression to get its full path on the disk. - # 2. If it is not a target, just use the user provided path. - # - if (PANDOC_FILTER) - # If it is a target, add a dependency so that it is built - if (TARGET ${PANDOC_FILTER}) - list(APPEND _pandoc_arguments --filter "$<TARGET_FILE:${PANDOC_FILTER}>") - list(APPEND _pandoc_depends ${PANDOC_FILTER}) - else () - list(APPEND _pandoc_arguments --filter ${PANDOC_FILTER}) - endif () - endif () + # + # Handle the filter with care. + # + # 1. If it is a target, depend on it and use a generator + # expression to get its full path on the disk. + # 2. If it is not a target, just use the user provided path. + # + if (PANDOC_FILTER) + # If it is a target, add a dependency so that it is built + if (TARGET ${PANDOC_FILTER}) + list(APPEND _pandoc_arguments --filter "$<TARGET_FILE:${PANDOC_FILTER}>") + list(APPEND _pandoc_depends ${PANDOC_FILTER}) + else () + list(APPEND _pandoc_arguments --filter ${PANDOC_FILTER}) + endif () + endif () - if (PANDOC_TOC) - list(APPEND _pandoc_arguments --toc) - endif () - if (PANDOC_STANDALONE) - list(APPEND _pandoc_arguments -s) - endif () - if (PANDOC_FROM) - list(APPEND _pandoc_arguments -f ${PANDOC_FROM}) - endif () - if (PANDOC_TO) - list(APPEND _pandoc_arguments -t ${PANDOC_TO}) - endif () - if (PANDOC_TEMPLATE) - list(APPEND _pandoc_arguments --template ${PANDOC_TEMPLATE}) - list(APPEND _pandoc_depends ${PANDOC_TEMPLATE}) - endif () + if (PANDOC_TOC) + list(APPEND _pandoc_arguments --toc) + endif () + if (PANDOC_STANDALONE) + list(APPEND _pandoc_arguments -s) + endif () + if (PANDOC_FROM) + list(APPEND _pandoc_arguments -f ${PANDOC_FROM}) + endif () + if (PANDOC_TO) + list(APPEND _pandoc_arguments -t ${PANDOC_TO}) + endif () + if (PANDOC_TEMPLATE) + list(APPEND _pandoc_arguments --template ${PANDOC_TEMPLATE}) + list(APPEND _pandoc_depends ${PANDOC_TEMPLATE}) + endif () - # Header, footers and body - foreach (h ${PANDOC_HEADER}) - list(APPEND _pandoc_arguments -H ${h}) - list(APPEND _pandoc_depends ${h}) - endforeach () - foreach (b ${PANDOC_BODY}) - list(APPEND _pandoc_arguments -B ${b}) - list(APPEND _pandoc_depends ${b}) - endforeach () - foreach (f ${PANDOC_FOOTER}) - list(APPEND _pandoc_arguments -A ${f}) - list(APPEND _pandoc_depends ${f}) - endforeach () + # Header, footers and body + foreach (h ${PANDOC_HEADER}) + list(APPEND _pandoc_arguments -H ${h}) + list(APPEND _pandoc_depends ${h}) + endforeach () + foreach (b ${PANDOC_BODY}) + list(APPEND _pandoc_arguments -B ${b}) + list(APPEND _pandoc_depends ${b}) + endforeach () + foreach (f ${PANDOC_FOOTER}) + list(APPEND _pandoc_arguments -A ${f}) + list(APPEND _pandoc_depends ${f}) + endforeach () - # Variables and metadata - foreach (var ${PANDOC_VARIABLE}) - list(APPEND _pandoc_arguments -V ${var}) - endforeach () - foreach (meta ${PANDOC_METADATA}) - list(APPEND _pandoc_arguments -M ${meta}) - endforeach () + # Variables and metadata + foreach (var ${PANDOC_VARIABLE}) + list(APPEND _pandoc_arguments -V ${var}) + endforeach () + foreach (meta ${PANDOC_METADATA}) + list(APPEND _pandoc_arguments -M ${meta}) + endforeach () - # Optional list of arguments - foreach (arg ${PANDOC_ARGS}) - list(APPEND _pandoc_arguments ${arg}) - endforeach () + # Optional list of arguments + foreach (arg ${PANDOC_ARGS}) + list(APPEND _pandoc_arguments ${arg}) + endforeach () - # Output and sources - list(APPEND _pandoc_arguments -o ${PANDOC_OUTPUT}) + # Output and sources + list(APPEND _pandoc_arguments -o ${PANDOC_OUTPUT}) - # - # The following variables are set within the loop: - # - # _pandoc_input The absolute path to the input file. - # _pandoc_output_base The base output directory. - # - foreach (s ${PANDOC_SOURCES}) - get_filename_component(_pandoc_input ${s} ABSOLUTE) - get_filename_component(_pandoc_output_base ${PANDOC_OUTPUT} DIRECTORY) - list(APPEND _pandoc_depends ${_pandoc_input}) - list(APPEND _pandoc_arguments ${_pandoc_input}) - endforeach () + # + # The following variables are set within the loop: + # + # _pandoc_input The absolute path to the input file. + # _pandoc_output_base The base output directory. + # + foreach (s ${PANDOC_SOURCES}) + get_filename_component(_pandoc_input ${s} ABSOLUTE) + get_filename_component(_pandoc_output_base ${PANDOC_OUTPUT} DIRECTORY) + list(APPEND _pandoc_depends ${_pandoc_input}) + list(APPEND _pandoc_arguments ${_pandoc_input}) + endforeach () - # Create the output directory if requested - if (PANDOC_MAKE_DIRECTORY) - set(_pandoc_mkdir ${CMAKE_COMMAND} -E make_directory ${_pandoc_output_base}) - endif () + # Create the output directory if requested + if (PANDOC_MAKE_DIRECTORY) + set(_pandoc_mkdir ${CMAKE_COMMAND} -E make_directory ${_pandoc_output_base}) + endif () - add_custom_command( - OUTPUT ${PANDOC_OUTPUT} - COMMAND ${_pandoc_mkdir} - COMMAND ${Pandoc_EXECUTABLE} ${_pandoc_arguments} - DEPENDS ${_pandoc_depends} ${PANDOC_DEPENDS} - WORKING_DIRECTORY ${PANDOC_WORKING_DIRECTORY} - VERBATIM - ) + add_custom_command( + OUTPUT ${PANDOC_OUTPUT} + COMMAND ${_pandoc_mkdir} + COMMAND ${Pandoc_EXECUTABLE} ${_pandoc_arguments} + DEPENDS ${_pandoc_depends} ${PANDOC_DEPENDS} + WORKING_DIRECTORY ${PANDOC_WORKING_DIRECTORY} + VERBATIM + ) - if (PANDOC_TARGET) - add_custom_target( - ${PANDOC_TARGET} ${PANDOC_ALL} - SOURCES ${_pandoc_depends} - DEPENDS ${PANDOC_OUTPUT} - WORKING_DIRECTORY ${PANDOC_WORKING_DIRECTORY} - ) - endif () - endfunction() + if (PANDOC_TARGET) + add_custom_target( + ${PANDOC_TARGET} ${PANDOC_ALL} + SOURCES ${_pandoc_depends} + DEPENDS ${PANDOC_OUTPUT} + WORKING_DIRECTORY ${PANDOC_WORKING_DIRECTORY} + ) + endif () + endfunction() endif () mark_as_advanced(Pandoc_EXECUTABLE)
--- a/cmake/FindQtIFW.cmake Wed Aug 01 14:08:40 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -# FindQtIFW -# --------- -# -# Find Qt Installer Framework, this module defines: -# -# QtIFW_CREATOR, where to find binarycreator.exe -# QtIFW_ARCHIVEGEN, where to find archivegen.exe -# QtIFW_FOUND, if the InnoSetup installation was found -# -# This module also defines the following macros: -# -# qtifw_create( -# OUTPUT installerfile -# CONFIG configuration file -# PACKAGES packages directory -# [TARGET name] -# [SOURCES sources ...] -# [DEPENDS dependencies ...] -# [RESOURCES resources ...] -# [ONLINE|OFFLINE] -# [ARGS args ...] -# ) -# -# This function adds a new custom command that generate the installer file specified by OUTPUT. -# -# The CONFIG and PACKAGES parameters are equivalent to -c and -p options respectively. -# -# You can add optional dependencies to the custom command with the DEPENDS parameter. -# -# If TARGET is specified, an additional target is created with the supplied name, the output file will be added as -# target dependency and optional sources files can be listed in the SOURCES parameter. -# -# You can specify .qrc files to be bundled with the RESOURCES parameter. -# -# The ONLINE and OFFLINE parameters are equivalent to -n and -f options respectively. They are mutually exclusive. -# -# If you need to pass additional arguments to binarycreator, you can use the ARGS parameter. -# -# qtifw_archive( -# OUTPUT archive.7z -# SOURCES sources ... -# [TARGET name] -# [DEPENDS dependencies ...] -# ) -# -# This function adds a new custom command that generate .7z files using QtIFW's archivegen tool. -# -# The output file must be specified by OUTPUT, sources can be either files or directories specified by SOURCES. -# -# If TARGET is specified, an additional target is created with the supplied name, the output file will be added as -# target dependency and source files will also be listed. -# -# You can add optional dependencies to the custom command with the DEPENDS parameter. -# - -find_program( - QtIFW_CREATOR - NAMES binarycreator - DOC "QtIFW binarycreator executable" -) - -find_program( - QtIFW_ARCHIVEGEN - NAMES archivegen - DOC "QtIFW archivegen executable" -) - -include(CMakeParseArguments) -include(FindPackageHandleStandardArgs) - -find_package_handle_standard_args( - QtIFW - FOUND_VAR QtIFW_FOUND - REQUIRED_VARS QtIFW_CREATOR QtIFW_ARCHIVEGEN -) - -if (QtIFW_FOUND) - function (qtifw_create) - - endfunction () -endif () - -mark_as_advanced(QtIFW_CREATOR) \ No newline at end of file
--- a/cmake/FindQuazip.cmake Wed Aug 01 14:08:40 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -# FindQuazip -# ---------- -# -# Find Quazip library, this modules defines: -# -# Quazip_INCLUDE_DIRS, where to find quazip/quazip.h -# Quazip_LIBRARIES, where to find library -# Quazip_FOUND, if it is found - -find_package(ZLIB QUIET) - -find_path(Quazip_INCLUDE_DIR NAMES quazip/quazip.h) -find_library(Quazip_LIBRARY NAMES libquazip quazip) - -include(FindPackageHandleStandardArgs) - -find_package_handle_standard_args( - Quazip - FOUND_VAR Quazip_FOUND - REQUIRED_VARS Quazip_LIBRARY Quazip_INCLUDE_DIR ZLIB_LIBRARIES ZLIB_INCLUDE_DIRS -) - -if (ZLIB_FOUND AND Quazip_LIBRARY AND Quazip_INCLUDE_DIR) - set(Quazip_LIBRARIES ${Quazip_LIBRARY} ${ZLIB_LIBRARIES}) - set(Quazip_INCLUDE_DIRS ${Quazip_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS}) -endif () - -mark_as_advanced(Quazip_INCLUDE_DIR Quazip_LIBRARY)
--- a/cmake/FindSDL2.cmake Wed Aug 01 14:08:40 2018 +0200 +++ b/cmake/FindSDL2.cmake Thu Oct 04 21:17:55 2018 +0200 @@ -8,9 +8,9 @@ # SDL2_INCLUDE_DIR, where to find SDL.h find_path( - SDL2_INCLUDE_DIR - NAMES SDL.h - PATH_SUFFIXES include/SDL2 include + SDL2_INCLUDE_DIR + NAMES SDL.h + PATH_SUFFIXES include/SDL2 include ) find_library(SDL2_LIBRARY NAMES SDL2 SDL2-2.0 libSDL2 libSDL2-2.0) @@ -18,8 +18,8 @@ include(FindPackageHandleStandardArgs) find_package_handle_standard_args( - SDL2 - REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR + SDL2 + REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR ) set(SDL2_LIBRARIES ${SDL2_LIBRARY})
--- a/cmake/FindSysQueue.cmake Wed Aug 01 14:08:40 2018 +0200 +++ b/cmake/FindSysQueue.cmake Thu Oct 04 21:17:55 2018 +0200 @@ -30,23 +30,23 @@ check_include_file(sys/queue.h SYSQUEUE_FOUND) if (SYSQUEUE_FOUND) - foreach (type "SLIST" "STAILQ" "LIST" "TAILQ" "SIMPLEQ" "CIRCLEQ") - check_symbol_exists(${type}_HEAD sys/queue.h SYSQUEUE_${type}) + foreach (type "SLIST" "STAILQ" "LIST" "TAILQ" "SIMPLEQ" "CIRCLEQ") + check_symbol_exists(${type}_HEAD sys/queue.h SYSQUEUE_${type}) - if (SYSQUEUE_${type}) - # Check for _FOREACH. - check_symbol_exists( - ${type}_FOREACH - sys/queue.h - SYSQUEUE_${type}_FOREACH - ) + if (SYSQUEUE_${type}) + # Check for _FOREACH. + check_symbol_exists( + ${type}_FOREACH + sys/queue.h + SYSQUEUE_${type}_FOREACH + ) - # Check for _FOREACH_SAFE. - check_symbol_exists( - ${type}_FOREACH_SAFE - sys/queue.h - SYSQUEUE_${type}_FOREACH_SAFE - ) - endif () - endforeach () + # Check for _FOREACH_SAFE. + check_symbol_exists( + ${type}_FOREACH_SAFE + sys/queue.h + SYSQUEUE_${type}_FOREACH_SAFE + ) + endif () + endforeach () endif ()
--- a/cmake/FindZIP.cmake Wed Aug 01 14:08:40 2018 +0200 +++ b/cmake/FindZIP.cmake Thu Oct 04 21:17:55 2018 +0200 @@ -10,42 +10,42 @@ find_package(ZLIB QUIET) find_path( - ZIP_INCLUDE_DIR - NAMES zip.h + ZIP_INCLUDE_DIR + NAMES zip.h ) find_library( - ZIP_LIBRARY - NAMES zip libzip + ZIP_LIBRARY + NAMES zip libzip ) find_path( - ZIPCONF_INCLUDE_DIR - NAMES zipconf.h + ZIPCONF_INCLUDE_DIR + NAMES zipconf.h ) if (NOT ZIPCONF_INCLUDE_DIR) - # zipconf.h is sometimes directly in the include/ folder but on some systems - # like Windows, it is installed in the lib/ directory. - get_filename_component(_ZIP_PRIVATE_LIBRARY "${ZIP_LIBRARY}" DIRECTORY) + # zipconf.h is sometimes directly in the include/ folder but on some systems + # like Windows, it is installed in the lib/ directory. + get_filename_component(_ZIP_PRIVATE_LIBRARY "${ZIP_LIBRARY}" DIRECTORY) - find_path( - ZIPCONF_INCLUDE_DIR - NAMES zipconf.h - PATHS "${_ZIP_PRIVATE_LIBRARY}/libzip/include" - ) + find_path( + ZIPCONF_INCLUDE_DIR + NAMES zipconf.h + PATHS "${_ZIP_PRIVATE_LIBRARY}/libzip/include" + ) endif () include(FindPackageHandleStandardArgs) find_package_handle_standard_args( - ZIP - REQUIRED_VARS ZLIB_LIBRARIES ZLIB_INCLUDE_DIRS ZIP_LIBRARY ZIP_INCLUDE_DIR ZIPCONF_INCLUDE_DIR + ZIP + REQUIRED_VARS ZLIB_LIBRARIES ZLIB_INCLUDE_DIRS ZIP_LIBRARY ZIP_INCLUDE_DIR ZIPCONF_INCLUDE_DIR ) if (ZIP_FOUND) - set(ZIP_LIBRARIES ${ZIP_LIBRARY} ${ZLIB_LIBRARIES}) - set(ZIP_INCLUDE_DIRS ${ZIP_INCLUDE_DIR} ${ZIPCONF_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS}) + set(ZIP_LIBRARIES ${ZIP_LIBRARY} ${ZLIB_LIBRARIES}) + set(ZIP_INCLUDE_DIRS ${ZIP_INCLUDE_DIR} ${ZIPCONF_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS}) endif () mark_as_advanced(ZIP_LIBRARY ZIP_INCLUDE_DIR ZIPCONF_INCLUDE_DIR)
--- a/cpp/is_boolean/CMakeLists.txt Wed Aug 01 14:08:40 2018 +0200 +++ b/cpp/is_boolean/CMakeLists.txt Thu Oct 04 21:17:55 2018 +0200 @@ -17,6 +17,6 @@ # code_define_module( - NAME is-boolean - SOURCES is_boolean.hpp + NAME is-boolean + SOURCES is_boolean.hpp )
--- a/cpp/is_boolean/is_boolean.hpp Wed Aug 01 14:08:40 2018 +0200 +++ b/cpp/is_boolean/is_boolean.hpp Thu Oct 04 21:17:55 2018 +0200 @@ -32,11 +32,11 @@ */ inline auto is_boolean(std::string value) noexcept -> bool { - std::transform(value.begin(), value.end(), value.begin(), [] (auto c) noexcept { - return toupper(c); - }); + std::transform(value.begin(), value.end(), value.begin(), [] (auto c) noexcept { + return toupper(c); + }); - return value == "1" || value == "YES" || value == "TRUE" || value == "ON"; + return value == "1" || value == "YES" || value == "TRUE" || value == "ON"; } #endif // !IS_BOOLEAN_HPP
--- a/cpp/is_boolean/test/main.cpp Wed Aug 01 14:08:40 2018 +0200 +++ b/cpp/is_boolean/test/main.cpp Thu Oct 04 21:17:55 2018 +0200 @@ -23,21 +23,21 @@ BOOST_AUTO_TEST_CASE(simple_is_boolean) { - BOOST_REQUIRE(is_boolean("true")); - BOOST_REQUIRE(is_boolean("True")); - BOOST_REQUIRE(is_boolean("TRUE")); - BOOST_REQUIRE(is_boolean("TruE")); - BOOST_REQUIRE(is_boolean("yes")); - BOOST_REQUIRE(is_boolean("Yes")); - BOOST_REQUIRE(is_boolean("YES")); - BOOST_REQUIRE(is_boolean("YeS")); - BOOST_REQUIRE(is_boolean("on")); - BOOST_REQUIRE(is_boolean("On")); - BOOST_REQUIRE(is_boolean("oN")); - BOOST_REQUIRE(is_boolean("ON")); - BOOST_REQUIRE(is_boolean("1")); - BOOST_REQUIRE(!is_boolean("false")); - BOOST_REQUIRE(!is_boolean("lol")); - BOOST_REQUIRE(!is_boolean("")); - BOOST_REQUIRE(!is_boolean("0")); + BOOST_REQUIRE(is_boolean("true")); + BOOST_REQUIRE(is_boolean("True")); + BOOST_REQUIRE(is_boolean("TRUE")); + BOOST_REQUIRE(is_boolean("TruE")); + BOOST_REQUIRE(is_boolean("yes")); + BOOST_REQUIRE(is_boolean("Yes")); + BOOST_REQUIRE(is_boolean("YES")); + BOOST_REQUIRE(is_boolean("YeS")); + BOOST_REQUIRE(is_boolean("on")); + BOOST_REQUIRE(is_boolean("On")); + BOOST_REQUIRE(is_boolean("oN")); + BOOST_REQUIRE(is_boolean("ON")); + BOOST_REQUIRE(is_boolean("1")); + BOOST_REQUIRE(!is_boolean("false")); + BOOST_REQUIRE(!is_boolean("lol")); + BOOST_REQUIRE(!is_boolean("")); + BOOST_REQUIRE(!is_boolean("0")); }
--- a/cpp/is_number/CMakeLists.txt Wed Aug 01 14:08:40 2018 +0200 +++ b/cpp/is_number/CMakeLists.txt Thu Oct 04 21:17:55 2018 +0200 @@ -17,6 +17,6 @@ # code_define_module( - NAME is-number - SOURCES is_number.hpp + NAME is-number + SOURCES is_number.hpp )
--- a/cpp/is_number/is_number.hpp Wed Aug 01 14:08:40 2018 +0200 +++ b/cpp/is_number/is_number.hpp Thu Oct 04 21:17:55 2018 +0200 @@ -31,14 +31,14 @@ */ inline auto is_int(const std::string& str, int base = 10) noexcept -> bool { - if (str.empty()) - return false; + if (str.empty()) + return false; - char* ptr; + char* ptr; - std::strtol(str.c_str(), &ptr, base); + std::strtol(str.c_str(), &ptr, base); - return *ptr == 0; + return *ptr == 0; } /** @@ -49,14 +49,14 @@ */ inline auto is_real(const std::string &str) noexcept -> bool { - if (str.empty()) - return false; + if (str.empty()) + return false; - char* ptr; + char* ptr; - std::strtod(str.c_str(), &ptr); + std::strtod(str.c_str(), &ptr); - return *ptr == 0; + return *ptr == 0; } /** @@ -67,7 +67,7 @@ */ inline auto is_number(const std::string& str) noexcept -> bool { - return is_int(str) || is_real(str); + return is_int(str) || is_real(str); } #endif // !IS_NUMBER_HPP
--- a/cpp/is_number/test/main.cpp Wed Aug 01 14:08:40 2018 +0200 +++ b/cpp/is_number/test/main.cpp Thu Oct 04 21:17:55 2018 +0200 @@ -23,31 +23,31 @@ BOOST_AUTO_TEST_CASE(simple_is_int) { - BOOST_TEST(is_int("123")); - BOOST_TEST(is_int("-126")); - BOOST_TEST(!is_int("")); - BOOST_TEST(!is_int("bdf")); - BOOST_TEST(!is_int("false")); + BOOST_TEST(is_int("123")); + BOOST_TEST(is_int("-126")); + BOOST_TEST(!is_int("")); + BOOST_TEST(!is_int("bdf")); + BOOST_TEST(!is_int("false")); } BOOST_AUTO_TEST_CASE(simple_is_real) { - BOOST_TEST(is_real("123")); - BOOST_TEST(is_real("-126")); - BOOST_TEST(is_real("56.28")); - BOOST_TEST(is_real("1e5")); - BOOST_TEST(!is_real("")); - BOOST_TEST(!is_real("bdf")); - BOOST_TEST(!is_real("false")); + BOOST_TEST(is_real("123")); + BOOST_TEST(is_real("-126")); + BOOST_TEST(is_real("56.28")); + BOOST_TEST(is_real("1e5")); + BOOST_TEST(!is_real("")); + BOOST_TEST(!is_real("bdf")); + BOOST_TEST(!is_real("false")); } BOOST_AUTO_TEST_CASE(simple_is_number) { - BOOST_TEST(is_number("123")); - BOOST_TEST(is_number("-126")); - BOOST_TEST(is_number("56.28")); - BOOST_TEST(is_number("1e5")); - BOOST_TEST(!is_number("")); - BOOST_TEST(!is_number("bdf")); - BOOST_TEST(!is_number("false")); + BOOST_TEST(is_number("123")); + BOOST_TEST(is_number("-126")); + BOOST_TEST(is_number("56.28")); + BOOST_TEST(is_number("1e5")); + BOOST_TEST(!is_number("")); + BOOST_TEST(!is_number("bdf")); + BOOST_TEST(!is_number("false")); }
--- a/cpp/join/CMakeLists.txt Wed Aug 01 14:08:40 2018 +0200 +++ b/cpp/join/CMakeLists.txt Thu Oct 04 21:17:55 2018 +0200 @@ -17,6 +17,6 @@ # code_define_module( - NAME join - SOURCES join.hpp + NAME join + SOURCES join.hpp )
--- a/cpp/join/join.hpp Wed Aug 01 14:08:40 2018 +0200 +++ b/cpp/join/join.hpp Thu Oct 04 21:17:55 2018 +0200 @@ -36,16 +36,16 @@ template <typename InputIt, typename DelimType = char> auto join(InputIt first, InputIt last, DelimType delim = ':') -> std::string { - std::ostringstream oss; + std::ostringstream oss; - if (first != last) { - oss << *first; + if (first != last) { + oss << *first; - while (++first != last) - oss << delim << *first; - } + while (++first != last) + oss << delim << *first; + } - return oss.str(); + return oss.str(); } /** @@ -58,5 +58,5 @@ template <typename T, typename DelimType = char> auto join(std::initializer_list<T> list, DelimType delim = ':') -> std::string { - return join(list.begin(), list.end(), delim); + return join(list.begin(), list.end(), delim); }
--- a/cpp/join/test/main.cpp Wed Aug 01 14:08:40 2018 +0200 +++ b/cpp/join/test/main.cpp Thu Oct 04 21:17:55 2018 +0200 @@ -23,40 +23,40 @@ BOOST_AUTO_TEST_CASE(empty) { - std::string expected = ""; - std::string result = join<int>({}); + std::string expected = ""; + std::string result = join<int>({}); - BOOST_REQUIRE_EQUAL(expected, result); + BOOST_REQUIRE_EQUAL(expected, result); } BOOST_AUTO_TEST_CASE(one) { - std::string expected = "1"; - std::string result = join({1}); + std::string expected = "1"; + std::string result = join({1}); - BOOST_REQUIRE_EQUAL(expected, result); + BOOST_REQUIRE_EQUAL(expected, result); } BOOST_AUTO_TEST_CASE(two) { - std::string expected = "1:2"; - std::string result = join({1, 2}); + std::string expected = "1:2"; + std::string result = join({1, 2}); - BOOST_REQUIRE_EQUAL(expected, result); + BOOST_REQUIRE_EQUAL(expected, result); } BOOST_AUTO_TEST_CASE(delimiterString) { - std::string expected = "1;;2;;3"; - std::string result = join({1, 2, 3}, ";;"); + std::string expected = "1;;2;;3"; + std::string result = join({1, 2, 3}, ";;"); - BOOST_REQUIRE_EQUAL(expected, result); + BOOST_REQUIRE_EQUAL(expected, result); } BOOST_AUTO_TEST_CASE(delimiterChar) { - std::string expected = "1@2@3@4"; - std::string result = join({1, 2, 3, 4}, '@'); + std::string expected = "1@2@3@4"; + std::string result = join({1, 2, 3, 4}, '@'); - BOOST_REQUIRE_EQUAL(expected, result); + BOOST_REQUIRE_EQUAL(expected, result); }
--- a/cpp/json_util/CMakeLists.txt Wed Aug 01 14:08:40 2018 +0200 +++ b/cpp/json_util/CMakeLists.txt Thu Oct 04 21:17:55 2018 +0200 @@ -19,9 +19,8 @@ project(json-util) code_define_module( - NAME json-util - LIBRARIES json - SOURCES - ${json-util_SOURCE_DIR}/json_util.hpp + NAME json-util + LIBRARIES json + SOURCES + ${json-util_SOURCE_DIR}/json_util.hpp ) -
--- a/cpp/json_util/json_util.hpp Wed Aug 01 14:08:40 2018 +0200 +++ b/cpp/json_util/json_util.hpp Thu Oct 04 21:17:55 2018 +0200 @@ -47,35 +47,35 @@ template <typename Int> class parser_type_traits_uint : public std::true_type { public: - static boost::optional<Int> get(const nlohmann::json& value) noexcept - { - if (!value.is_number_unsigned()) - return boost::none; + static boost::optional<Int> get(const nlohmann::json& value) noexcept + { + if (!value.is_number_unsigned()) + return boost::none; - const auto ret = value.get<std::uint64_t>(); + const auto ret = value.get<std::uint64_t>(); - if (ret > std::numeric_limits<Int>::max()) - return boost::none; + if (ret > std::numeric_limits<Int>::max()) + return boost::none; - return static_cast<Int>(ret); - } + return static_cast<Int>(ret); + } }; template <typename Int> class parser_type_traits_int : public std::true_type { public: - static boost::optional<Int> get(const nlohmann::json& value) noexcept - { - if (!value.is_number_integer()) - return boost::none; + static boost::optional<Int> get(const nlohmann::json& value) noexcept + { + if (!value.is_number_integer()) + return boost::none; - const auto ret = value.get<std::int64_t>(); + const auto ret = value.get<std::int64_t>(); - if (ret < std::numeric_limits<Int>::min() || ret > std::numeric_limits<Int>::max()) - return boost::none; + if (ret < std::numeric_limits<Int>::min() || ret > std::numeric_limits<Int>::max()) + return boost::none; - return static_cast<Int>(ret); - } + return static_cast<Int>(ret); + } }; } // !detail @@ -116,19 +116,19 @@ template <> class parser_type_traits<bool> : public std::true_type { public: - /** - * Convert the JSON value to bool. - * - * \param value the value - * \return the bool or none if not a boolean type - */ - static boost::optional<bool> get(const nlohmann::json& value) noexcept - { - if (!value.is_boolean()) - return boost::none; + /** + * Convert the JSON value to bool. + * + * \param value the value + * \return the bool or none if not a boolean type + */ + static boost::optional<bool> get(const nlohmann::json& value) noexcept + { + if (!value.is_boolean()) + return boost::none; - return value.get<bool>(); - } + return value.get<bool>(); + } }; /** @@ -137,19 +137,19 @@ template <> class parser_type_traits<double> : public std::true_type { public: - /** - * Convert the JSON value to bool. - * - * \param value the value - * \return the double or none if not a double type - */ - static boost::optional<double> get(const nlohmann::json& value) noexcept - { - if (!value.is_number_float()) - return boost::none; + /** + * Convert the JSON value to bool. + * + * \param value the value + * \return the double or none if not a double type + */ + static boost::optional<double> get(const nlohmann::json& value) noexcept + { + if (!value.is_number_float()) + return boost::none; - return value.get<double>(); - } + return value.get<double>(); + } }; /** @@ -158,19 +158,19 @@ template <> class parser_type_traits<std::string> : public std::true_type { public: - /** - * Convert the JSON value to bool. - * - * \param value the value - * \return the string or none if not a string type - */ - static boost::optional<std::string> get(const nlohmann::json& value) - { - if (!value.is_string()) - return boost::none; + /** + * Convert the JSON value to bool. + * + * \param value the value + * \return the string or none if not a string type + */ + static boost::optional<std::string> get(const nlohmann::json& value) + { + if (!value.is_string()) + return boost::none; - return value.get<std::string>(); - } + return value.get<std::string>(); + } }; /** @@ -200,19 +200,19 @@ template <> class parser_type_traits<std::int64_t> : public std::true_type { public: - /** - * Convert the JSON value to std::int64_t. - * - * \param value the value - * \return the int or none if not a int type - */ - static boost::optional<std::int64_t> get(const nlohmann::json& value) noexcept - { - if (!value.is_number_integer()) - return boost::none; + /** + * Convert the JSON value to std::int64_t. + * + * \param value the value + * \return the int or none if not a int type + */ + static boost::optional<std::int64_t> get(const nlohmann::json& value) noexcept + { + if (!value.is_number_integer()) + return boost::none; - return value.get<std::int64_t>(); - } + return value.get<std::int64_t>(); + } }; /** @@ -242,19 +242,19 @@ template <> class parser_type_traits<std::uint64_t> : public std::true_type { public: - /** - * Convert the JSON value to std::uint64_t. - * - * \param value the value - * \return the int or none if not a int type - */ - static boost::optional<std::uint64_t> get(const nlohmann::json& value) noexcept - { - if (!value.is_number_unsigned()) - return boost::none; + /** + * Convert the JSON value to std::uint64_t. + * + * \param value the value + * \return the int or none if not a int type + */ + static boost::optional<std::uint64_t> get(const nlohmann::json& value) noexcept + { + if (!value.is_number_unsigned()) + return boost::none; - return value.get<std::uint64_t>(); - } + return value.get<std::uint64_t>(); + } }; /** @@ -265,52 +265,52 @@ */ class document : public nlohmann::json { public: - /** - * Inherited constructor. - */ - using nlohmann::json::json; + /** + * Inherited constructor. + */ + using nlohmann::json::json; - /** - * Get a value from the document object. - * - * \param key the property key - * \return the value or boost::none if not found or not convertible - */ - template <typename Type> - inline boost::optional<Type> get(const std::string& key) const noexcept - { - static_assert(parser_type_traits<Type>::value, "type not supported"); + /** + * Get a value from the document object. + * + * \param key the property key + * \return the value or boost::none if not found or not convertible + */ + template <typename Type> + inline boost::optional<Type> get(const std::string& key) const noexcept + { + static_assert(parser_type_traits<Type>::value, "type not supported"); - const auto it = find(key); + const auto it = find(key); - if (it == end()) - return boost::none; + if (it == end()) + return boost::none; - return parser_type_traits<Type>::get(*it); - } + return parser_type_traits<Type>::get(*it); + } - /** - * Get an optional value from the document object. - * - * If the value is undefined, the default value is returned. Otherwise, if - * the value is not in the given type, boost::none is returned. - * - * \param key the property key - * \param def the default value if property is undefined - * \return the value, boost::none or def - */ - template <typename Type, typename DefaultValue> - inline boost::optional<Type> optional(const std::string& key, DefaultValue&& def) const noexcept - { - static_assert(parser_type_traits<Type>::value, "type not supported"); + /** + * Get an optional value from the document object. + * + * If the value is undefined, the default value is returned. Otherwise, if + * the value is not in the given type, boost::none is returned. + * + * \param key the property key + * \param def the default value if property is undefined + * \return the value, boost::none or def + */ + template <typename Type, typename DefaultValue> + inline boost::optional<Type> optional(const std::string& key, DefaultValue&& def) const noexcept + { + static_assert(parser_type_traits<Type>::value, "type not supported"); - const auto it = find(key); + const auto it = find(key); - if (it == end()) - return boost::optional<Type>(std::forward<DefaultValue>(def)); + if (it == end()) + return boost::optional<Type>(std::forward<DefaultValue>(def)); - return parser_type_traits<Type>::get(*it); - } + return parser_type_traits<Type>::get(*it); + } }; /** @@ -323,22 +323,22 @@ */ inline std::string pretty(const nlohmann::json& value, int indent = 4) { - switch (value.type()) { - case nlohmann::json::value_t::null: - return "null"; - case nlohmann::json::value_t::string: - return value.get<std::string>(); - case nlohmann::json::value_t::boolean: - return value.get<bool>() ? "true" : "false"; - case nlohmann::json::value_t::number_integer: - return std::to_string(value.get<std::int64_t>()); - case nlohmann::json::value_t::number_unsigned: - return std::to_string(value.get<std::uint64_t>()); - case nlohmann::json::value_t::number_float: - return std::to_string(value.get<double>()); - default: - return value.dump(indent); - } + switch (value.type()) { + case nlohmann::json::value_t::null: + return "null"; + case nlohmann::json::value_t::string: + return value.get<std::string>(); + case nlohmann::json::value_t::boolean: + return value.get<bool>() ? "true" : "false"; + case nlohmann::json::value_t::number_integer: + return std::to_string(value.get<std::int64_t>()); + case nlohmann::json::value_t::number_unsigned: + return std::to_string(value.get<std::uint64_t>()); + case nlohmann::json::value_t::number_float: + return std::to_string(value.get<double>()); + default: + return value.dump(indent); + } } } // !json_util
--- a/cpp/json_util/test/main.cpp Wed Aug 01 14:08:40 2018 +0200 +++ b/cpp/json_util/test/main.cpp Thu Oct 04 21:17:55 2018 +0200 @@ -26,12 +26,12 @@ class test_fixture { protected: - document document_{ - { "boolean", true }, - { "int", -1234 }, - { "uint", 1234U }, - { "string", "str" } - }; + document document_{ + { "boolean", true }, + { "int", -1234 }, + { "uint", 1234U }, + { "string", "str" } + }; }; BOOST_FIXTURE_TEST_SUITE(test_fixture_suite, test_fixture) @@ -40,46 +40,46 @@ BOOST_AUTO_TEST_CASE(boolean) { - const auto v = document_.get<bool>("boolean"); + const auto v = document_.get<bool>("boolean"); - BOOST_TEST(v); - BOOST_TEST(*v); - BOOST_TEST(!document_.get<bool>("int")); - BOOST_TEST(!document_.get<bool>("int")); - BOOST_TEST(!document_.get<bool>("uint")); - BOOST_TEST(!document_.get<bool>("string")); + BOOST_TEST(v); + BOOST_TEST(*v); + BOOST_TEST(!document_.get<bool>("int")); + BOOST_TEST(!document_.get<bool>("int")); + BOOST_TEST(!document_.get<bool>("uint")); + BOOST_TEST(!document_.get<bool>("string")); } BOOST_AUTO_TEST_CASE(integer) { - const auto v = document_.get<int>("int"); + const auto v = document_.get<int>("int"); - BOOST_TEST(v); - BOOST_TEST(*v == -1234); - BOOST_TEST(!document_.get<int>("bool")); - BOOST_TEST(!document_.get<int>("string")); + BOOST_TEST(v); + BOOST_TEST(*v == -1234); + BOOST_TEST(!document_.get<int>("bool")); + BOOST_TEST(!document_.get<int>("string")); } BOOST_AUTO_TEST_CASE(unsigned_integer) { - const auto v = document_.get<unsigned>("uint"); + const auto v = document_.get<unsigned>("uint"); - BOOST_TEST(v); - BOOST_TEST(*v == 1234U); - BOOST_TEST(!document_.get<unsigned>("bool")); - BOOST_TEST(!document_.get<unsigned>("int")); - BOOST_TEST(!document_.get<unsigned>("string")); + BOOST_TEST(v); + BOOST_TEST(*v == 1234U); + BOOST_TEST(!document_.get<unsigned>("bool")); + BOOST_TEST(!document_.get<unsigned>("int")); + BOOST_TEST(!document_.get<unsigned>("string")); } BOOST_AUTO_TEST_CASE(string) { - const auto v = document_.get<std::string>("string"); + const auto v = document_.get<std::string>("string"); - BOOST_TEST(v); - BOOST_TEST(*v == "str"); - BOOST_TEST(!document_.get<std::string>("bool")); - BOOST_TEST(!document_.get<std::string>("int")); - BOOST_TEST(!document_.get<std::string>("uint")); + BOOST_TEST(v); + BOOST_TEST(*v == "str"); + BOOST_TEST(!document_.get<std::string>("bool")); + BOOST_TEST(!document_.get<std::string>("int")); + BOOST_TEST(!document_.get<std::string>("uint")); } BOOST_AUTO_TEST_SUITE_END() @@ -88,23 +88,23 @@ BOOST_AUTO_TEST_CASE(boolean) { - BOOST_TEST(*document_.optional<bool>("undefined", true)); - BOOST_TEST(!*document_.optional<bool>("undefined", false)); + BOOST_TEST(*document_.optional<bool>("undefined", true)); + BOOST_TEST(!*document_.optional<bool>("undefined", false)); } BOOST_AUTO_TEST_CASE(integer) { - BOOST_TEST(*document_.optional<int>("undefined", 1234) == 1234); + BOOST_TEST(*document_.optional<int>("undefined", 1234) == 1234); } BOOST_AUTO_TEST_CASE(unsigned_integer) { - BOOST_TEST(*document_.optional<unsigned>("undefined", 1234U) == 1234U); + BOOST_TEST(*document_.optional<unsigned>("undefined", 1234U) == 1234U); } BOOST_AUTO_TEST_CASE(string) { - BOOST_TEST(*document_.optional<std::string>("undefined", "foo") == "foo"); + BOOST_TEST(*document_.optional<std::string>("undefined", "foo") == "foo"); } BOOST_AUTO_TEST_SUITE_END() @@ -113,29 +113,29 @@ BOOST_AUTO_TEST_CASE(boolean) { - BOOST_TEST(!document_.optional<bool>("int", true)); - BOOST_TEST(!document_.optional<bool>("uint", true)); - BOOST_TEST(!document_.optional<bool>("string", true)); + BOOST_TEST(!document_.optional<bool>("int", true)); + BOOST_TEST(!document_.optional<bool>("uint", true)); + BOOST_TEST(!document_.optional<bool>("string", true)); } BOOST_AUTO_TEST_CASE(integer) { - BOOST_TEST(!document_.optional<int>("boolean", 1234)); - BOOST_TEST(!document_.optional<int>("string", 1234)); + BOOST_TEST(!document_.optional<int>("boolean", 1234)); + BOOST_TEST(!document_.optional<int>("string", 1234)); } BOOST_AUTO_TEST_CASE(unsigned_integer) { - BOOST_TEST(!document_.optional<unsigned>("boolean", 1234)); - BOOST_TEST(!document_.optional<unsigned>("int", 1234)); - BOOST_TEST(!document_.optional<unsigned>("string", 1234)); + BOOST_TEST(!document_.optional<unsigned>("boolean", 1234)); + BOOST_TEST(!document_.optional<unsigned>("int", 1234)); + BOOST_TEST(!document_.optional<unsigned>("string", 1234)); } BOOST_AUTO_TEST_CASE(string) { - BOOST_TEST(!document_.optional<std::string>("boolean", "foo")); - BOOST_TEST(!document_.optional<std::string>("int", "foo")); - BOOST_TEST(!document_.optional<std::string>("uint", "foo")); + BOOST_TEST(!document_.optional<std::string>("boolean", "foo")); + BOOST_TEST(!document_.optional<std::string>("int", "foo")); + BOOST_TEST(!document_.optional<std::string>("uint", "foo")); } BOOST_AUTO_TEST_SUITE_END()
--- a/cpp/to_int/CMakeLists.txt Wed Aug 01 14:08:40 2018 +0200 +++ b/cpp/to_int/CMakeLists.txt Thu Oct 04 21:17:55 2018 +0200 @@ -17,6 +17,6 @@ # code_define_module( - NAME to-int - SOURCES to_int.hpp + NAME to-int + SOURCES to_int.hpp )
--- a/cpp/to_int/test/main.cpp Wed Aug 01 14:08:40 2018 +0200 +++ b/cpp/to_int/test/main.cpp Thu Oct 04 21:17:55 2018 +0200 @@ -25,32 +25,32 @@ BOOST_AUTO_TEST_CASE(signed_to_int) { - BOOST_TEST(*to_int("10") == 10); - BOOST_TEST(*to_int<std::int8_t>("-10") == -10); - BOOST_TEST(*to_int<std::int8_t>("10") == 10); - BOOST_TEST(*to_int<std::int16_t>("-1000") == -1000); - BOOST_TEST(*to_int<std::int16_t>("1000") == 1000); - BOOST_TEST(*to_int<std::int32_t>("-1000") == -1000); - BOOST_TEST(*to_int<std::int32_t>("1000") == 1000); + BOOST_TEST(*to_int("10") == 10); + BOOST_TEST(*to_int<std::int8_t>("-10") == -10); + BOOST_TEST(*to_int<std::int8_t>("10") == 10); + BOOST_TEST(*to_int<std::int16_t>("-1000") == -1000); + BOOST_TEST(*to_int<std::int16_t>("1000") == 1000); + BOOST_TEST(*to_int<std::int32_t>("-1000") == -1000); + BOOST_TEST(*to_int<std::int32_t>("1000") == 1000); } BOOST_AUTO_TEST_CASE(signed_to_int64) { - BOOST_TEST(*to_int<std::int64_t>("-9223372036854775807") == -9223372036854775807LL); - BOOST_TEST(*to_int<std::int64_t>("9223372036854775807") == 9223372036854775807LL); + BOOST_TEST(*to_int<std::int64_t>("-9223372036854775807") == -9223372036854775807LL); + BOOST_TEST(*to_int<std::int64_t>("9223372036854775807") == 9223372036854775807LL); } BOOST_AUTO_TEST_CASE(unsigned_to_uint) { - BOOST_TEST(*to_uint("10") == 10U); - BOOST_TEST(*to_uint<std::uint8_t>("10") == 10U); - BOOST_TEST(*to_uint<std::uint16_t>("1000") == 1000U); - BOOST_TEST(*to_uint<std::uint32_t>("1000") == 1000U); + BOOST_TEST(*to_uint("10") == 10U); + BOOST_TEST(*to_uint<std::uint8_t>("10") == 10U); + BOOST_TEST(*to_uint<std::uint16_t>("1000") == 1000U); + BOOST_TEST(*to_uint<std::uint32_t>("1000") == 1000U); } BOOST_AUTO_TEST_CASE(unsigned_to_uint64) { - BOOST_TEST(*to_uint<std::uint64_t>("18446744073709551615") == 18446744073709551615ULL); + BOOST_TEST(*to_uint<std::uint64_t>("18446744073709551615") == 18446744073709551615ULL); } BOOST_AUTO_TEST_SUITE_END() @@ -59,16 +59,16 @@ BOOST_AUTO_TEST_CASE(invalid_argument) { - BOOST_TEST(!to_int("plopation")); - BOOST_TEST(!to_uint("plopation")); + BOOST_TEST(!to_int("plopation")); + BOOST_TEST(!to_uint("plopation")); } BOOST_AUTO_TEST_CASE(out_of_range) { - BOOST_TEST(!to_int<std::int8_t>("1000")); - BOOST_TEST(!to_int<std::int8_t>("-1000")); - BOOST_TEST(!to_uint<std::uint8_t>("1000")); - BOOST_TEST(!to_uint<std::uint8_t>("-1000")); + BOOST_TEST(!to_int<std::int8_t>("1000")); + BOOST_TEST(!to_int<std::int8_t>("-1000")); + BOOST_TEST(!to_uint<std::uint8_t>("1000")); + BOOST_TEST(!to_uint<std::uint8_t>("-1000")); } BOOST_AUTO_TEST_SUITE_END()
--- a/cpp/to_int/to_int.hpp Wed Aug 01 14:08:40 2018 +0200 +++ b/cpp/to_int/to_int.hpp Thu Oct 04 21:17:55 2018 +0200 @@ -43,15 +43,15 @@ T min = std::numeric_limits<T>::min(), T max = std::numeric_limits<T>::max()) noexcept -> std::optional<T> { - static_assert(std::is_signed<T>::value, "must be signed"); + static_assert(std::is_signed<T>::value, "must be signed"); - char* end; - auto v = std::strtoll(str.c_str(), &end, 10); + char* end; + auto v = std::strtoll(str.c_str(), &end, 10); - if (*end != '\0' || v < min || v > max) - return std::nullopt; + if (*end != '\0' || v < min || v > max) + return std::nullopt; - return static_cast<T>(v); + return static_cast<T>(v); } /** @@ -68,15 +68,15 @@ T min = std::numeric_limits<T>::min(), T max = std::numeric_limits<T>::max()) noexcept -> std::optional<T> { - static_assert(std::is_unsigned<T>::value, "must be unsigned"); + static_assert(std::is_unsigned<T>::value, "must be unsigned"); - char* end; - auto v = std::strtoull(str.c_str(), &end, 10); + char* end; + auto v = std::strtoull(str.c_str(), &end, 10); - if (*end != '\0' || v < min || v > max) - return std::nullopt; + if (*end != '\0' || v < min || v > max) + return std::nullopt; - return static_cast<T>(v); + return static_cast<T>(v); } #endif // !TO_INT_HPP