Merge pull request #4334 from mathisloge/cmake-linting

adding auto formatting
This commit is contained in:
Artem Pavlenko 2022-08-17 14:15:13 +01:00 committed by GitHub
commit 14a5cc7e1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
66 changed files with 17297 additions and 14324 deletions

View file

@ -30,7 +30,7 @@ BraceWrapping:
AfterFunction: true # see AllowShortFunctionsOnASingleLine
AfterNamespace: false
AfterStruct: true
AfterExternBlock: true
AfterExternBlock: false
BeforeCatch: false
BeforeElse: true
BeforeLambdaBody: false

View file

@ -9,68 +9,83 @@ on:
- "**"
jobs:
checkSource:
name: Check Source Code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.0
windows:
needs: checkSource
name: Windows memory mapped
uses: ./.github/workflows/windows.yml
with:
VCPKG_SHA: f6af75acc923c833a5620943e3fc7d5e4930f0df
NUGET_REGISTRY: https://nuget.pkg.github.com/mapnik/index.json
NUGET_USERNAME: mapnik
USE_MEMORY_MAPPED_FILE: 'ON'
USE_MEMORY_MAPPED_FILE: "ON"
secrets:
NUGET_REGISTRY_PAT: ${{ secrets.VCPKG_CACHE_PAT }}
windows-mmf-off:
needs: checkSource
name: Windows file based
uses: ./.github/workflows/windows.yml
with:
VCPKG_SHA: f6af75acc923c833a5620943e3fc7d5e4930f0df
NUGET_REGISTRY: https://nuget.pkg.github.com/mapnik/index.json
NUGET_USERNAME: mapnik
USE_MEMORY_MAPPED_FILE: 'OFF'
USE_MEMORY_MAPPED_FILE: "OFF"
secrets:
NUGET_REGISTRY_PAT: ${{ secrets.VCPKG_CACHE_PAT }}
ubuntu:
needs: checkSource
name: Linux memory mapped
uses: ./.github/workflows/ubuntu.yml
with:
VCPKG_SHA: f6af75acc923c833a5620943e3fc7d5e4930f0df
NUGET_REGISTRY: https://nuget.pkg.github.com/mapnik/index.json
NUGET_USERNAME: mapnik
USE_MEMORY_MAPPED_FILE: 'ON'
USE_MEMORY_MAPPED_FILE: "ON"
secrets:
NUGET_REGISTRY_PAT: ${{ secrets.VCPKG_CACHE_PAT }}
ubuntu-mmf-off:
needs: checkSource
name: Linux file based
uses: ./.github/workflows/ubuntu.yml
with:
VCPKG_SHA: f6af75acc923c833a5620943e3fc7d5e4930f0df
NUGET_REGISTRY: https://nuget.pkg.github.com/mapnik/index.json
NUGET_USERNAME: mapnik
USE_MEMORY_MAPPED_FILE: 'OFF'
USE_MEMORY_MAPPED_FILE: "OFF"
secrets:
NUGET_REGISTRY_PAT: ${{ secrets.VCPKG_CACHE_PAT }}
macos:
needs: checkSource
name: MacOS memory mapped
uses: ./.github/workflows/macos.yml
with:
VCPKG_SHA: f6af75acc923c833a5620943e3fc7d5e4930f0df
NUGET_REGISTRY: https://nuget.pkg.github.com/mapnik/index.json
NUGET_USERNAME: mapnik
USE_MEMORY_MAPPED_FILE: 'ON'
USE_MEMORY_MAPPED_FILE: "ON"
secrets:
NUGET_REGISTRY_PAT: ${{ secrets.VCPKG_CACHE_PAT }}
macos-mmf-off:
needs: checkSource
name: MacOS file based
uses: ./.github/workflows/macos.yml
with:
VCPKG_SHA: f6af75acc923c833a5620943e3fc7d5e4930f0df
NUGET_REGISTRY: https://nuget.pkg.github.com/mapnik/index.json
NUGET_USERNAME: mapnik
USE_MEMORY_MAPPED_FILE: 'OFF'
USE_MEMORY_MAPPED_FILE: "OFF"
secrets:
NUGET_REGISTRY_PAT: ${{ secrets.VCPKG_CACHE_PAT }}

16
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,16 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
files: ^.*\.cmake|CMakeLists\.txt$
- id: end-of-file-fixer
files: ^.*\.cmake|CMakeLists\.txt$
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
types_or: [c++, c]

View file

