From aa46197d66ce70ece382bf955326c46b13f35864 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Sat, 14 Nov 2020 22:55:31 +0100 Subject: Weed out proj_api.h datatypes and replace them with their proj.h counterparts --- src/ctx.cpp | 55 +++++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) (limited to 'src/ctx.cpp') diff --git a/src/ctx.cpp b/src/ctx.cpp index 6dbe0de5..24d3773b 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -1,6 +1,6 @@ /****************************************************************************** * Project: PROJ.4 - * Purpose: Implementation of the projCtx thread context object. + * Purpose: Implementation of the PJ_CONTEXT thread context object. * Author: Frank Warmerdam, warmerdam@pobox.com * ****************************************************************************** @@ -43,7 +43,7 @@ /* pj_get_ctx() */ /************************************************************************/ -projCtx pj_get_ctx( projPJ pj ) +PJ_CONTEXT* pj_get_ctx( PJ *pj ) { if (nullptr==pj) @@ -59,7 +59,7 @@ projCtx pj_get_ctx( projPJ pj ) /* Note we do not deallocate the old context! */ /************************************************************************/ -void pj_set_ctx( projPJ pj, projCtx ctx ) +void pj_set_ctx( PJ *pj, PJ_CONTEXT *ctx ) { if (pj==nullptr) @@ -86,7 +86,7 @@ void pj_set_ctx( projPJ pj, projCtx ctx ) * the user may want to assign another thread-specific context to the * object. */ -void proj_assign_context( PJ* pj, PJ_CONTEXT* ctx ) +void proj_assign_context( PJ* pj, PJ_CONTEXT *ctx ) { pj_set_ctx( pj, ctx ); } @@ -95,9 +95,9 @@ void proj_assign_context( PJ* pj, PJ_CONTEXT* ctx ) /* createDefault() */ /************************************************************************/ -projCtx_t projCtx_t::createDefault() +pj_ctx pj_ctx::createDefault() { - projCtx_t ctx; + pj_ctx ctx; ctx.debug_level = PJ_LOG_NONE; ctx.logger = pj_stderr_logger; ctx.fileapi_legacy = pj_get_default_fileapi(); @@ -117,7 +117,7 @@ projCtx_t projCtx_t::createDefault() /* get_cpp_context() */ /**************************************************************************/ -projCppContext* projCtx_t::get_cpp_context() +projCppContext* pj_ctx::get_cpp_context() { if (cpp_context == nullptr) { cpp_context = new projCppContext(this); @@ -125,12 +125,11 @@ projCppContext* projCtx_t::get_cpp_context() return cpp_context; } - /**************************************************************************/ /* safeAutoCloseDbIfNeeded() */ /**************************************************************************/ -void projCtx_t::safeAutoCloseDbIfNeeded() +void pj_ctx::safeAutoCloseDbIfNeeded() { if (cpp_context) { cpp_context->autoCloseDbIfNeeded(); @@ -141,7 +140,7 @@ void projCtx_t::safeAutoCloseDbIfNeeded() /* set_search_paths() */ /************************************************************************/ -void projCtx_t::set_search_paths(const std::vector& search_paths_in ) +void pj_ctx::set_search_paths(const std::vector& search_paths_in ) { search_paths = search_paths_in; delete[] c_compat_paths; @@ -158,16 +157,16 @@ void projCtx_t::set_search_paths(const std::vector& search_paths_in /* set_ca_bundle_path() */ /**************************************************************************/ -void projCtx_t::set_ca_bundle_path(const std::string& ca_bundle_path_in) +void pj_ctx::set_ca_bundle_path(const std::string& ca_bundle_path_in) { ca_bundle_path = ca_bundle_path_in; } /************************************************************************/ -/* projCtx_t(const projCtx_t& other) */ +/* pj_ctx(const pj_ctx& other) */ /************************************************************************/ -projCtx_t::projCtx_t(const projCtx_t& other) : +pj_ctx::pj_ctx(const pj_ctx& other) : debug_level(other.debug_level), logger(other.logger), logger_app_data(other.logger_app_data), @@ -197,19 +196,19 @@ projCtx_t::projCtx_t(const projCtx_t& other) : /* pj_get_default_ctx() */ /************************************************************************/ -projCtx pj_get_default_ctx() +PJ_CONTEXT* pj_get_default_ctx() { // C++11 rules guarantee a thread-safe instantiation. - static projCtx_t default_context(projCtx_t::createDefault()); + static pj_ctx default_context(pj_ctx::createDefault()); return &default_context; } /************************************************************************/ -/* ~projCtx_t() */ +/* ~pj_ctx() */ /************************************************************************/ -projCtx_t::~projCtx_t() +pj_ctx::~pj_ctx() { delete[] c_compat_paths; proj_context_delete_cpp_context(cpp_context); @@ -219,10 +218,10 @@ projCtx_t::~projCtx_t() /* pj_ctx_alloc() */ /************************************************************************/ -projCtx pj_ctx_alloc() +PJ_CONTEXT* pj_ctx_alloc() { - return new (std::nothrow) projCtx_t(*pj_get_default_ctx()); + return new (std::nothrow) pj_ctx(*pj_get_default_ctx()); } /************************************************************************/ @@ -230,19 +229,19 @@ projCtx pj_ctx_alloc() /* Create a new context based on a custom context */ /************************************************************************/ -PJ_CONTEXT *proj_context_clone (PJ_CONTEXT *ctx) +PJ_CONTEXT* proj_context_clone (PJ_CONTEXT *ctx) { if (nullptr==ctx) return pj_ctx_alloc (); - return new (std::nothrow) projCtx_t(*ctx); + return new (std::nothrow) pj_ctx(*ctx); } /************************************************************************/ /* pj_ctx_free() */ /************************************************************************/ -void pj_ctx_free( projCtx ctx ) +void pj_ctx_free( PJ_CONTEXT *ctx ) { delete ctx; @@ -252,7 +251,7 @@ void pj_ctx_free( projCtx ctx ) /* pj_ctx_get_errno() */ /************************************************************************/ -int pj_ctx_get_errno( projCtx ctx ) +int pj_ctx_get_errno( PJ_CONTEXT *ctx ) { if (nullptr==ctx) @@ -266,7 +265,7 @@ int pj_ctx_get_errno( projCtx ctx ) /* Also sets the global errno */ /************************************************************************/ -void pj_ctx_set_errno( projCtx ctx, int new_errno ) +void pj_ctx_set_errno( PJ_CONTEXT *ctx, int new_errno ) { ctx->last_errno = new_errno; @@ -280,7 +279,7 @@ void pj_ctx_set_errno( projCtx ctx, int new_errno ) /* pj_ctx_set_debug() */ /************************************************************************/ -void pj_ctx_set_debug( projCtx ctx, int new_debug ) +void pj_ctx_set_debug( PJ_CONTEXT *ctx, int new_debug ) { if (nullptr==ctx) @@ -292,7 +291,7 @@ void pj_ctx_set_debug( projCtx ctx, int new_debug ) /* pj_ctx_set_logger() */ /************************************************************************/ -void pj_ctx_set_logger( projCtx ctx, void (*new_logger)(void*,int,const char*) ) +void pj_ctx_set_logger( PJ_CONTEXT *ctx, void (*new_logger)(void*,int,const char*) ) { if (nullptr==ctx) @@ -304,7 +303,7 @@ void pj_ctx_set_logger( projCtx ctx, void (*new_logger)(void*,int,const char*) ) /* pj_ctx_set_app_data() */ /************************************************************************/ -void pj_ctx_set_app_data( projCtx ctx, void *new_app_data ) +void pj_ctx_set_app_data( PJ_CONTEXT *ctx, void *new_app_data ) { if (nullptr==ctx) @@ -316,7 +315,7 @@ void pj_ctx_set_app_data( projCtx ctx, void *new_app_data ) /* pj_ctx_get_app_data() */ /************************************************************************/ -void *pj_ctx_get_app_data( projCtx ctx ) +void *pj_ctx_get_app_data( PJ_CONTEXT *ctx ) { if (nullptr==ctx) -- cgit v1.2.3 From 7f79fe7325a74d2a9eac93d7081a107ae54bb877 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Mon, 16 Nov 2020 21:10:45 +0100 Subject: Remove legacy file API --- src/ctx.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/ctx.cpp') diff --git a/src/ctx.cpp b/src/ctx.cpp index 24d3773b..d3eee39f 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -100,7 +100,6 @@ pj_ctx pj_ctx::createDefault() pj_ctx ctx; ctx.debug_level = PJ_LOG_NONE; ctx.logger = pj_stderr_logger; - ctx.fileapi_legacy = pj_get_default_fileapi(); NS_PROJ::FileManager::fillDefaultNetworkInterface(&ctx); if( getenv("PROJ_DEBUG") != nullptr ) @@ -170,7 +169,6 @@ pj_ctx::pj_ctx(const pj_ctx& other) : debug_level(other.debug_level), logger(other.logger), logger_app_data(other.logger_app_data), - fileapi_legacy(other.fileapi_legacy), cpp_context(other.cpp_context ? other.cpp_context->clone(this) : nullptr), use_proj4_init_rules(other.use_proj4_init_rules), epsg_file_exists(other.epsg_file_exists), -- cgit v1.2.3 From a74b985b5006c2d279353a245cfcb850cf7fcc94 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Tue, 17 Nov 2020 12:54:24 +0100 Subject: Remove pj_ctx_* functions and use their proj_context counterparts --- src/ctx.cpp | 127 ++++++------------------------------------------------------ 1 file changed, 11 insertions(+), 116 deletions(-) (limited to 'src/ctx.cpp') diff --git a/src/ctx.cpp b/src/ctx.cpp index d3eee39f..8e25db2a 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -54,13 +54,17 @@ PJ_CONTEXT* pj_get_ctx( PJ *pj ) } /************************************************************************/ -/* pj_set_ctx() */ -/* */ -/* Note we do not deallocate the old context! */ +/* proj_assign_context() */ /************************************************************************/ -void pj_set_ctx( PJ *pj, PJ_CONTEXT *ctx ) - +/** \brief Re-assign a context to a PJ* object. + * + * This may be useful if the PJ* has been created with a context that is + * thread-specific, and is later used in another thread. In that case, + * the user may want to assign another thread-specific context to the + * object. + */ +void proj_assign_context( PJ* pj, PJ_CONTEXT *ctx ) { if (pj==nullptr) return; @@ -71,24 +75,9 @@ void pj_set_ctx( PJ *pj, PJ_CONTEXT *ctx ) } for( const auto &alt: pj->alternativeCoordinateOperations ) { - pj_set_ctx(alt.pj, ctx); + proj_assign_context(alt.pj, ctx); } -} -/************************************************************************/ -/* proj_assign_context() */ -/************************************************************************/ - -/** \brief Re-assign a context to a PJ* object. - * - * This may be useful if the PJ* has been created with a context that is - * thread-specific, and is later used in another thread. In that case, - * the user may want to assign another thread-specific context to the - * object. - */ -void proj_assign_context( PJ* pj, PJ_CONTEXT *ctx ) -{ - pj_set_ctx( pj, ctx ); } /************************************************************************/ @@ -212,16 +201,6 @@ pj_ctx::~pj_ctx() proj_context_delete_cpp_context(cpp_context); } -/************************************************************************/ -/* pj_ctx_alloc() */ -/************************************************************************/ - -PJ_CONTEXT* pj_ctx_alloc() - -{ - return new (std::nothrow) pj_ctx(*pj_get_default_ctx()); -} - /************************************************************************/ /* proj_context_clone() */ /* Create a new context based on a custom context */ @@ -230,93 +209,9 @@ PJ_CONTEXT* pj_ctx_alloc() PJ_CONTEXT* proj_context_clone (PJ_CONTEXT *ctx) { if (nullptr==ctx) - return pj_ctx_alloc (); + return proj_context_create(); return new (std::nothrow) pj_ctx(*ctx); } -/************************************************************************/ -/* pj_ctx_free() */ -/************************************************************************/ - -void pj_ctx_free( PJ_CONTEXT *ctx ) - -{ - delete ctx; -} - -/************************************************************************/ -/* pj_ctx_get_errno() */ -/************************************************************************/ - -int pj_ctx_get_errno( PJ_CONTEXT *ctx ) -{ - if (nullptr==ctx) - return pj_get_default_ctx ()->last_errno; - return ctx->last_errno; -} - -/************************************************************************/ -/* pj_ctx_set_errno() */ -/* */ -/* Also sets the global errno */ -/************************************************************************/ - -void pj_ctx_set_errno( PJ_CONTEXT *ctx, int new_errno ) - -{ - ctx->last_errno = new_errno; - if( new_errno == 0 ) - return; - errno = new_errno; - pj_errno = new_errno; -} - -/************************************************************************/ -/* pj_ctx_set_debug() */ -/************************************************************************/ - -void pj_ctx_set_debug( PJ_CONTEXT *ctx, int new_debug ) - -{ - if (nullptr==ctx) - return; - ctx->debug_level = new_debug; -} - -/************************************************************************/ -/* pj_ctx_set_logger() */ -/************************************************************************/ - -void pj_ctx_set_logger( PJ_CONTEXT *ctx, void (*new_logger)(void*,int,const char*) ) - -{ - if (nullptr==ctx) - return; - ctx->logger = new_logger; -} - -/************************************************************************/ -/* pj_ctx_set_app_data() */ -/************************************************************************/ - -void pj_ctx_set_app_data( PJ_CONTEXT *ctx, void *new_app_data ) - -{ - if (nullptr==ctx) - return; - ctx->logger_app_data = new_app_data; -} - -/************************************************************************/ -/* pj_ctx_get_app_data() */ -/************************************************************************/ - -void *pj_ctx_get_app_data( PJ_CONTEXT *ctx ) - -{ - if (nullptr==ctx) - return nullptr; - return ctx->logger_app_data; -} -- cgit v1.2.3 From ddb3b8da0756acbb8713aeb452de209eb350e996 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Wed, 18 Nov 2020 09:32:45 +0100 Subject: Removed unused function pj_set_searchpath() and pj_set_finder() --- src/ctx.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/ctx.cpp') diff --git a/src/ctx.cpp b/src/ctx.cpp index 8e25db2a..2093950b 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -163,7 +163,6 @@ pj_ctx::pj_ctx(const pj_ctx& other) : epsg_file_exists(other.epsg_file_exists), ca_bundle_path(other.ca_bundle_path), env_var_proj_lib(other.env_var_proj_lib), - file_finder_legacy(other.file_finder_legacy), file_finder(other.file_finder), file_finder_user_data(other.file_finder_user_data), custom_sqlite3_vfs_name(other.custom_sqlite3_vfs_name), -- cgit v1.2.3