@ -5,11 +5,11 @@ cmake_minimum_required(VERSION 3.15)
include(cmake/GetVersion.cmake)
get_mapnik_version()
project(mapnik
project(mapnik
VERSION ${MAPNIK_MAJOR_VERSION}.${MAPNIK_MINOR_VERSION}.${MAPNIK_PATCH_VERSION}
HOMEPAGE_URL "https://mapnik.org/"
DESCRIPTION "Mapnik is an open source toolkit for developing mapping applications"
LANGUAGES CXX
HOMEPAGE_URL "https://mapnik.org/"
DESCRIPTION "Mapnik is an open source toolkit for developing mapping applications"
LANGUAGES CXX
)
message(STATUS "mapnik version: ${PROJECT_VERSION}")
@ -159,7 +159,7 @@ if(harfbuzz_FOUND)
message(STATUS "Found harfbuzz native cmake")
list(APPEND MAPNIK_OPTIONAL_LIBS harfbuzz::harfbuzz)
else()
# Use pkg-config when harfbuzz is not found.
# Use pkg-config when harfbuzz is not found.
# It might be possible that in future version harfbuzz could only be found via pkg-config.
# harfbuzz related discussion: https://github.com/harfbuzz/harfbuzz/issues/2653
message(STATUS "harfbuzz not found via cmake. Searching via pkg-config...")
@ -174,13 +174,13 @@ if(USE_EXTERNAL_MAPBOX_GEOMETRY)
find_path(MAPBOX_GEOMETRY_INCLUDE_DIRS "mapbox/geometry.hpp" REQUIRED)
endif()
else()
set(MAPBOX_GEOMETRY_INCLUDE_DIRS
set(MAPBOX_GEOMETRY_INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/geometry/include>
$<INSTALL_INTERFACE:include>
)
endif()
if(NOT MAPBOX_GEOMETRY_INCLUDE_DIRS)
message(FATAL_ERROR "Set -DMAPBOX_GEOMETRY_INCLUDE_DIRS to the mapbox/geometry.hpp include dir")
message(FATAL_ERROR "Set -DMAPBOX_GEOMETRY_INCLUDE_DIRS to the mapbox/geometry.hpp include dir")
endif()
if(USE_EXTERNAL_MAPBOX_POLYLABEL)
@ -189,13 +189,13 @@ if(USE_EXTERNAL_MAPBOX_POLYLABEL)
find_path(MAPBOX_POLYLABEL_INCLUDE_DIRS "mapbox/polylabel.hpp")
endif()
else()
set(MAPBOX_POLYLABEL_INCLUDE_DIRS
set(MAPBOX_POLYLABEL_INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/polylabel/include>
$<INSTALL_INTERFACE:include>
)
endif()
if(NOT MAPBOX_POLYLABEL_INCLUDE_DIRS)
message(FATAL_ERROR "Set MAPBOX_POLYLABEL_INCLUDE_DIRS to the mapbox/geometry include dir")
message(FATAL_ERROR "Set MAPBOX_POLYLABEL_INCLUDE_DIRS to the mapbox/geometry include dir")
endif()
if(USE_EXTERNAL_MAPBOX_PROTOZERO)
@ -204,13 +204,13 @@ if(USE_EXTERNAL_MAPBOX_PROTOZERO)
find_path(MAPBOX_PROTOZERO_INCLUDE_DIRS "protozero/pbf_message.hpp")
endif()
else()
set(MAPBOX_PROTOZERO_INCLUDE_DIRS
set(MAPBOX_PROTOZERO_INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/protozero/include>
$<INSTALL_INTERFACE:include>
)
endif()
if(NOT MAPBOX_PROTOZERO_INCLUDE_DIRS)
message(FATAL_ERROR "Set MAPBOX_PROTOZERO_INCLUDE_DIRS to the mapbox/protozero include dir")
message(FATAL_ERROR "Set MAPBOX_PROTOZERO_INCLUDE_DIRS to the mapbox/protozero include dir")
endif()
if(USE_EXTERNAL_MAPBOX_VARIANT)
@ -219,13 +219,13 @@ if(USE_EXTERNAL_MAPBOX_VARIANT)
find_path(MAPBOX_VARIANT_INCLUDE_DIRS "mapbox/variant.hpp")
endif()
else()
set(MAPBOX_VARIANT_INCLUDE_DIRS
set(MAPBOX_VARIANT_INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/variant/include>
$<INSTALL_INTERFACE:include>
)
endif()
if(NOT MAPBOX_VARIANT_INCLUDE_DIRS)
message(FATAL_ERROR "Set MAPBOX_VARIANT_INCLUDE_DIRS to the mapbox/variant include dir")
message(FATAL_ERROR "Set MAPBOX_VARIANT_INCLUDE_DIRS to the mapbox/variant include dir")
endif()
# (used by MapnikInstall.cmake. properties are needed since "set(...)" will be out of scope
@ -237,7 +237,7 @@ if(USE_GLIBC_WORKAROUND)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_ENABLE_GLIBC_WORKAROUND)
endif()
if(USE_BIGINT)
if(USE_BIGINT)
list(APPEND MAPNIK_COMPILE_DEFS BIGINT)
endif()
@ -338,7 +338,7 @@ if(USE_SVG_RENDERER)
list(APPEND MAPNIK_COMPILE_DEFS SVG_RENDERER)
endif()
if(NOT WIN32)
if(NOT WIN32)
message(STATUS "Compiling with -DMAPNIK_HAS_DLCFN")
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_HAS_DLCFN)
list(APPEND MAPNIK_OPTIONAL_LIBS ${CMAKE_DL_LIBS})
@ -352,8 +352,8 @@ add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
add_library(core INTERFACE)
add_library(mapnik::core ALIAS core)
target_include_directories(core INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
target_include_directories(core INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${MAPBOX_GEOMETRY_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${MAPBOX_POLYLABEL_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${MAPBOX_VARIANT_INCLUDE_DIRS}>
@ -362,7 +362,7 @@ target_include_directories(core INTERFACE
$<INSTALL_INTERFACE:include>
${MAPNIK_OPTIONAL_LIBS_INCLUDE}
)
target_link_libraries(core INTERFACE
target_link_libraries(core INTERFACE
Threads::Threads
ICU::uc
ICU::data

View file

@ -1,6 +1,6 @@
project(mapnik-benchmark)
set(BENCHMARK_SRCS
set(BENCHMARK_SRCS
src/normalize_angle.cpp
src/test_array_allocation.cpp
src/test_expression_parse.cpp
@ -32,7 +32,7 @@ function(mapnik_create_benchmark)
add_executable(${TARGET_NAME} ${ARGV0})
target_include_directories(${TARGET_NAME} PRIVATE include)
target_link_libraries(${TARGET_NAME} PRIVATE mapnik::agg mapnik::mapnik)
set_target_properties(${TARGET_NAME} PROPERTIES
set_target_properties(${TARGET_NAME} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
@ -45,7 +45,7 @@ foreach(benchmark ${BENCHMARK_SRCS})
endforeach()
file(COPY data DESTINATION "${MAPNIK_OUTPUT_DIR}/benchmark")
file(COPY run_benchmarks
DESTINATION "${MAPNIK_OUTPUT_DIR}"
file(COPY run_benchmarks
DESTINATION "${MAPNIK_OUTPUT_DIR}"
FILE_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE GROUP_WRITE GROUP_READ GROUP_EXECUTE WORLD_READ
)

View file

@ -63,11 +63,11 @@ if(CAIRO_INCLUDE_DIR AND NOT CAIRO_VERSION)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Cairo
REQUIRED_VARS
find_package_handle_standard_args(Cairo
REQUIRED_VARS
CAIRO_LIBRARY
CAIRO_INCLUDE_DIR
VERSION_VAR
VERSION_VAR
CAIRO_VERSION_STRING
)
mark_as_advanced(CAIRO_INCLUDE_DIR CAIRO_LIBRARY)

View file

@ -63,8 +63,8 @@ if ("${WebP_FIND_VERSION}" VERSION_GREATER "${WebP_VERSION}")
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WebP
REQUIRED_VARS
find_package_handle_standard_args(WebP
REQUIRED_VARS
WebP_LIBRARY
WebP_INCLUDE_DIR
VERSION_VAR WebP_VERSION

View file

@ -22,10 +22,10 @@ install(
DESTINATION ${MAPNIK_CMAKE_DIR}
)
# install our modules, so that the expected target names are found.
# install our modules, so that the expected target names are found.
install(
FILES
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindCairo.cmake"
FILES
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindCairo.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindWebP.cmake"
DESTINATION ${MAPNIK_CMAKE_DIR}/Modules
)

View file

@ -9,7 +9,7 @@ Name: @_lib_name@
Description: @_description@
Version: @MAPNIK_VERSION@
Libs: -L"${libdir}" -l$<TARGET_FILE_BASE_NAME:@_target@>$<TARGET_PROPERTY:@_target@,$<CONFIG>_POSTFIX>
Cflags: -I"${includedir}" ]]
Cflags: -I"${includedir}" ]]
_contents @ONLY)
file(GENERATE
@ -26,11 +26,11 @@ endfunction()
function(create_pkg_config_file_mapnik _lib_name _description)
get_target_property(m_compile_defs core INTERFACE_COMPILE_DEFINITIONS)
string(JOIN " -D" m_str_compile_defs ${m_compile_defs})
if(m_str_compile_defs)
if(m_str_compile_defs)
set(m_str_compile_defs "-D${m_str_compile_defs}")
endif()
set(m_requires
set(m_requires
libmapnikwkt
libmapnikjson
icu-uc
@ -71,7 +71,7 @@ Description: @_description@
Version: @MAPNIK_VERSION@
Requires: @m_requires@
Libs: -L"${libdir}" -l$<TARGET_FILE_BASE_NAME:mapnik>$<TARGET_PROPERTY:mapnik,$<CONFIG>_POSTFIX>
Cflags: -I"${includedir}" @m_str_compile_defs@]]
Cflags: -I"${includedir}" @m_str_compile_defs@]]
_contents @ONLY)
file(GENERATE
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_lib_name}-$<CONFIG>.pc

View file

@ -87,7 +87,7 @@ function(mapnik_install_targets)
message(STATUS \"internal_executables: ${_internal_executables}\")
message(STATUS \"internal_libraries: ${_internal_libraries}\")
message(STATUS \"ADDITIONAL_LIBARIES_PATHS: ${ADDITIONAL_LIBARIES_PATHS}\")
include(BundleUtilities)
fixup_bundle(\"${_internal_executables}\" \"${_internal_libraries}\" \"${ADDITIONAL_LIBARIES_PATHS}\")
" COMPONENT MapnikRuntime)

View file

@ -1,5 +1,5 @@
function(format_dir dir)
file(GLOB_RECURSE sources
file(GLOB_RECURSE sources
"${dir}/*.cpp"
"${dir}/*.hpp"
)

View file

@ -32,14 +32,14 @@ function(mapnik_find_plugin_dir PLUGIN_DIR)
string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type_l)
set(_plugin_dir "${MAPNIK_PLUGINS_DIR_${_build_type_l}}")
# only release has more then one configuration
if(NOT _plugin_dir)
if(NOT _plugin_dir)
set(_all_rel_cfgs RELEASE RELWITHDEBINFO MINSIZEREL)
list(FIND _all_rel_cfgs ${_build_type_l} _is_rel_cfg)
# check if the current configuration is a known release configuration
if(${_is_rel_cfg} GREATER_EQUAL 0)
foreach(_rel_cfg IN LISTS _all_rel_cfgs)
set(_plugin_dir "${MAPNIK_PLUGINS_DIR_${_rel_cfg}}")
if(_plugin_dir)
if(_plugin_dir)
break()
endif()
endforeach()
@ -49,4 +49,4 @@ function(mapnik_find_plugin_dir PLUGIN_DIR)
message(WARNING "Could not find a plugin install dir for configuration ${_build_type_l}")
endif()
set(${PLUGIN_DIR} ${_plugin_dir} PARENT_SCOPE)
endfunction()
endfunction()

View file

@ -1,5 +1,5 @@
add_executable(mapnik-demo rundemo.cpp)
set_target_properties(mapnik-demo PROPERTIES
set_target_properties(mapnik-demo PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"

View file

@ -14,7 +14,7 @@ set(PROJECT_SOURCES
styles_model.cpp
forms/about.ui
forms/info.ui
forms/layer_info.ui
forms/layer_info.ui
mapnik_viewer.qrc
)
@ -37,7 +37,7 @@ endif()
set_target_properties(mapnik-viewer PROPERTIES
AUTOUIC_SEARCH_PATHS forms
AUTORCC ON
AUTORCC ON
AUTOUIC ON
AUTOMOC ON
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
@ -45,13 +45,13 @@ set_target_properties(mapnik-viewer PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
target_link_libraries(mapnik-viewer PRIVATE
target_link_libraries(mapnik-viewer PRIVATE
Qt${QT_VERSION_MAJOR}::Widgets
mapnik::agg
mapnik::mapnik
)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini
"[mapnik]
plugins_dir=${PLUGINS_INSTALL_DIR}
fonts/1/dir=${FONTS_INSTALL_DIR}

1
deps/agg/.clang-format vendored Normal file
View file

@ -0,0 +1 @@
DisableFormat: true

View file

@ -3,8 +3,8 @@ project(agg)
add_library(agg INTERFACE)
add_library(mapnik::agg ALIAS agg)
target_include_directories(agg INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
target_include_directories(agg INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(agg INTERFACE mapnik::core)

1
deps/boost/.clang-format vendored Normal file
View file

@ -0,0 +1 @@
DisableFormat: true

1
deps/mapbox/.clang-format vendored Normal file
View file

@ -0,0 +1 @@
DisableFormat: true

File diff suppressed because it is too large Load diff

View file

@ -43,9 +43,9 @@
#include <mapnik/sparsehash/internal/sparseconfig.h>
#include <assert.h>
#include <stdio.h>
#include <stddef.h> // for size_t
#include <stddef.h> // for size_t
#include <iosfwd>
#include <stdexcept> // For length_error
#include <stdexcept> // For length_error
_START_GOOGLE_NAMESPACE_
@ -80,15 +80,15 @@ namespace sparsehash_internal {
// ----- low-level I/O for FILE* ----
template<typename Ignored>
inline bool read_data_internal(Ignored*, FILE* fp,
void* data, size_t length) {
return fread(data, length, 1, fp) == 1;
inline bool read_data_internal(Ignored*, FILE* fp, void* data, size_t length)
{
return fread(data, length, 1, fp) == 1;
}
template<typename Ignored>
inline bool write_data_internal(Ignored*, FILE* fp,
const void* data, size_t length) {
return fwrite(data, length, 1, fp) == 1;
inline bool write_data_internal(Ignored*, FILE* fp, const void* data, size_t length)
{
return fwrite(data, length, 1, fp) == 1;
}
// ----- low-level I/O for iostream ----
@ -98,55 +98,57 @@ inline bool write_data_internal(Ignored*, FILE* fp,
// it's only legal to delay the instantiation the way we want to if
// the istream/ostream is a template type. So we jump through hoops.
template<typename ISTREAM>
inline bool read_data_internal_for_istream(ISTREAM* fp,
void* data, size_t length) {
return fp->read(reinterpret_cast<char*>(data), length).good();
inline bool read_data_internal_for_istream(ISTREAM* fp, void* data, size_t length)
{
return fp->read(reinterpret_cast<char*>(data), length).good();
}
template<typename Ignored>
inline bool read_data_internal(Ignored*, std::istream* fp,
void* data, size_t length) {
return read_data_internal_for_istream(fp, data, length);
inline bool read_data_internal(Ignored*, std::istream* fp, void* data, size_t length)
{
return read_data_internal_for_istream(fp, data, length);
}
template<typename OSTREAM>
inline bool write_data_internal_for_ostream(OSTREAM* fp,
const void* data, size_t length) {
return fp->write(reinterpret_cast<const char*>(data), length).good();
inline bool write_data_internal_for_ostream(OSTREAM* fp, const void* data, size_t length)
{
return fp->write(reinterpret_cast<const char*>(data), length).good();
}
template<typename Ignored>
inline bool write_data_internal(Ignored*, std::ostream* fp,
const void* data, size_t length) {
return write_data_internal_for_ostream(fp, data, length);
inline bool write_data_internal(Ignored*, std::ostream* fp, const void* data, size_t length)
{
return write_data_internal_for_ostream(fp, data, length);
}
// ----- low-level I/O for custom streams ----
// The INPUT type needs to support a Read() method that takes a
// buffer and a length and returns the number of bytes read.
template <typename INPUT>
inline bool read_data_internal(INPUT* fp, void*,
void* data, size_t length) {
return static_cast<size_t>(fp->Read(data, length)) == length;
template<typename INPUT>
inline bool read_data_internal(INPUT* fp, void*, void* data, size_t length)
{
return static_cast<size_t>(fp->Read(data, length)) == length;
}
// The OUTPUT type needs to support a Write() operation that takes
// a buffer and a length and returns the number of bytes written.
template <typename OUTPUT>
inline bool write_data_internal(OUTPUT* fp, void*,
const void* data, size_t length) {
return static_cast<size_t>(fp->Write(data, length)) == length;
template<typename OUTPUT>
inline bool write_data_internal(OUTPUT* fp, void*, const void* data, size_t length)
{
return static_cast<size_t>(fp->Write(data, length)) == length;
}
// ----- low-level I/O: the public API ----
template <typename INPUT>
inline bool read_data(INPUT* fp, void* data, size_t length) {
return read_data_internal(fp, fp, data, length);
template<typename INPUT>
inline bool read_data(INPUT* fp, void* data, size_t length)
{
return read_data_internal(fp, fp, data, length);
}
template <typename OUTPUT>
inline bool write_data(OUTPUT* fp, const void* data, size_t length) {
return write_data_internal(fp, fp, data, length);
template<typename OUTPUT>
inline bool write_data(OUTPUT* fp, const void* data, size_t length)
{
return write_data_internal(fp, fp, data, length);
}
// Uses read_data() and write_data() to read/write an integer.
@ -154,26 +156,32 @@ inline bool write_data(OUTPUT* fp, const void* data, size_t length) {
// from sizeof(IntType), allowing us to save on a 32-bit system
// and load on a 64-bit system). Excess bytes are taken to be 0.
// INPUT and OUTPUT must match legal inputs to read/write_data (above).
template <typename INPUT, typename IntType>
bool read_bigendian_number(INPUT* fp, IntType* value, size_t length) {
*value = 0;
unsigned char byte;
for (size_t i = 0; i < length; ++i) {
if (!read_data(fp, &byte, sizeof(byte))) return false;
*value |= static_cast<IntType>(byte) << ((length - 1 - i) * 8);
}
return true;
template<typename INPUT, typename IntType>
bool read_bigendian_number(INPUT* fp, IntType* value, size_t length)
{
*value = 0;
unsigned char byte;
for (size_t i = 0; i < length; ++i)
{
if (!read_data(fp, &byte, sizeof(byte)))
return false;
*value |= static_cast<IntType>(byte) << ((length - 1 - i) * 8);
}
return true;
}
template <typename OUTPUT, typename IntType>
bool write_bigendian_number(OUTPUT* fp, IntType value, size_t length) {
unsigned char byte;
for (size_t i = 0; i < length; ++i) {
byte = (sizeof(value) <= length-1 - i)
? 0 : static_cast<unsigned char>((value >> ((length-1 - i) * 8)) & 255);
if (!write_data(fp, &byte, sizeof(byte))) return false;
}
return true;
template<typename OUTPUT, typename IntType>
bool write_bigendian_number(OUTPUT* fp, IntType value, size_t length)
{
unsigned char byte;
for (size_t i = 0; i < length; ++i)
{
byte =
(sizeof(value) <= length - 1 - i) ? 0 : static_cast<unsigned char>((value >> ((length - 1 - i) * 8)) & 255);
if (!write_data(fp, &byte, sizeof(byte)))
return false;
}
return true;
}
// If your keys and values are simple enough, you can pass this
@ -181,19 +189,22 @@ bool write_bigendian_number(OUTPUT* fp, IntType value, size_t length) {
// value_type is a POD type that contains no pointers. Note,
// however, we don't try to normalize endianness.
// This is the type used for NopointerSerializer.
template <typename value_type> struct pod_serializer {
template <typename INPUT>
bool operator()(INPUT* fp, value_type* value) const {
return read_data(fp, value, sizeof(*value));
}
template<typename value_type>
struct pod_serializer
{
template<typename INPUT>
bool operator()(INPUT* fp, value_type* value) const
{
return read_data(fp, value, sizeof(*value));
}
template <typename OUTPUT>
bool operator()(OUTPUT* fp, const value_type& value) const {
return write_data(fp, &value, sizeof(value));
}
template<typename OUTPUT>
bool operator()(OUTPUT* fp, const value_type& value) const
{
return write_data(fp, &value, sizeof(value));
}
};
// Settings contains parameters for growing and shrinking the table.
// It also packages zero-size functor (ie. hasher).
//
@ -206,165 +217,136 @@ template <typename value_type> struct pod_serializer {
// for sure that the hash is the identity hash. If it's not, this
// is needless work (and possibly, though not likely, harmful).
template<typename Key, typename HashFunc,
typename SizeType, int HT_MIN_BUCKETS>
class sh_hashtable_settings : public HashFunc {
public:
typedef Key key_type;
typedef HashFunc hasher;
typedef SizeType size_type;
template<typename Key, typename HashFunc, typename SizeType, int HT_MIN_BUCKETS>
class sh_hashtable_settings : public HashFunc
{
public:
typedef Key key_type;
typedef HashFunc hasher;
typedef SizeType size_type;
public:
sh_hashtable_settings(const hasher& hf,
const float ht_occupancy_flt,
const float ht_empty_flt)
: hasher(hf),
enlarge_threshold_(0),
shrink_threshold_(0),
consider_shrink_(false),
use_empty_(false),
use_deleted_(false),
num_ht_copies_(0) {
set_enlarge_factor(ht_occupancy_flt);
set_shrink_factor(ht_empty_flt);
}
size_type hash(const key_type& v) const {
// We munge the hash value when we don't trust hasher::operator().
return hash_munger<Key>::MungedHash(hasher::operator()(v));
}
float enlarge_factor() const {
return enlarge_factor_;
}
void set_enlarge_factor(float f) {
enlarge_factor_ = f;
}
float shrink_factor() const {
return shrink_factor_;
}
void set_shrink_factor(float f) {
shrink_factor_ = f;
}
size_type enlarge_threshold() const {
return enlarge_threshold_;
}
void set_enlarge_threshold(size_type t) {
enlarge_threshold_ = t;
}
size_type shrink_threshold() const {
return shrink_threshold_;
}
void set_shrink_threshold(size_type t) {
shrink_threshold_ = t;
}
size_type enlarge_size(size_type x) const {
return static_cast<size_type>(x * enlarge_factor_);
}
size_type shrink_size(size_type x) const {
return static_cast<size_type>(x * shrink_factor_);
}
bool consider_shrink() const {
return consider_shrink_;
}
void set_consider_shrink(bool t) {
consider_shrink_ = t;
}
bool use_empty() const {
return use_empty_;
}
void set_use_empty(bool t) {
use_empty_ = t;
}
bool use_deleted() const {
return use_deleted_;
}
void set_use_deleted(bool t) {
use_deleted_ = t;
}
size_type num_ht_copies() const {
return static_cast<size_type>(num_ht_copies_);
}
void inc_num_ht_copies() {
++num_ht_copies_;
}
// Reset the enlarge and shrink thresholds
void reset_thresholds(size_type num_buckets) {
set_enlarge_threshold(enlarge_size(num_buckets));
set_shrink_threshold(shrink_size(num_buckets));
// whatever caused us to reset already considered
set_consider_shrink(false);
}
// Caller is resposible for calling reset_threshold right after
// set_resizing_parameters.
void set_resizing_parameters(float shrink, float grow) {
assert(shrink >= 0.0);
assert(grow <= 1.0);
if (shrink > grow/2.0f)
shrink = grow / 2.0f; // otherwise we thrash hashtable size
set_shrink_factor(shrink);
set_enlarge_factor(grow);
}
// This is the smallest size a hashtable can be without being too crowded
// If you like, you can give a min #buckets as well as a min #elts
size_type min_buckets(size_type num_elts, size_type min_buckets_wanted) {
float enlarge = enlarge_factor();
size_type sz = HT_MIN_BUCKETS; // min buckets allowed
while ( sz < min_buckets_wanted ||
num_elts >= static_cast<size_type>(sz * enlarge) ) {
// This just prevents overflowing size_type, since sz can exceed
// max_size() here.
if (static_cast<size_type>(sz * 2) < sz) {
throw std::length_error("resize overflow"); // protect against overflow
}
sz *= 2;
public:
sh_hashtable_settings(const hasher& hf, const float ht_occupancy_flt, const float ht_empty_flt)
: hasher(hf)
, enlarge_threshold_(0)
, shrink_threshold_(0)
, consider_shrink_(false)
, use_empty_(false)
, use_deleted_(false)
, num_ht_copies_(0)
{
set_enlarge_factor(ht_occupancy_flt);
set_shrink_factor(ht_empty_flt);
}
return sz;
}
private:
template<class HashKey> class hash_munger {
public:
static size_t MungedHash(size_t hash) {
return hash;
size_type hash(const key_type& v) const
{
// We munge the hash value when we don't trust hasher::operator().
return hash_munger<Key>::MungedHash(hasher::operator()(v));
}
};
// This matches when the hashtable key is a pointer.
template<class HashKey> class hash_munger<HashKey*> {
public:
static size_t MungedHash(size_t hash) {
// TODO(csilvers): consider rotating instead:
// static const int shift = (sizeof(void *) == 4) ? 2 : 3;
// return (hash << (sizeof(hash) * 8) - shift)) | (hash >> shift);
// This matters if we ever change sparse/dense_hash_* to compare
// hashes before comparing actual values. It's speedy on x86.
return hash / sizeof(void*); // get rid of known-0 bits
}
};
size_type enlarge_threshold_; // table.size() * enlarge_factor
size_type shrink_threshold_; // table.size() * shrink_factor
float enlarge_factor_; // how full before resize
float shrink_factor_; // how empty before resize
// consider_shrink=true if we should try to shrink before next insert
bool consider_shrink_;
bool use_empty_; // used only by densehashtable, not sparsehashtable
bool use_deleted_; // false until delkey has been set
// num_ht_copies is a counter incremented every Copy/Move
unsigned int num_ht_copies_;
float enlarge_factor() const { return enlarge_factor_; }
void set_enlarge_factor(float f) { enlarge_factor_ = f; }
float shrink_factor() const { return shrink_factor_; }
void set_shrink_factor(float f) { shrink_factor_ = f; }
size_type enlarge_threshold() const { return enlarge_threshold_; }
void set_enlarge_threshold(size_type t) { enlarge_threshold_ = t; }
size_type shrink_threshold() const { return shrink_threshold_; }
void set_shrink_threshold(size_type t) { shrink_threshold_ = t; }
size_type enlarge_size(size_type x) const { return static_cast<size_type>(x * enlarge_factor_); }
size_type shrink_size(size_type x) const { return static_cast<size_type>(x * shrink_factor_); }
bool consider_shrink() const { return consider_shrink_; }
void set_consider_shrink(bool t) { consider_shrink_ = t; }
bool use_empty() const { return use_empty_; }
void set_use_empty(bool t) { use_empty_ = t; }
bool use_deleted() const { return use_deleted_; }
void set_use_deleted(bool t) { use_deleted_ = t; }
size_type num_ht_copies() const { return static_cast<size_type>(num_ht_copies_); }
void inc_num_ht_copies() { ++num_ht_copies_; }
// Reset the enlarge and shrink thresholds
void reset_thresholds(size_type num_buckets)
{
set_enlarge_threshold(enlarge_size(num_buckets));
set_shrink_threshold(shrink_size(num_buckets));
// whatever caused us to reset already considered
set_consider_shrink(false);
}
// Caller is resposible for calling reset_threshold right after
// set_resizing_parameters.
void set_resizing_parameters(float shrink, float grow)
{
assert(shrink >= 0.0);
assert(grow <= 1.0);
if (shrink > grow / 2.0f)
shrink = grow / 2.0f; // otherwise we thrash hashtable size
set_shrink_factor(shrink);
set_enlarge_factor(grow);
}
// This is the smallest size a hashtable can be without being too crowded
// If you like, you can give a min #buckets as well as a min #elts
size_type min_buckets(size_type num_elts, size_type min_buckets_wanted)
{
float enlarge = enlarge_factor();
size_type sz = HT_MIN_BUCKETS; // min buckets allowed
while (sz < min_buckets_wanted || num_elts >= static_cast<size_type>(sz * enlarge))
{
// This just prevents overflowing size_type, since sz can exceed
// max_size() here.
if (static_cast<size_type>(sz * 2) < sz)
{
throw std::length_error("resize overflow"); // protect against overflow
}
sz *= 2;
}
return sz;
}
private:
template<class HashKey>
class hash_munger
{
public:
static size_t MungedHash(size_t hash) { return hash; }
};
// This matches when the hashtable key is a pointer.
template<class HashKey>
class hash_munger<HashKey*>
{
public:
static size_t MungedHash(size_t hash)
{
// TODO(csilvers): consider rotating instead:
// static const int shift = (sizeof(void *) == 4) ? 2 : 3;
// return (hash << (sizeof(hash) * 8) - shift)) | (hash >> shift);
// This matters if we ever change sparse/dense_hash_* to compare
// hashes before comparing actual values. It's speedy on x86.
return hash / sizeof(void*); // get rid of known-0 bits
}
};
size_type enlarge_threshold_; // table.size() * enlarge_factor
size_type shrink_threshold_; // table.size() * shrink_factor
float enlarge_factor_; // how full before resize
float shrink_factor_; // how empty before resize
// consider_shrink=true if we should try to shrink before next insert
bool consider_shrink_;
bool use_empty_; // used only by densehashtable, not sparsehashtable
bool use_deleted_; // false until delkey has been set
// num_ht_copies is a counter incremented every Copy/Move
unsigned int num_ht_copies_;
};
} // namespace sparsehash_internal
} // namespace sparsehash_internal
_END_GOOGLE_NAMESPACE_
#endif // UTIL_GTL_HASHTABLE_COMMON_H_
#endif // UTIL_GTL_HASHTABLE_COMMON_H_

View file

@ -33,87 +33,82 @@
#define UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_
#include <mapnik/sparsehash/internal/sparseconfig.h>
#include <stdlib.h> // for malloc/realloc/free
#include <stddef.h> // for ptrdiff_t
#include <new> // for placement new
#include <stdlib.h> // for malloc/realloc/free
#include <stddef.h> // for ptrdiff_t
#include <new> // for placement new
_START_GOOGLE_NAMESPACE_
template<class T>
class libc_allocator_with_realloc {
public:
typedef T value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
class libc_allocator_with_realloc
{
public:
typedef T value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
libc_allocator_with_realloc() {}
libc_allocator_with_realloc(const libc_allocator_with_realloc&) {}
~libc_allocator_with_realloc() {}
libc_allocator_with_realloc() {}
libc_allocator_with_realloc(const libc_allocator_with_realloc&) {}
~libc_allocator_with_realloc() {}
pointer address(reference r) const { return &r; }
const_pointer address(const_reference r) const { return &r; }
pointer address(reference r) const { return &r; }
const_pointer address(const_reference r) const { return &r; }
pointer allocate(size_type n, const_pointer = 0) {
return static_cast<pointer>(malloc(n * sizeof(value_type)));
}
void deallocate(pointer p, size_type) {
free(p);
}
pointer reallocate(pointer p, size_type n) {
return static_cast<pointer>(realloc(p, n * sizeof(value_type)));
}
pointer allocate(size_type n, const_pointer = 0) { return static_cast<pointer>(malloc(n * sizeof(value_type))); }
void deallocate(pointer p, size_type) { free(p); }
pointer reallocate(pointer p, size_type n) { return static_cast<pointer>(realloc(p, n * sizeof(value_type))); }
size_type max_size() const {
return static_cast<size_type>(-1) / sizeof(value_type);
}
size_type max_size() const { return static_cast<size_type>(-1) / sizeof(value_type); }
void construct(pointer p, const value_type& val) {
new(p) value_type(val);
}
void destroy(pointer p) { p->~value_type(); }
void construct(pointer p, const value_type& val) { new (p) value_type(val); }
void destroy(pointer p) { p->~value_type(); }
template <class U>
libc_allocator_with_realloc(const libc_allocator_with_realloc<U>&) {}
template<class U>
libc_allocator_with_realloc(const libc_allocator_with_realloc<U>&)
{}
template<class U>
struct rebind {
typedef libc_allocator_with_realloc<U> other;
};
template<class U>
struct rebind
{
typedef libc_allocator_with_realloc<U> other;
};
};
// libc_allocator_with_realloc<void> specialization.
template<>
class libc_allocator_with_realloc<void> {
public:
typedef void value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef void* pointer;
typedef const void* const_pointer;
class libc_allocator_with_realloc<void>
{
public:
typedef void value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef void* pointer;
typedef const void* const_pointer;
template<class U>
struct rebind {
typedef libc_allocator_with_realloc<U> other;
};
template<class U>
struct rebind
{
typedef libc_allocator_with_realloc<U> other;
};
};
template<class T>
inline bool operator==(const libc_allocator_with_realloc<T>&,
const libc_allocator_with_realloc<T>&) {
return true;
inline bool operator==(const libc_allocator_with_realloc<T>&, const libc_allocator_with_realloc<T>&)
{
return true;
}
template<class T>
inline bool operator!=(const libc_allocator_with_realloc<T>&,
const libc_allocator_with_realloc<T>&) {
return false;
inline bool operator!=(const libc_allocator_with_realloc<T>&, const libc_allocator_with_realloc<T>&)
{
return false;
}
_END_GOOGLE_NAMESPACE_
#endif // UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_
#endif // UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_

View file

@ -56,14 +56,16 @@ _START_GOOGLE_NAMESPACE_
// sizeof(big_)
typedef char small_;
struct big_ {
char dummy[2];
struct big_
{
char dummy[2];
};
// Identity metafunction.
template <class T>
struct identity_ {
typedef T type;
template<class T>
struct identity_
{
typedef T type;
};
// integral_constant, defined in tr1, is a wrapper for an integer
@ -72,63 +74,64 @@ struct identity_ {
// general integer_constant for compatibility with tr1.
template<class T, T v>
struct integral_constant {
static const T value = v;
typedef T value_type;
typedef integral_constant<T, v> type;
struct integral_constant
{
static const T value = v;
typedef T value_type;
typedef integral_constant<T, v> type;
};
template <class T, T v> const T integral_constant<T, v>::value;
template<class T, T v>
const T integral_constant<T, v>::value;
// Abbreviations: true_type and false_type are structs that represent boolean
// true and false values. Also define the boost::mpl versions of those names,
// true_ and false_.
typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, false> false_type;
typedef true_type true_;
typedef true_type true_;
typedef false_type false_;
// if_ is a templatized conditional statement.
// if_<cond, A, B> is a compile time evaluation of cond.
// if_<>::type contains A if cond is true, B otherwise.
template<bool cond, typename A, typename B>
struct if_{
typedef A type;
struct if_
{
typedef A type;
};
template<typename A, typename B>
struct if_<false, A, B> {
typedef B type;
struct if_<false, A, B>
{
typedef B type;
};
// type_equals_ is a template type comparator, similar to Loki IsSameType.
// type_equals_<A, B>::value is true iff "A" is the same type as "B".
//
// New code should prefer base::is_same, defined in base/type_traits.h.
// It is functionally identical, but is_same is the standard spelling.
template<typename A, typename B>
struct type_equals_ : public false_ {
};
struct type_equals_ : public false_
{};
template<typename A>
struct type_equals_<A, A> : public true_ {
};
struct type_equals_<A, A> : public true_
{};
// and_ is a template && operator.
// and_<A, B>::value evaluates "A::value && B::value".
template<typename A, typename B>
struct and_ : public integral_constant<bool, (A::value && B::value)> {
};
struct and_ : public integral_constant<bool, (A::value && B::value)>
{};
// or_ is a template || operator.
// or_<A, B>::value evaluates "A::value || B::value".
template<typename A, typename B>
struct or_ : public integral_constant<bool, (A::value || B::value)> {
};
struct or_ : public integral_constant<bool, (A::value || B::value)>
{};
_END_GOOGLE_NAMESPACE_
#endif // BASE_TEMPLATE_UTIL_H_
#endif // BASE_TEMPLATE_UTIL_H_

View file

@ -58,106 +58,188 @@
#define BASE_TYPE_TRAITS_H_
#include <mapnik/sparsehash/internal/sparseconfig.h>
#include <utility> // For pair
#include <utility> // For pair
#include <mapnik/sparsehash/template_util.h> // For true_type and false_type
#include <mapnik/sparsehash/template_util.h> // For true_type and false_type
_START_GOOGLE_NAMESPACE_
template <class T> struct is_integral;
template <class T> struct is_floating_point;
template <class T> struct is_pointer;
template<class T>
struct is_integral;
template<class T>
struct is_floating_point;
template<class T>
struct is_pointer;
// MSVC can't compile this correctly, and neither can gcc 3.3.5 (at least)
#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
// is_enum uses is_convertible, which is not available on MSVC.
template <class T> struct is_enum;
template<class T>
struct is_enum;
#endif
template <class T> struct is_reference;
template <class T> struct is_pod;
template <class T> struct has_trivial_constructor;
template <class T> struct has_trivial_copy;
template <class T> struct has_trivial_assign;
template <class T> struct has_trivial_destructor;
template <class T> struct remove_const;
template <class T> struct remove_volatile;
template <class T> struct remove_cv;
template <class T> struct remove_reference;
template <class T> struct add_reference;
template <class T> struct remove_pointer;
template <class T, class U> struct is_same;
template<class T>
struct is_reference;
template<class T>
struct is_pod;
template<class T>
struct has_trivial_constructor;
template<class T>
struct has_trivial_copy;
template<class T>
struct has_trivial_assign;
template<class T>
struct has_trivial_destructor;
template<class T>
struct remove_const;
template<class T>
struct remove_volatile;
template<class T>
struct remove_cv;
template<class T>
struct remove_reference;
template<class T>
struct add_reference;
template<class T>
struct remove_pointer;
template<class T, class U>
struct is_same;
#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
template <class From, class To> struct is_convertible;
template<class From, class To>
struct is_convertible;
#endif
// is_integral is false except for the built-in integer types. A
// cv-qualified type is integral if and only if the underlying type is.
template <class T> struct is_integral : false_type { };
template<> struct is_integral<bool> : true_type { };
template<> struct is_integral<char> : true_type { };
template<> struct is_integral<unsigned char> : true_type { };
template<> struct is_integral<signed char> : true_type { };
template<class T>
struct is_integral : false_type
{};
template<>
struct is_integral<bool> : true_type
{};
template<>
struct is_integral<char> : true_type
{};
template<>
struct is_integral<unsigned char> : true_type
{};
template<>
struct is_integral<signed char> : true_type
{};
#if defined(_MSC_VER)
// wchar_t is not by default a distinct type from unsigned short in
// Microsoft C.
// See http://msdn2.microsoft.com/en-us/library/dh8che7s(VS.80).aspx
template<> struct is_integral<__wchar_t> : true_type { };
template<>
struct is_integral<__wchar_t> : true_type
{};
#else
template<> struct is_integral<wchar_t> : true_type { };
template<>
struct is_integral<wchar_t> : true_type
{};
#endif
template<> struct is_integral<short> : true_type { };
template<> struct is_integral<unsigned short> : true_type { };
template<> struct is_integral<int> : true_type { };
template<> struct is_integral<unsigned int> : true_type { };
template<> struct is_integral<long> : true_type { };
template<> struct is_integral<unsigned long> : true_type { };
template<>
struct is_integral<short> : true_type
{};
template<>
struct is_integral<unsigned short> : true_type
{};
template<>
struct is_integral<int> : true_type
{};
template<>
struct is_integral<unsigned int> : true_type
{};
template<>
struct is_integral<long> : true_type
{};
template<>
struct is_integral<unsigned long> : true_type
{};
#ifdef HAVE_LONG_LONG
template<> struct is_integral<long long> : true_type { };
template<> struct is_integral<unsigned long long> : true_type { };
template<>
struct is_integral<long long> : true_type
{};
template<>
struct is_integral<unsigned long long> : true_type
{};
#endif
template <class T> struct is_integral<const T> : is_integral<T> { };
template <class T> struct is_integral<volatile T> : is_integral<T> { };
template <class T> struct is_integral<const volatile T> : is_integral<T> { };
template<class T>
struct is_integral<const T> : is_integral<T>
{};
template<class T>
struct is_integral<volatile T> : is_integral<T>
{};
template<class T>
struct is_integral<const volatile T> : is_integral<T>
{};
// is_floating_point is false except for the built-in floating-point types.
// A cv-qualified type is integral if and only if the underlying type is.
template <class T> struct is_floating_point : false_type { };
template<> struct is_floating_point<float> : true_type { };
template<> struct is_floating_point<double> : true_type { };
template<> struct is_floating_point<long double> : true_type { };
template <class T> struct is_floating_point<const T>
: is_floating_point<T> { };
template <class T> struct is_floating_point<volatile T>
: is_floating_point<T> { };
template <class T> struct is_floating_point<const volatile T>
: is_floating_point<T> { };
template<class T>
struct is_floating_point : false_type
{};
template<>
struct is_floating_point<float> : true_type
{};
template<>
struct is_floating_point<double> : true_type
{};
template<>
struct is_floating_point<long double> : true_type
{};
template<class T>
struct is_floating_point<const T> : is_floating_point<T>
{};
template<class T>
struct is_floating_point<volatile T> : is_floating_point<T>
{};
template<class T>
struct is_floating_point<const volatile T> : is_floating_point<T>
{};
// is_pointer is false except for pointer types. A cv-qualified type (e.g.
// "int* const", as opposed to "int const*") is cv-qualified if and only if
// the underlying type is.
template <class T> struct is_pointer : false_type { };
template <class T> struct is_pointer<T*> : true_type { };
template <class T> struct is_pointer<const T> : is_pointer<T> { };
template <class T> struct is_pointer<volatile T> : is_pointer<T> { };
template <class T> struct is_pointer<const volatile T> : is_pointer<T> { };
template<class T>
struct is_pointer : false_type
{};
template<class T>
struct is_pointer<T*> : true_type
{};
template<class T>
struct is_pointer<const T> : is_pointer<T>
{};
template<class T>
struct is_pointer<volatile T> : is_pointer<T>
{};
template<class T>
struct is_pointer<const volatile T> : is_pointer<T>
{};
#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
namespace internal {
template <class T> struct is_class_or_union {
template <class U> static small_ tester(void (U::*)());
template <class U> static big_ tester(...);
static const bool value = sizeof(tester<T>(0)) == sizeof(small_);
template<class T>
struct is_class_or_union
{
template<class U>
static small_ tester(void (U::*)());
template<class U>
static big_ tester(...);
static const bool value = sizeof(tester<T>(0)) == sizeof(small_);
};
// is_convertible chokes if the first argument is an array. That's why
// we use add_reference here.
template <bool NotUnum, class T> struct is_enum_impl
: is_convertible<typename add_reference<T>::type, int> { };
template<bool NotUnum, class T>
struct is_enum_impl : is_convertible<typename add_reference<T>::type, int>
{};
template <class T> struct is_enum_impl<true, T> : false_type { };
template<class T>
struct is_enum_impl<true, T> : false_type
{};
} // namespace internal
} // namespace internal
// Specified by TR1 [4.5.1] primary type categories.
@ -174,127 +256,212 @@ template <class T> struct is_enum_impl<true, T> : false_type { };
// Is-convertible-to-int check is done only if all other checks pass,
// because it can't be used with some types (e.g. void or classes with
// inaccessible conversion operators).
template <class T> struct is_enum
: internal::is_enum_impl<
is_same<T, void>::value ||
is_integral<T>::value ||
is_floating_point<T>::value ||
is_reference<T>::value ||
internal::is_class_or_union<T>::value,
T> { };
template<class T>
struct is_enum
: internal::is_enum_impl<is_same<T, void>::value || is_integral<T>::value || is_floating_point<T>::value ||
is_reference<T>::value || internal::is_class_or_union<T>::value,
T>
{};
template <class T> struct is_enum<const T> : is_enum<T> { };
template <class T> struct is_enum<volatile T> : is_enum<T> { };
template <class T> struct is_enum<const volatile T> : is_enum<T> { };
template<class T>
struct is_enum<const T> : is_enum<T>
{};
template<class T>
struct is_enum<volatile T> : is_enum<T>
{};
template<class T>
struct is_enum<const volatile T> : is_enum<T>
{};
#endif
// is_reference is false except for reference types.
template<typename T> struct is_reference : false_type {};
template<typename T> struct is_reference<T&> : true_type {};
template<typename T>
struct is_reference : false_type
{};
template<typename T>
struct is_reference<T&> : true_type
{};
// We can't get is_pod right without compiler help, so fail conservatively.
// We will assume it's false except for arithmetic types, enumerations,
// pointers and cv-qualified versions thereof. Note that std::pair<T,U>
// is not a POD even if T and U are PODs.
template <class T> struct is_pod
: integral_constant<bool, (is_integral<T>::value ||
is_floating_point<T>::value ||
template<class T>
struct is_pod : integral_constant<bool,
(is_integral<T>::value || is_floating_point<T>::value ||
#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
// is_enum is not available on MSVC.
is_enum<T>::value ||
// is_enum is not available on MSVC.
is_enum<T>::value ||
#endif
is_pointer<T>::value)> { };
template <class T> struct is_pod<const T> : is_pod<T> { };
template <class T> struct is_pod<volatile T> : is_pod<T> { };
template <class T> struct is_pod<const volatile T> : is_pod<T> { };
is_pointer<T>::value)>
{};
template<class T>
struct is_pod<const T> : is_pod<T>
{};
template<class T>
struct is_pod<volatile T> : is_pod<T>
{};
template<class T>
struct is_pod<const volatile T> : is_pod<T>
{};
// We can't get has_trivial_constructor right without compiler help, so
// fail conservatively. We will assume it's false except for: (1) types
// for which is_pod is true. (2) std::pair of types with trivial
// constructors. (3) array of a type with a trivial constructor.
// (4) const versions thereof.
template <class T> struct has_trivial_constructor : is_pod<T> { };
template <class T, class U> struct has_trivial_constructor<std::pair<T, U> >
: integral_constant<bool,
(has_trivial_constructor<T>::value &&
has_trivial_constructor<U>::value)> { };
template <class A, int N> struct has_trivial_constructor<A[N]>
: has_trivial_constructor<A> { };
template <class T> struct has_trivial_constructor<const T>
: has_trivial_constructor<T> { };
template<class T>
struct has_trivial_constructor : is_pod<T>
{};
template<class T, class U>
struct has_trivial_constructor<std::pair<T, U>>
: integral_constant<bool, (has_trivial_constructor<T>::value && has_trivial_constructor<U>::value)>
{};
template<class A, int N>
struct has_trivial_constructor<A[N]> : has_trivial_constructor<A>
{};
template<class T>
struct has_trivial_constructor<const T> : has_trivial_constructor<T>
{};
// We can't get has_trivial_copy right without compiler help, so fail
// conservatively. We will assume it's false except for: (1) types
// for which is_pod is true. (2) std::pair of types with trivial copy
// constructors. (3) array of a type with a trivial copy constructor.
// (4) const versions thereof.
template <class T> struct has_trivial_copy : is_pod<T> { };
template <class T, class U> struct has_trivial_copy<std::pair<T, U> >
: integral_constant<bool,
(has_trivial_copy<T>::value &&
has_trivial_copy<U>::value)> { };
template <class A, int N> struct has_trivial_copy<A[N]>
: has_trivial_copy<A> { };
template <class T> struct has_trivial_copy<const T> : has_trivial_copy<T> { };
template<class T>
struct has_trivial_copy : is_pod<T>
{};
template<class T, class U>
struct has_trivial_copy<std::pair<T, U>>
: integral_constant<bool, (has_trivial_copy<T>::value && has_trivial_copy<U>::value)>
{};
template<class A, int N>
struct has_trivial_copy<A[N]> : has_trivial_copy<A>
{};
template<class T>
struct has_trivial_copy<const T> : has_trivial_copy<T>
{};
// We can't get has_trivial_assign right without compiler help, so fail
// conservatively. We will assume it's false except for: (1) types
// for which is_pod is true. (2) std::pair of types with trivial copy
// constructors. (3) array of a type with a trivial assign constructor.
template <class T> struct has_trivial_assign : is_pod<T> { };
template <class T, class U> struct has_trivial_assign<std::pair<T, U> >
: integral_constant<bool,
(has_trivial_assign<T>::value &&
has_trivial_assign<U>::value)> { };
template <class A, int N> struct has_trivial_assign<A[N]>
: has_trivial_assign<A> { };
template<class T>
struct has_trivial_assign : is_pod<T>
{};
template<class T, class U>
struct has_trivial_assign<std::pair<T, U>>
: integral_constant<bool, (has_trivial_assign<T>::value && has_trivial_assign<U>::value)>
{};
template<class A, int N>
struct has_trivial_assign<A[N]> : has_trivial_assign<A>
{};
// We can't get has_trivial_destructor right without compiler help, so
// fail conservatively. We will assume it's false except for: (1) types
// for which is_pod is true. (2) std::pair of types with trivial
// destructors. (3) array of a type with a trivial destructor.
// (4) const versions thereof.
template <class T> struct has_trivial_destructor : is_pod<T> { };
template <class T, class U> struct has_trivial_destructor<std::pair<T, U> >
: integral_constant<bool,
(has_trivial_destructor<T>::value &&
has_trivial_destructor<U>::value)> { };
template <class A, int N> struct has_trivial_destructor<A[N]>
: has_trivial_destructor<A> { };
template <class T> struct has_trivial_destructor<const T>
: has_trivial_destructor<T> { };
template<class T>
struct has_trivial_destructor : is_pod<T>
{};
template<class T, class U>
struct has_trivial_destructor<std::pair<T, U>>
: integral_constant<bool, (has_trivial_destructor<T>::value && has_trivial_destructor<U>::value)>
{};
template<class A, int N>
struct has_trivial_destructor<A[N]> : has_trivial_destructor<A>
{};
template<class T>
struct has_trivial_destructor<const T> : has_trivial_destructor<T>
{};
// Specified by TR1 [4.7.1]
template<typename T> struct remove_const { typedef T type; };
template<typename T> struct remove_const<T const> { typedef T type; };
template<typename T> struct remove_volatile { typedef T type; };
template<typename T> struct remove_volatile<T volatile> { typedef T type; };
template<typename T> struct remove_cv {
typedef typename remove_const<typename remove_volatile<T>::type>::type type;
template<typename T>
struct remove_const
{
typedef T type;
};
template<typename T>
struct remove_const<T const>
{
typedef T type;
};
template<typename T>
struct remove_volatile
{
typedef T type;
};
template<typename T>
struct remove_volatile<T volatile>
{
typedef T type;
};
template<typename T>
struct remove_cv
{
typedef typename remove_const<typename remove_volatile<T>::type>::type type;
};
// Specified by TR1 [4.7.2] Reference modifications.
template<typename T> struct remove_reference { typedef T type; };
template<typename T> struct remove_reference<T&> { typedef T type; };
template<typename T>
struct remove_reference
{
typedef T type;
};
template<typename T>
struct remove_reference<T&>
{
typedef T type;
};
template <typename T> struct add_reference { typedef T& type; };
template <typename T> struct add_reference<T&> { typedef T& type; };
template<typename T>
struct add_reference
{
typedef T& type;
};
template<typename T>
struct add_reference<T&>
{
typedef T& type;
};
// Specified by TR1 [4.7.4] Pointer modifications.
template<typename T> struct remove_pointer { typedef T type; };
template<typename T> struct remove_pointer<T*> { typedef T type; };
template<typename T> struct remove_pointer<T* const> { typedef T type; };
template<typename T> struct remove_pointer<T* volatile> { typedef T type; };
template<typename T> struct remove_pointer<T* const volatile> {
typedef T type; };
template<typename T>
struct remove_pointer
{
typedef T type;
};
template<typename T>
struct remove_pointer<T*>
{
typedef T type;
};
template<typename T>
struct remove_pointer<T* const>
{
typedef T type;
};
template<typename T>
struct remove_pointer<T* volatile>
{
typedef T type;
};
template<typename T>
struct remove_pointer<T* const volatile>
{
typedef T type;
};
// Specified by TR1 [4.6] Relationships between types
template<typename T, typename U> struct is_same : public false_type { };
template<typename T> struct is_same<T, T> : public true_type { };
template<typename T, typename U>
struct is_same : public false_type
{};
template<typename T>
struct is_same<T, T> : public true_type
{};
// Specified by TR1 [4.6] Relationships between types
#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
@ -309,22 +476,22 @@ namespace internal {
// had called it with an argument of type From. See Alexandrescu's
// _Modern C++ Design_ for more details on this sort of trick.
template <typename From, typename To>
struct ConvertHelper {
static small_ Test(To);
static big_ Test(...);
static From Create();
template<typename From, typename To>
struct ConvertHelper
{
static small_ Test(To);
static big_ Test(...);
static From Create();
};
} // namespace internal
} // namespace internal
// Inherits from true_type if From is convertible to To, false_type otherwise.
template <typename From, typename To>
template<typename From, typename To>
struct is_convertible
: integral_constant<bool,
sizeof(internal::ConvertHelper<From, To>::Test(
internal::ConvertHelper<From, To>::Create()))
== sizeof(small_)> {
};
sizeof(internal::ConvertHelper<From, To>::Test(internal::ConvertHelper<From, To>::Create())) ==
sizeof(small_)>
{};
#endif
_END_GOOGLE_NAMESPACE_
@ -333,10 +500,10 @@ _END_GOOGLE_NAMESPACE_
// these types are PODs, for human use. They may be made more contentful
// later. The typedef is just to make it legal to put a semicolon after
// these macros.
#define DECLARE_POD(TypeName) typedef int Dummy_Type_For_DECLARE_POD
#define DECLARE_POD(TypeName) typedef int Dummy_Type_For_DECLARE_POD
#define DECLARE_NESTED_POD(TypeName) DECLARE_POD(TypeName)
#define PROPAGATE_POD_FROM_TEMPLATE_ARGUMENT(TemplateName) \
#define PROPAGATE_POD_FROM_TEMPLATE_ARGUMENT(TemplateName) \
typedef int Dummy_Type_For_PROPAGATE_POD_FROM_TEMPLATE_ARGUMENT
#define ENFORCE_POD(TypeName) typedef int Dummy_Type_For_ENFORCE_POD
#endif // BASE_TYPE_TRAITS_H_
#endif // BASE_TYPE_TRAITS_H_

View file

@ -118,9 +118,18 @@ using datasource_ptr = std::shared_ptr<datasource>;
#define DATASOURCE_PLUGIN(classname)
#else
#define DATASOURCE_PLUGIN(classname) \
extern "C" MAPNIK_EXP const char* datasource_name() { return classname::name(); } \
extern "C" MAPNIK_EXP datasource* create(parameters const& params) { return new classname(params); } \
extern "C" MAPNIK_EXP void destroy(datasource* ds) { delete ds; }
extern "C" MAPNIK_EXP const char* datasource_name() \
{ \
return classname::name(); \
} \
extern "C" MAPNIK_EXP datasource* create(parameters const& params) \
{ \
return new classname(params); \
} \
extern "C" MAPNIK_EXP void destroy(datasource* ds) \
{ \
delete ds; \
}
#endif
} // namespace mapnik

View file

@ -96,7 +96,10 @@ class MAPNIK_DECL logger : public singleton<logger, CreateStatic>,
}
// format
static std::string const& get_format() { return format_; }
static std::string const& get_format()
{
return format_;
}
static void set_format(std::string const& format)
{
@ -208,7 +211,10 @@ class base_log : public util::noncopyable
private:
#ifdef MAPNIK_LOG
inline bool check_severity() { return Severity >= logger::get_object_severity(object_name_); }
inline bool check_severity()
{
return Severity >= logger::get_object_severity(object_name_);
}
typename output_policy::stream_buffer streambuf_;
std::string object_name_;

View file

@ -152,7 +152,10 @@ class hextree : private util::noncopyable
~hextree() {}
void setMaxColors(unsigned max_colors) { max_colors_ = max_colors; }
void setMaxColors(unsigned max_colors)
{
max_colors_ = max_colors;
}
void setGamma(double g)
{
@ -163,9 +166,15 @@ class hextree : private util::noncopyable
}
}
void setTransMode(unsigned t) { trans_mode_ = t; }
void setTransMode(unsigned t)
{
trans_mode_ = t;
}
transparency_mode_t getTransMode() const { return trans_mode_; }
transparency_mode_t getTransMode() const
{
return trans_mode_;
}
// process alpha value based on trans_mode_
std::uint8_t preprocessAlpha(std::uint8_t a) const

View file

@ -640,7 +640,10 @@ struct offset_converter
return cur_.cmd;
}
void push_vertex(vertex2d const& v) { vertices_.push_back(v); }
void push_vertex(vertex2d const& v)
{
vertices_.push_back(v);
}
Geometry& geom_;
double offset_;

View file

@ -492,8 +492,14 @@ class renderer_agg : util::noncopyable
}
#endif
inline VertexSource& source() const { return source_; }
inline AttributeSource const& attributes() const { return attributes_; }
inline VertexSource& source() const
{
return source_;
}
inline AttributeSource const& attributes() const
{
return attributes_;
}
private:

View file

@ -60,13 +60,25 @@ class file : public util::noncopyable
}
}
inline bool is_open() const { return file_ ? true : false; }
inline bool is_open() const
{
return file_ ? true : false;
}
explicit operator bool() const { return this->is_open(); }
explicit operator bool() const
{
return this->is_open();
}
inline std::FILE* get() const { return file_.get(); }
inline std::FILE* get() const
{
return file_.get();
}
inline std::size_t size() const { return size_; }
inline std::size_t size() const
{
return size_;
}
inline data_type data() const
{

View file

@ -77,7 +77,10 @@ class singleton
singleton(const singleton& rhs);
singleton& operator=(const singleton&);
static void onDeadReference() { throw std::runtime_error("dead reference!"); }
static void onDeadReference()
{
throw std::runtime_error("dead reference!");
}
static void DestroySingleton()
{

View file

@ -61,7 +61,7 @@ if(WIN32)
file(COPY ${m_deps} DESTINATION "@MAPNIK_OUTPUT_DIR@")
]] m_copy_dlls_str @ONLY
)
file (GENERATE OUTPUT "copy_dlls_$<CONFIG>.cmake"
file (GENERATE OUTPUT "copy_dlls_$<CONFIG>.cmake"
CONTENT "${m_copy_dlls_str}"
)
add_custom_target(copy_plugin_dependencies ALL

View file

@ -6,11 +6,11 @@ add_library(input-csv MODULE
csv_utils.cpp
)
target_link_libraries(input-csv PRIVATE
mapnik::mapnik
mapnik::wkt
mapnik::mapnik
mapnik::wkt
mapnik::json
)
set_target_properties(input-csv PROPERTIES
set_target_properties(input-csv PROPERTIES
OUTPUT_NAME "csv"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"

View file

@ -5,11 +5,11 @@ add_library(input-gdal MODULE
gdal_featureset.cpp
)
target_include_directories(input-gdal PRIVATE ${GDAL_INCLUDE_DIRS})
target_link_libraries(input-gdal PRIVATE
target_link_libraries(input-gdal PRIVATE
mapnik::mapnik
${GDAL_LIBRARIES}
)
set_target_properties(input-gdal PROPERTIES
set_target_properties(input-gdal PROPERTIES
OUTPUT_NAME "gdal"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"

View file

@ -3,7 +3,7 @@ add_library(input-geobuf MODULE
geobuf_featureset.cpp
)
target_link_libraries(input-geobuf PRIVATE mapnik::mapnik)
set_target_properties(input-geobuf PROPERTIES
set_target_properties(input-geobuf PROPERTIES
OUTPUT_NAME "geobuf"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"

View file

@ -1,14 +1,14 @@
add_library(input-geojson MODULE
geojson_datasource.cpp
geojson_featureset.cpp
geojson_index_featureset.cpp
add_library(input-geojson MODULE
geojson_datasource.cpp
geojson_featureset.cpp
geojson_index_featureset.cpp
geojson_memory_index_featureset.cpp
)
target_link_libraries(input-geojson PRIVATE
mapnik::mapnik
mapnik::json
)
set_target_properties(input-geojson PROPERTIES
set_target_properties(input-geojson PROPERTIES
OUTPUT_NAME "geojson"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"

View file

@ -1,6 +1,6 @@
find_package(GDAL REQUIRED)
add_library(input-ogr MODULE
add_library(input-ogr MODULE
ogr_converter.cpp
ogr_datasource.cpp
ogr_featureset.cpp
@ -11,7 +11,7 @@ target_link_libraries(input-ogr PRIVATE
mapnik::mapnik
${GDAL_LIBRARIES}
)
set_target_properties(input-ogr PROPERTIES
set_target_properties(input-ogr PROPERTIES
OUTPUT_NAME "ogr"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"

View file

@ -144,11 +144,20 @@ class ogr_layer_ptr
#endif
}
std::string const& layer_name() const { return layer_name_; }
std::string const& layer_name() const
{
return layer_name_;
}
OGRLayer* layer() const { return layer_; }
OGRLayer* layer() const
{
return layer_;
}
bool is_valid() const { return is_valid_; }
bool is_valid() const
{
return is_valid_;
}
private:

View file

@ -1,15 +1,15 @@
find_package(PostgreSQL REQUIRED)
add_library(input-pgraster MODULE
pgraster_datasource.cpp
pgraster_featureset.cpp
add_library(input-pgraster MODULE
pgraster_datasource.cpp
pgraster_featureset.cpp
pgraster_wkb_reader.cpp
)
target_link_libraries(input-pgraster PRIVATE
mapnik::mapnik
mapnik::mapnik
PostgreSQL::PostgreSQL
)
set_target_properties(input-pgraster PROPERTIES
set_target_properties(input-pgraster PROPERTIES
OUTPUT_NAME "pgraster"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"

View file

@ -1,14 +1,14 @@
find_package(PostgreSQL REQUIRED)
add_library(input-postgis MODULE
postgis_datasource.cpp
postgis_featureset.cpp
add_library(input-postgis MODULE
postgis_datasource.cpp
postgis_featureset.cpp
)
target_link_libraries(input-postgis PRIVATE
mapnik::mapnik
mapnik::mapnik
PostgreSQL::PostgreSQL
)
set_target_properties(input-postgis PROPERTIES
set_target_properties(input-postgis PROPERTIES
OUTPUT_NAME "postgis"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"

View file

@ -236,11 +236,20 @@ class Connection
return std::make_shared<ResultSet>(result);
}
std::string client_encoding() const { return PQparameterStatus(conn_, "client_encoding"); }
std::string client_encoding() const
{
return PQparameterStatus(conn_, "client_encoding");
}
bool isOK() const { return (!closed_) && (PQstatus(conn_) != CONNECTION_BAD); }
bool isOK() const
{
return (!closed_) && (PQstatus(conn_) != CONNECTION_BAD);
}
bool isPending() const { return pending_; }
bool isPending() const
{
return pending_;
}
void close()
{

View file

@ -4,7 +4,7 @@ add_library(input-raster MODULE
raster_info.cpp
)
target_link_libraries(input-raster PRIVATE mapnik::mapnik)
set_target_properties(input-raster PROPERTIES
set_target_properties(input-raster PROPERTIES
OUTPUT_NAME "raster"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"

View file

@ -1,5 +1,5 @@
add_library(input-shape MODULE
dbfile.cpp
add_library(input-shape MODULE
dbfile.cpp
dbf_test.cpp
shape_datasource.cpp
shape_featureset.cpp
@ -7,7 +7,7 @@ add_library(input-shape MODULE
shape_io.cpp shape_utils.cpp
)
target_link_libraries(input-shape PRIVATE mapnik::mapnik)
set_target_properties(input-shape PROPERTIES
set_target_properties(input-shape PROPERTIES
OUTPUT_NAME "shape"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"

View file

@ -171,15 +171,30 @@ class shape_file : public mapnik::util::mapped_memory_file
file_.read(reinterpret_cast<char*>(&envelope), sizeof(envelope));
}
inline void rewind() { seek(100); }
inline void rewind()
{
seek(100);
}
inline void seek(std::streampos pos) { file_.seekg(pos, std::ios::beg); }
inline void seek(std::streampos pos)
{
file_.seekg(pos, std::ios::beg);
}
inline std::streampos pos() { return file_.tellg(); }
inline std::streampos pos()
{
return file_.tellg();
}
inline bool is_eof() { return file_.eof(); }
inline bool is_eof()
{
return file_.eof();
}
inline bool is_good() { return file_.good(); }
inline bool is_good()
{
return file_.good();
}
};
#endif // SHAPEFILE_HPP

View file

@ -6,10 +6,10 @@ add_library(input-sqlite MODULE
)
add_library(mapnik::plugin::input::sqlite ALIAS input-sqlite)
target_link_libraries(input-sqlite PRIVATE
mapnik::mapnik
mapnik::mapnik
SQLite::SQLite3
)
set_target_properties(input-sqlite PROPERTIES
set_target_properties(input-sqlite PROPERTIES
OUTPUT_NAME "sqlite"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"

View file

@ -160,7 +160,10 @@ class sqlite_connection
return rc;
}
sqlite3* operator*() { return db_; }
sqlite3* operator*()
{
return db_;
}
bool load_extension(std::string const& ext_path)
{

View file

@ -7,7 +7,7 @@ target_link_libraries(input-topojson PRIVATE
mapnik::mapnik
mapnik::json
)
set_target_properties(input-topojson PROPERTIES
set_target_properties(input-topojson PROPERTIES
OUTPUT_NAME "topojson"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"

View file

@ -11,7 +11,7 @@ endif()
target_link_libraries(mapnik PUBLIC mapnik::core)
target_link_libraries(mapnik PRIVATE mapnik::agg)
set_target_properties(mapnik PROPERTIES
set_target_properties(mapnik PROPERTIES
DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}"
OUTPUT_NAME "mapnik"
PREFIX "lib"
@ -97,7 +97,7 @@ target_sources(mapnik PRIVATE
simplify.cpp
symbolizer_enumerations.cpp
symbolizer_keys.cpp
symbolizer.cpp
symbolizer.cpp
transform_expression_grammar_x3.cpp
transform_expression.cpp
twkb.cpp
@ -110,7 +110,7 @@ target_sources(mapnik PRIVATE
wkb.cpp
xml_tree.cpp
)
target_sources(mapnik PRIVATE
target_sources(mapnik PRIVATE
../deps/agg/src/agg_arc.cpp
../deps/agg/src/agg_arrowhead.cpp
../deps/agg/src/agg_bezier_arc.cpp
@ -154,7 +154,7 @@ target_sources(mapnik PRIVATE
agg/process_text_symbolizer.cpp
)
target_sources(mapnik PRIVATE
target_sources(mapnik PRIVATE
css/css_color_grammar_x3.cpp
css/css_grammar_x3.cpp
)
@ -212,12 +212,12 @@ target_sources(mapnik PRIVATE
text/formatting/list.cpp
text/formatting/registry.cpp
text/formatting/text.cpp
text/placements/base.cpp
text/placements/dummy.cpp
text/placements/list.cpp
text/placements/registry.cpp
text/placements/simple.cpp
text/placements/simple.cpp
)
target_sources(mapnik PRIVATE
@ -264,7 +264,7 @@ endif()
if(USE_GRID_RENDERER)
target_sources(mapnik PRIVATE
grid/grid_renderer.cpp
grid/grid.cpp
grid/grid.cpp
grid/process_building_symbolizer.cpp
grid/process_group_symbolizer.cpp
grid/process_line_pattern_symbolizer.cpp

View file

@ -18,19 +18,19 @@ add_library(mapnik::json ALIAS json)
target_include_directories(json PRIVATE
${JPEG_INCLUDE_DIR}
${LIBXML2_INCLUDE_DIR}
${MAPBOX_POLYLABEL_INCLUDE_DIRS}
${MAPBOX_POLYLABEL_INCLUDE_DIRS}
${MAPBOX_GEOMETRY_INCLUDE_DIRS}
${MAPBOX_VARIANT_INCLUDE_DIRS}
)
target_link_libraries(json PRIVATE mapnik::core ${ICUU_LIB})
set_target_properties(json PROPERTIES
set_target_properties(json PROPERTIES
POSITION_INDEPENDENT_CODE ON
DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}"
OUTPUT_NAME "mapnikjson"
PREFIX "lib"
IMPORT_PREFIX "lib"
VERSION ${MAPNIK_VERSION}
VERSION ${MAPNIK_VERSION}
# see mapnik target for explanation
SOVERSION ${MAPNIK_VERSION}
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"

View file

@ -128,23 +128,25 @@ proj_transform::proj_transform(projection const& source, projection const& dest)
transform_ = proj_create_crs_to_crs(ctx_, source.params().c_str(), dest.params().c_str(), nullptr);
if (transform_ == nullptr)
{
throw std::runtime_error(std::string("Cannot initialize proj_transform (crs_to_crs) for given projections: '") +
source.params() + "'->'" + dest.params() +
throw std::runtime_error(
std::string("Cannot initialize proj_transform (crs_to_crs) for given projections: '") +
source.params() + "'->'" + dest.params() +
#if MAPNIK_PROJ_VERSION >= 80000
"' because of " + std::string(proj_context_errno_string(ctx_, proj_context_errno(ctx_))));
"' because of " + std::string(proj_context_errno_string(ctx_, proj_context_errno(ctx_))));
#else
"'");
"'");
#endif
}
PJ* transform_gis = proj_normalize_for_visualization(ctx_, transform_);
if (transform_gis == nullptr)
{
throw std::runtime_error(std::string("Cannot initialize proj_transform (normalize) for given projections: '") +
source.params() + "'->'" + dest.params() +
throw std::runtime_error(
std::string("Cannot initialize proj_transform (normalize) for given projections: '") +
source.params() + "'->'" + dest.params() +
#if MAPNIK_PROJ_VERSION >= 80000
"' because of " + std::string(proj_context_errno_string(ctx_, proj_context_errno(ctx_))));
"' because of " + std::string(proj_context_errno_string(ctx_, proj_context_errno(ctx_))));
#else
"'");
"'");
#endif
}
proj_destroy(transform_);

View file

@ -96,19 +96,49 @@ class tiff_reader : public image_reader
unsigned width() const final;
unsigned height() const final;
boost::optional<box2d<double>> bounding_box() const final;
inline bool has_alpha() const final { return has_alpha_; }
inline bool has_alpha() const final
{
return has_alpha_;
}
void read(unsigned x, unsigned y, image_rgba8& image) final;
image_any read(unsigned x, unsigned y, unsigned width, unsigned height) final;
// methods specific to tiff reader
unsigned bits_per_sample() const { return bps_; }
unsigned sample_format() const { return sample_format_; }
unsigned photometric() const { return photometric_; }
bool is_tiled() const { return is_tiled_; }
unsigned tile_width() const { return tile_width_; }
unsigned tile_height() const { return tile_height_; }
unsigned rows_per_strip() const { return rows_per_strip_; }
unsigned planar_config() const { return planar_config_; }
unsigned compression() const { return compression_; }
unsigned bits_per_sample() const
{
return bps_;
}
unsigned sample_format() const
{
return sample_format_;
}
unsigned photometric() const
{
return photometric_;
}
bool is_tiled() const
{
return is_tiled_;
}
unsigned tile_width() const
{
return tile_width_;
}
unsigned tile_height() const
{
return tile_height_;
}
unsigned rows_per_strip() const
{
return rows_per_strip_;
}
unsigned planar_config() const
{
return planar_config_;
}
unsigned compression() const
{
return compression_;
}
private:
tiff_reader(const tiff_reader&);

View file

@ -10,19 +10,19 @@ target_include_directories(wkt PRIVATE
${MAPNIK_INCLUDE_PATH}
${JPEG_INCLUDE_DIR}
${LIBXML2_INCLUDE_DIR}
${MAPBOX_POLYLABEL_INCLUDE_DIRS}
${MAPBOX_POLYLABEL_INCLUDE_DIRS}
${MAPBOX_GEOMETRY_INCLUDE_DIRS}
${MAPBOX_VARIANT_INCLUDE_DIRS}
)
target_link_libraries(wkt PRIVATE mapnik::core)
set_target_properties(wkt PROPERTIES
set_target_properties(wkt PROPERTIES
POSITION_INDEPENDENT_CODE ON
DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}"
OUTPUT_NAME "mapnikwkt"
PREFIX "lib"
IMPORT_PREFIX "lib"
VERSION ${MAPNIK_VERSION}
VERSION ${MAPNIK_VERSION}
# see mapnik target for explanation
SOVERSION ${MAPNIK_VERSION}
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"

View file

@ -9,7 +9,7 @@ FetchContent_Declare(
GIT_TAG v2.13.7)
FetchContent_MakeAvailable(Catch2)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19.0")
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19.0")
# for cmake 3.19+ https://cmake.org/cmake/help/git-stage/policy/CMP0110.html
# might not be needed if catch updates its cmakes
cmake_policy(SET CMP0110 OLD)
@ -17,7 +17,7 @@ endif()
add_subdirectory(visual)
add_executable(mapnik-test-unit
add_executable(mapnik-test-unit
unit/run.cpp
unit/color/css_color.cpp
unit/core/box2d_test.cpp
@ -100,13 +100,13 @@ add_executable(mapnik-test-unit
unit/vertex_adapter/transform_path_adapter.cpp
unit/vertex_adapter/vertex_adapter.cpp
)
set_target_properties(mapnik-test-unit PROPERTIES
set_target_properties(mapnik-test-unit PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
target_link_libraries(mapnik-test-unit PUBLIC
Catch2::Catch2
Catch2::Catch2
mapnik::agg
mapnik::mapnik
mapnik::json
@ -119,41 +119,41 @@ file(COPY cleanup.hpp DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
target_include_directories(mapnik-test-unit PRIVATE "${Catch2_SOURCE_DIR}/single_include/catch2" "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
add_executable(agg_rasterizer_integer_overflow_test standalone/agg_rasterizer_integer_overflow_test.cpp)
set_target_properties(agg_rasterizer_integer_overflow_test PROPERTIES
set_target_properties(agg_rasterizer_integer_overflow_test PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
target_link_libraries(agg_rasterizer_integer_overflow_test PUBLIC
Catch2::Catch2
mapnik::mapnik
Catch2::Catch2
mapnik::mapnik
mapnik::agg
mapnik::json
)
target_include_directories(agg_rasterizer_integer_overflow_test PRIVATE "${Catch2_SOURCE_DIR}/single_include/catch2" "${CMAKE_CURRENT_BINARY_DIR}")
add_executable(datasource_registration_test standalone/datasource_registration_test.cpp)
set_target_properties(datasource_registration_test PROPERTIES
set_target_properties(datasource_registration_test PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
target_link_libraries(datasource_registration_test PUBLIC
Catch2::Catch2
mapnik::mapnik
mapnik::mapnik
mapnik::agg
)
target_include_directories(datasource_registration_test PRIVATE "${Catch2_SOURCE_DIR}/single_include/catch2" "${CMAKE_CURRENT_BINARY_DIR}")
add_executable(font_registration_test standalone/font_registration_test.cpp)
set_target_properties(font_registration_test PROPERTIES
set_target_properties(font_registration_test PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
target_link_libraries(font_registration_test PUBLIC
Catch2::Catch2
mapnik::mapnik
Catch2::Catch2
mapnik::mapnik
mapnik::agg
mapnik::json
)
@ -161,14 +161,14 @@ target_include_directories(font_registration_test PRIVATE "${Catch2_SOURCE_DIR}/
#not workable since boost::filesystem native returns a wstring and the function taskes a std::string
add_executable(map_xml_test standalone/map_xml_test.cpp)
set_target_properties(map_xml_test PROPERTIES
set_target_properties(map_xml_test PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
target_link_libraries(map_xml_test PUBLIC
Catch2::Catch2
mapnik::mapnik
Catch2::Catch2
mapnik::mapnik
mapnik::agg
mapnik::json
)
@ -190,8 +190,8 @@ endif()
catch_discover_tests(mapnik-test-unit
WORKING_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
PROPERTIES
ENVIRONMENT
PROPERTIES
ENVIRONMENT
"PATH=${m_test_path}"
)
catch_discover_tests(agg_rasterizer_integer_overflow_test WORKING_DIRECTORY "${MAPNIK_OUTPUT_DIR}")

File diff suppressed because it is too large Load diff

View file

@ -3,20 +3,21 @@
#include "catch.hpp"
#define TRY_CHECK( expr ) \
try { \
CHECK( expr ); \
} \
catch ( Catch::TestFailureException & ) { \
/* thrown by CHECK after it catches and reports */ \
/* an exception from expr => swallow this */ \
#define TRY_CHECK(expr) \
try \
{ \
CHECK(expr); \
} catch (Catch::TestFailureException&) \
{ \
/* thrown by CHECK after it catches and reports */ \
/* an exception from expr => swallow this */ \
}
#define TRY_CHECK_FALSE( expr ) \
try { \
CHECK_FALSE( expr ); \
} \
catch ( Catch::TestFailureException & ) { \
}
#define TRY_CHECK_FALSE(expr) \
try \
{ \
CHECK_FALSE(expr); \
} catch (Catch::TestFailureException&) \
{}
#endif // TEST_CATCH_EXT_HPP

View file

@ -343,7 +343,10 @@ TEST_CASE("postgis")
REQUIRE(ds != nullptr);
auto featureset = all_features(ds);
auto feature = featureset->next();
CHECKED_IF(feature != nullptr) { CHECK(feature->get("email").to_string() == "fake@mail.ru"); }
CHECKED_IF(feature != nullptr)
{
CHECK(feature->get("email").to_string() == "fake@mail.ru");
}
}
SECTION("Postgis interpolates !@uservar! tokens in query")

View file

@ -381,7 +381,10 @@ TEST_CASE("image class")
// swap empty <-> non-empty
CHECK_NOTHROW(im.swap(im3));
CHECK(im3.data() == nullptr);
CHECKED_IF(im.data() != nullptr) { CHECK(im(0, 0) == blue); }
CHECKED_IF(im.data() != nullptr)
{
CHECK(im(0, 0) == blue);
}
}
} // END TEST CASE

View file

@ -167,9 +167,15 @@ void test_tiff_reader(std::string const& pattern)
TEST_CASE("tiff io")
{
SECTION("tiff-reader rgb8+rgba8") { test_tiff_reader<mapnik::image_rgba8>("tiff_rgb"); }
SECTION("tiff-reader rgb8+rgba8")
{
test_tiff_reader<mapnik::image_rgba8>("tiff_rgb");
}
SECTION("tiff-reader gray8") { test_tiff_reader<mapnik::image_gray8>("tiff_gray"); }
SECTION("tiff-reader gray8")
{
test_tiff_reader<mapnik::image_gray8>("tiff_gray");
}
SECTION("scan rgb8 striped")
{

View file

@ -32,23 +32,62 @@
TEST_CASE("saturated cast")
{
SECTION("int8") { CAST_ASSERT(std::int8_t); }
SECTION("int16") { CAST_ASSERT(std::int16_t); }
SECTION("int32") { CAST_ASSERT(std::int32_t); }
SECTION("int8")
{
CAST_ASSERT(std::int8_t);
}
SECTION("int16")
{
CAST_ASSERT(std::int16_t);
}
SECTION("int32")
{
CAST_ASSERT(std::int32_t);
}
SECTION("int64") { CAST_ASSERT2(std::int64_t); }
SECTION("intmax") { CAST_ASSERT2(std::intmax_t); }
SECTION("intptr") { CAST_ASSERT2(std::intptr_t); }
SECTION("int64")
{
CAST_ASSERT2(std::int64_t);
}
SECTION("intmax")
{
CAST_ASSERT2(std::intmax_t);
}
SECTION("intptr")
{
CAST_ASSERT2(std::intptr_t);
}
SECTION("uint8") { CAST_ASSERT(std::uint8_t); }
SECTION("uint16") { CAST_ASSERT(std::uint16_t); }
SECTION("uint32") { CAST_ASSERT(std::uint32_t); }
SECTION("uint8")
{
CAST_ASSERT(std::uint8_t);
}
SECTION("uint16")
{
CAST_ASSERT(std::uint16_t);
}
SECTION("uint32")
{
CAST_ASSERT(std::uint32_t);
}
SECTION("uint64") { CAST_ASSERT3(std::uint64_t); }
SECTION("uintmax") { CAST_ASSERT3(std::uintmax_t); }
SECTION("uintptr") { CAST_ASSERT3(std::uintptr_t); }
SECTION("uint64")
{
CAST_ASSERT3(std::uint64_t);
}
SECTION("uintmax")
{
CAST_ASSERT3(std::uintmax_t);
}
SECTION("uintptr")
{
CAST_ASSERT3(std::uintptr_t);
}
SECTION("float") { CAST_ASSERT4(float); }
SECTION("float")
{
CAST_ASSERT4(float);
}
SECTION("freeform")
{

View file

@ -1,10 +1,10 @@
add_executable(mapnik-test-visual
add_executable(mapnik-test-visual
parse_map_sizes.cpp
report.cpp
runner.cpp
run.cpp
)
set_target_properties(mapnik-test-visual PROPERTIES
set_target_properties(mapnik-test-visual PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"

View file

@ -2,7 +2,7 @@ add_executable(geometry_to_wkb main.cpp)
target_link_libraries(geometry_to_wkb PRIVATE mapnik::mapnik)
set_target_properties(geometry_to_wkb PROPERTIES
set_target_properties(geometry_to_wkb PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
)

View file

@ -13,7 +13,7 @@ target_link_libraries(mapnik-index PRIVATE
Boost::program_options
)
set_target_properties(mapnik-index PROPERTIES
set_target_properties(mapnik-index PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
)

View file

@ -2,12 +2,12 @@ find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options)
add_executable(mapnik-render mapnik-render.cpp)
target_link_libraries(mapnik-render PRIVATE
target_link_libraries(mapnik-render PRIVATE
mapnik::mapnik
Boost::program_options
)
set_target_properties(mapnik-render PROPERTIES
set_target_properties(mapnik-render PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
)

View file

@ -2,7 +2,7 @@ add_executable(ogrindex ogrindex.cpp)
target_link_libraries(ogrindex PRIVATE mapnik::mapnik)
set_target_properties(ogrindex PROPERTIES
set_target_properties(ogrindex PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
)

View file

@ -2,20 +2,20 @@ find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options)
find_package(SQLite3 REQUIRED)
find_package(PostgreSQL REQUIRED)
add_executable(pgsql2sqlite
add_executable(pgsql2sqlite
main.cpp
sqlite.cpp
)
target_include_directories(pgsql2sqlite PRIVATE ../../plugins/input/postgis)
target_link_libraries(pgsql2sqlite PRIVATE
target_link_libraries(pgsql2sqlite PRIVATE
SQLite::SQLite3
PostgreSQL::PostgreSQL
Boost::program_options
mapnik::mapnik
)
set_target_properties(pgsql2sqlite PROPERTIES
set_target_properties(pgsql2sqlite PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
)

View file

@ -1,6 +1,6 @@
find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options)
add_executable(shapeindex
add_executable(shapeindex
shapeindex.cpp
)
@ -10,7 +10,7 @@ target_link_libraries(shapeindex PRIVATE
mapnik::mapnik
)
set_target_properties(shapeindex PROPERTIES
set_target_properties(shapeindex PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
)

View file

@ -1,16 +1,16 @@
find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options)
add_executable(svg2png
add_executable(svg2png
svg2png.cpp
)
target_link_libraries(svg2png PRIVATE
Boost::program_options
target_link_libraries(svg2png PRIVATE
Boost::program_options
mapnik::mapnik
mapnik::agg
)
set_target_properties(svg2png PROPERTIES
set_target_properties(svg2png PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
)