From 23918e80c7991fb61fc1ccb278444d892a54c3e4 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Tue, 5 Nov 2024 14:55:42 +0100 Subject: [PATCH] Rename project back to sharedlibpp (#12) * Rename project back to sharedlibpp --- CMakeLists.txt | 10 +-- README.md | 8 +-- examples/CMakeLists.txt | 8 +-- examples/MyMath.cpp | 2 +- examples/MyMathCustom.cpp | 2 +- examples/math_test.cpp | 8 +-- examples/math_test_custom.cpp | 8 +-- pixi.toml | 2 +- src/CMakeLists.txt | 58 ++++++++--------- src/SharedLibrary.cpp | 4 +- src/SharedLibraryFactory.cpp | 62 +++++++++---------- src/{shlibpp => sharedlibpp}/SharedLibrary.h | 6 +- .../SharedLibraryClass-inl.h | 24 +++---- .../SharedLibraryClass.h | 8 +-- .../SharedLibraryClassApi.h | 14 ++--- .../SharedLibraryClassFactory-inl.h | 10 +-- .../SharedLibraryClassFactory.h | 10 +-- .../SharedLibraryFactory.h | 6 +- src/{shlibpp => sharedlibpp}/api.h | 0 src/{shlibpp => sharedlibpp}/config.h.in | 0 src/{shlibpp => sharedlibpp}/version.h.in | 14 ++--- src/version.cpp | 10 +-- 22 files changed, 137 insertions(+), 137 deletions(-) rename src/{shlibpp => sharedlibpp}/SharedLibrary.h (96%) rename src/{shlibpp => sharedlibpp}/SharedLibraryClass-inl.h (63%) rename src/{shlibpp => sharedlibpp}/SharedLibraryClass.h (95%) rename src/{shlibpp => sharedlibpp}/SharedLibraryClassApi.h (95%) rename src/{shlibpp => sharedlibpp}/SharedLibraryClassFactory-inl.h (80%) rename src/{shlibpp => sharedlibpp}/SharedLibraryClassFactory.h (89%) rename src/{shlibpp => sharedlibpp}/SharedLibraryFactory.h (99%) rename src/{shlibpp => sharedlibpp}/api.h (100%) rename src/{shlibpp => sharedlibpp}/config.h.in (100%) rename src/{shlibpp => sharedlibpp}/version.h.in (62%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5730fc9..d4985c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,8 +6,8 @@ cmake_minimum_required(VERSION 3.5) -project(shlibpp - VERSION 0.0.2 +project(sharedlibpp + VERSION 0.0.3 DESCRIPTION "Tiny cross-platform plug-in system (dll, so, dylib)" LANGUAGES CXX) @@ -62,10 +62,10 @@ add_subdirectory(src) # Install CMake config files for the library include(InstallBasicPackageFiles) -install_basic_package_files(shlibpp - VERSION ${shlibpp_VERSION} +install_basic_package_files(sharedlibpp + VERSION ${sharedlibpp_VERSION} COMPATIBILITY AnyNewerVersion - EXPORT shlibpp + EXPORT sharedlibpp NO_CHECK_REQUIRED_COMPONENTS_MACRO) # Add uninstall target diff --git a/README.md b/README.md index bbf612c..1e4dee7 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ Simple cross platform plug-in system ==================================== -`shlibpp` is a tiny cross-platform library to create and load shared -libraries for different platform (Linux/Mac/Windows). `shlibpp` provides +`sharedlibpp` is a tiny cross-platform library to create and load shared +libraries for different platform (Linux/Mac/Windows). `sharedlibpp` provides an easy and portable way to create plug-ins which encapsulate your c++ classes inside a shared library (so, dylib, dll). The original code is taken and from @@ -13,7 +13,7 @@ added to report the native OS error messages on failures. Building on Linux/Mac --------------------- - $ cd shlibpp + $ cd sharedlibpp $ cmake -Bbuild -S. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./install $ cmake --build . --config Release $ cmake --install . @@ -25,7 +25,7 @@ The build system by default compiles and build the examples. * On Linux/Mac ``` - $ cd shlibpp/build/examples + $ cd sharedlibpp/build/examples $ ./math_test mymath $ ./math_test_custom mymathcustom ``` diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 3e79ad1..5413520 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -5,13 +5,13 @@ # BSD-3-Clause license. See the accompanying LICENSE file for details. add_library(mymath MODULE MyMath.cpp MyMath.h) -target_include_directories(mymath PRIVATE $) +target_include_directories(mymath PRIVATE $) add_executable(math_test math_test.cpp) -target_link_libraries(math_test PRIVATE shlibpp::shlibpp) +target_link_libraries(math_test PRIVATE sharedlibpp::sharedlibpp) add_library(mymathcustom MODULE MyMathCustom.cpp MyMathCustom.h) -target_include_directories(mymathcustom PRIVATE $) +target_include_directories(mymathcustom PRIVATE $) add_executable(math_test_custom math_test_custom.cpp) -target_link_libraries(math_test_custom PRIVATE shlibpp::shlibpp) +target_link_libraries(math_test_custom PRIVATE sharedlibpp::sharedlibpp) diff --git a/examples/MyMath.cpp b/examples/MyMath.cpp index 8a6c99b..6c46654 100644 --- a/examples/MyMath.cpp +++ b/examples/MyMath.cpp @@ -7,7 +7,7 @@ */ #include "MyMath.h" -#include +#include SHLIBPP_DEFINE_SHARED_SUBCLASS(my_math, MyMathImpl, MyMath); diff --git a/examples/MyMathCustom.cpp b/examples/MyMathCustom.cpp index 9dd4b42..c2c8444 100644 --- a/examples/MyMathCustom.cpp +++ b/examples/MyMathCustom.cpp @@ -7,7 +7,7 @@ */ #include "MyMathCustom.h" -#include +#include SHLIBPP_DEFINE_SHARED_SUBCLASS_CUSTOM(CUSTOM_START_CHECK, CUSTOM_END_CHECK, CUSTOM_SYSTEM_VERSION, my_math_custom, MyMathCustomImpl, MyMathCustom); diff --git a/examples/math_test.cpp b/examples/math_test.cpp index 1e93102..62fa454 100644 --- a/examples/math_test.cpp +++ b/examples/math_test.cpp @@ -9,8 +9,8 @@ #include #include "MyMath.h" -#include -#include +#include +#include int main(int argc, char *argv[]) @@ -24,7 +24,7 @@ int main(int argc, char *argv[]) // create an instance of shared library class factory to load the library printf("Loading the shared library... \n"); - shlibpp::SharedLibraryClassFactory myMathFactory(argv[1], "my_math"); + sharedlibpp::SharedLibraryClassFactory myMathFactory(argv[1], "my_math"); if (!myMathFactory.isValid()) { printf("error (%d) : %s\n", static_cast(myMathFactory.getStatus()), myMathFactory.getError().c_str()); @@ -32,7 +32,7 @@ int main(int argc, char *argv[]) } // create an instance of the class and call its functions - shlibpp::SharedLibraryClass myMath(myMathFactory); + sharedlibpp::SharedLibraryClass myMath(myMathFactory); printf("Calling some of its functions... \n"); printf("15 + 12 = %d\n", myMath->add(15, 12)); printf("15 - 12 = %d\n", myMath->sub(15, 12)); diff --git a/examples/math_test_custom.cpp b/examples/math_test_custom.cpp index f91a40a..286317b 100644 --- a/examples/math_test_custom.cpp +++ b/examples/math_test_custom.cpp @@ -9,8 +9,8 @@ #include #include "MyMathCustom.h" -#include -#include +#include +#include int main(int argc, char *argv[]) @@ -24,7 +24,7 @@ int main(int argc, char *argv[]) // create an instance of shared library class factory to load the library printf("Loading the shared library... \n"); - shlibpp::SharedLibraryClassFactory myMathFactory(argv[1], + sharedlibpp::SharedLibraryClassFactory myMathFactory(argv[1], CUSTOM_START_CHECK, CUSTOM_END_CHECK, CUSTOM_SYSTEM_VERSION, @@ -36,7 +36,7 @@ int main(int argc, char *argv[]) } // create an instance of the class and call its functions - shlibpp::SharedLibraryClass myMath(myMathFactory); + sharedlibpp::SharedLibraryClass myMath(myMathFactory); printf("Calling some of its functions... \n"); printf("15 + 12 = %d\n", myMath->add(15, 12)); printf("15 - 12 = %d\n", myMath->sub(15, 12)); diff --git a/pixi.toml b/pixi.toml index f99c665..8a32ebf 100644 --- a/pixi.toml +++ b/pixi.toml @@ -1,5 +1,5 @@ [project] -name = "shlibpp" +name = "sharedlibpp" # As this version is currently ignored, we do not # waste effort in mantain it in synch with the value # specified in CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e96cedb..9dafb85 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,39 +6,39 @@ include (GNUInstallDirs) -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/shlibpp/config.h.in" - "${CMAKE_CURRENT_BINARY_DIR}/shlibpp/config.h" +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/sharedlibpp/config.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/sharedlibpp/config.h" @ONLY) -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/shlibpp/version.h.in" - "${CMAKE_CURRENT_BINARY_DIR}/shlibpp/version.h" +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/sharedlibpp/version.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/sharedlibpp/version.h" @ONLY) -set(shlibpp_HDRS "${CMAKE_CURRENT_BINARY_DIR}/shlibpp/config.h" - "${CMAKE_CURRENT_BINARY_DIR}/shlibpp/version.h" - shlibpp/api.h - shlibpp/SharedLibraryClassApi.h - shlibpp/SharedLibraryClassFactory.h - shlibpp/SharedLibraryClassFactory-inl.h - shlibpp/SharedLibraryClass.h - shlibpp/SharedLibraryClass-inl.h - shlibpp/SharedLibraryFactory.h - shlibpp/SharedLibrary.h) +set(sharedlibpp_HDRS "${CMAKE_CURRENT_BINARY_DIR}/sharedlibpp/config.h" + "${CMAKE_CURRENT_BINARY_DIR}/sharedlibpp/version.h" + sharedlibpp/api.h + sharedlibpp/SharedLibraryClassApi.h + sharedlibpp/SharedLibraryClassFactory.h + sharedlibpp/SharedLibraryClassFactory-inl.h + sharedlibpp/SharedLibraryClass.h + sharedlibpp/SharedLibraryClass-inl.h + sharedlibpp/SharedLibraryFactory.h + sharedlibpp/SharedLibrary.h) -set(shlibpp_SRCS version.cpp +set(sharedlibpp_SRCS version.cpp SharedLibrary.cpp SharedLibraryFactory.cpp) -add_library(shlibpp ${shlibpp_SRCS} ${shlibpp_HDRS}) -add_library(shlibpp::shlibpp ALIAS shlibpp) +add_library(sharedlibpp ${sharedlibpp_SRCS} ${sharedlibpp_HDRS}) +add_library(sharedlibpp::sharedlibpp ALIAS sharedlibpp) # Add build definitions if(NOT BUILD_SHARED_LIBS) target_compile_definitions(shlibpp PRIVATE SHLIBPP_STATIC) endif() -set_target_properties(shlibpp PROPERTIES DEFINE_SYMBOL BUILDING_SHLIBPP) +set_target_properties(sharedlibpp PROPERTIES DEFINE_SYMBOL BUILDING_SHLIBPP) -target_include_directories(shlibpp PUBLIC $ +target_include_directories(sharedlibpp PUBLIC $ $ $) @@ -47,24 +47,24 @@ if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 3.8) endif() if(CMAKE_VERSION VERSION_LESS 3.8) # Should be enough to enable c++11 - target_compile_features(shlibpp PUBLIC cxx_constexpr + target_compile_features(sharedlibpp PUBLIC cxx_constexpr cxx_nullptr) else() - target_compile_features(shlibpp PUBLIC cxx_std_11) + target_compile_features(sharedlibpp PUBLIC cxx_std_11) endif() if(UNIX) - target_link_libraries(shlibpp PRIVATE dl) + target_link_libraries(sharedlibpp PRIVATE dl) endif() -set_property(TARGET shlibpp PROPERTY PUBLIC_HEADER ${shlibpp_HDRS}) -set_property(TARGET shlibpp PROPERTY VERSION ${shlibpp_VERSION}) -set_property(TARGET shlibpp PROPERTY SOVERSION 1) +set_property(TARGET sharedlibpp PROPERTY PUBLIC_HEADER ${sharedlibpp_HDRS}) +set_property(TARGET sharedlibpp PROPERTY VERSION ${sharedlibpp_VERSION}) +set_property(TARGET sharedlibpp PROPERTY SOVERSION 1) -install(TARGETS shlibpp - EXPORT shlibpp - COMPONENT shlibpp +install(TARGETS sharedlibpp + EXPORT sharedlibpp + COMPONENT sharedlibpp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/shlibpp) + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sharedlibpp) diff --git a/src/SharedLibrary.cpp b/src/SharedLibrary.cpp index 8bd14f9..9b18e2a 100644 --- a/src/SharedLibrary.cpp +++ b/src/SharedLibrary.cpp @@ -14,9 +14,9 @@ # include #endif -#include +#include -using namespace shlibpp; +using namespace sharedlibpp; class SharedLibrary::Private diff --git a/src/SharedLibraryFactory.cpp b/src/SharedLibraryFactory.cpp index 995571b..8e847e3 100644 --- a/src/SharedLibraryFactory.cpp +++ b/src/SharedLibraryFactory.cpp @@ -6,9 +6,9 @@ * BSD-3-Clause license. See the accompanying LICENSE file for details. */ -#include -#include -#include +#include +#include +#include #include #include @@ -31,7 +31,7 @@ #define PATH_SEPARATOR "/" #endif -class shlibpp::SharedLibraryFactory::Private +class sharedlibpp::SharedLibraryFactory::Private { public: Private(int32_t startCheck, @@ -69,7 +69,7 @@ class shlibpp::SharedLibraryFactory::Private -shlibpp::SharedLibraryFactory::Private::Private(int32_t startCheck, +sharedlibpp::SharedLibraryFactory::Private::Private(int32_t startCheck, int32_t endCheck, int32_t systemVersion, const char* factoryName) : @@ -84,7 +84,7 @@ shlibpp::SharedLibraryFactory::Private::Private(int32_t startCheck, memset(&api, 0, sizeof(SharedLibraryClassApi)); } -std::vector shlibpp::SharedLibraryFactory::Private::platformSpecificLibName(const std::string& library) +std::vector sharedlibpp::SharedLibraryFactory::Private::platformSpecificLibName(const std::string& library) { #if defined(_WIN32) @@ -102,7 +102,7 @@ std::vector shlibpp::SharedLibraryFactory::Private::platformSpecifi #endif } -std::string shlibpp::SharedLibraryFactory::Private::findLibraryInExtendedPath(const std::string& libraryName) +std::string sharedlibpp::SharedLibraryFactory::Private::findLibraryInExtendedPath(const std::string& libraryName) { std::size_t found = libraryName.find_first_of("\\/"); if (found != std::string::npos) { @@ -122,7 +122,7 @@ std::string shlibpp::SharedLibraryFactory::Private::findLibraryInExtendedPath(co return {}; } -bool shlibpp::SharedLibraryFactory::Private::open(const char* dll_name) +bool sharedlibpp::SharedLibraryFactory::Private::open(const char* dll_name) { returnValue = 0; name = ""; @@ -173,7 +173,7 @@ bool shlibpp::SharedLibraryFactory::Private::open(const char* dll_name) return true; } -bool shlibpp::SharedLibraryFactory::Private::isValid() const +bool sharedlibpp::SharedLibraryFactory::Private::isValid() const { if (returnValue != startCheck) { return false; @@ -193,7 +193,7 @@ bool shlibpp::SharedLibraryFactory::Private::isValid() const return true; } -bool shlibpp::SharedLibraryFactory::Private::useFactoryFunction(void *factory) +bool sharedlibpp::SharedLibraryFactory::Private::useFactoryFunction(void *factory) { api.startCheck = 0; if (factory == nullptr) { @@ -204,7 +204,7 @@ bool shlibpp::SharedLibraryFactory::Private::useFactoryFunction(void *factory) return isValid(); } -void shlibpp::SharedLibraryFactory::Private::extendSearchPath(const std::string& path) +void sharedlibpp::SharedLibraryFactory::Private::extendSearchPath(const std::string& path) { std::string pathToAdd = path; @@ -221,7 +221,7 @@ void shlibpp::SharedLibraryFactory::Private::extendSearchPath(const std::string& extendedPath.push_back(pathToAdd); } -void shlibpp::SharedLibraryFactory::Private::readExtendedPathFromEnvironment() +void sharedlibpp::SharedLibraryFactory::Private::readExtendedPathFromEnvironment() { std::string path; auto content = std::getenv(pluginPathEnvVar.c_str()); @@ -243,7 +243,7 @@ void shlibpp::SharedLibraryFactory::Private::readExtendedPathFromEnvironment() } } -shlibpp::SharedLibraryFactory::SharedLibraryFactory(int32_t startCheck, +sharedlibpp::SharedLibraryFactory::SharedLibraryFactory(int32_t startCheck, int32_t endCheck, int32_t systemVersion, const char *factoryName) : @@ -251,7 +251,7 @@ shlibpp::SharedLibraryFactory::SharedLibraryFactory(int32_t startCheck, { } -shlibpp::SharedLibraryFactory::SharedLibraryFactory(const char *dll_name, +sharedlibpp::SharedLibraryFactory::SharedLibraryFactory(const char *dll_name, int32_t startCheck, int32_t endCheck, int32_t systemVersion, @@ -261,7 +261,7 @@ shlibpp::SharedLibraryFactory::SharedLibraryFactory(const char *dll_name, mPriv->open(dll_name); } -shlibpp::SharedLibraryFactory::SharedLibraryFactory(const char* dll_name, +sharedlibpp::SharedLibraryFactory::SharedLibraryFactory(const char* dll_name, const char* factoryName) : SharedLibraryFactory(SHLIBPP_DEFAULT_START_CHECK, SHLIBPP_DEFAULT_END_CHECK, @@ -271,12 +271,12 @@ shlibpp::SharedLibraryFactory::SharedLibraryFactory(const char* dll_name, mPriv->open(dll_name); } -shlibpp::SharedLibraryFactory::~SharedLibraryFactory() +sharedlibpp::SharedLibraryFactory::~SharedLibraryFactory() { delete mPriv; } -bool shlibpp::SharedLibraryFactory::open(const char *dll_name, +bool sharedlibpp::SharedLibraryFactory::open(const char *dll_name, int32_t startCheck, int32_t endCheck, int32_t systemVersion, @@ -289,7 +289,7 @@ bool shlibpp::SharedLibraryFactory::open(const char *dll_name, return mPriv->open(dll_name); } -bool shlibpp::SharedLibraryFactory::open(const char* dll_name, const char* factoryName) +bool sharedlibpp::SharedLibraryFactory::open(const char* dll_name, const char* factoryName) { mPriv->startCheck = SHLIBPP_DEFAULT_START_CHECK; mPriv->endCheck = SHLIBPP_DEFAULT_END_CHECK; @@ -298,69 +298,69 @@ bool shlibpp::SharedLibraryFactory::open(const char* dll_name, const char* facto return mPriv->open(dll_name); } -void shlibpp::SharedLibraryFactory::setPluginPathEnvVarName(const std::string &env_var) +void sharedlibpp::SharedLibraryFactory::setPluginPathEnvVarName(const std::string &env_var) { mPriv->pluginPathEnvVar = env_var; } -void shlibpp::SharedLibraryFactory::extendSearchPath(const std::string& path) +void sharedlibpp::SharedLibraryFactory::extendSearchPath(const std::string& path) { mPriv->extendSearchPath(path); } -bool shlibpp::SharedLibraryFactory::isValid() const +bool sharedlibpp::SharedLibraryFactory::isValid() const { return mPriv->isValid(); } -shlibpp::SharedLibraryFactory::Status shlibpp::SharedLibraryFactory::getStatus() const +sharedlibpp::SharedLibraryFactory::Status sharedlibpp::SharedLibraryFactory::getStatus() const { return mPriv->status; } -std::string shlibpp::SharedLibraryFactory::getError() const +std::string sharedlibpp::SharedLibraryFactory::getError() const { return mPriv->error; } -const shlibpp::SharedLibraryClassApi& shlibpp::SharedLibraryFactory::getApi() const +const sharedlibpp::SharedLibraryClassApi& sharedlibpp::SharedLibraryFactory::getApi() const { return mPriv->api; } -int shlibpp::SharedLibraryFactory::getReferenceCount() const +int sharedlibpp::SharedLibraryFactory::getReferenceCount() const { return mPriv->rct; } -int shlibpp::SharedLibraryFactory::addRef() +int sharedlibpp::SharedLibraryFactory::addRef() { mPriv->rct++; return mPriv->rct; } -int shlibpp::SharedLibraryFactory::removeRef() +int sharedlibpp::SharedLibraryFactory::removeRef() { mPriv->rct--; return mPriv->rct; } -std::string shlibpp::SharedLibraryFactory::getName() const +std::string sharedlibpp::SharedLibraryFactory::getName() const { return mPriv->name; } -std::string shlibpp::SharedLibraryFactory::getClassName() const +std::string sharedlibpp::SharedLibraryFactory::getClassName() const { return mPriv->className; } -std::string shlibpp::SharedLibraryFactory::getBaseClassName() const +std::string sharedlibpp::SharedLibraryFactory::getBaseClassName() const { return mPriv->baseClassName; } -bool shlibpp::SharedLibraryFactory::useFactoryFunction(void *factory) +bool sharedlibpp::SharedLibraryFactory::useFactoryFunction(void *factory) { return mPriv->useFactoryFunction(factory); } diff --git a/src/shlibpp/SharedLibrary.h b/src/sharedlibpp/SharedLibrary.h similarity index 96% rename from src/shlibpp/SharedLibrary.h rename to src/sharedlibpp/SharedLibrary.h index a044e14..93d5063 100644 --- a/src/shlibpp/SharedLibrary.h +++ b/src/sharedlibpp/SharedLibrary.h @@ -9,10 +9,10 @@ #ifndef SHAREDLIBPP_SHAREDLIBRARY_H #define SHAREDLIBPP_SHAREDLIBRARY_H -#include +#include #include -namespace shlibpp { +namespace sharedlibpp { /** * Low-level wrapper for loading shared libraries (DLLs) and accessing @@ -87,6 +87,6 @@ class SHLIBPP_API SharedLibrary #endif }; -} // namespace shlibpp +} // namespace sharedlibpp #endif // SHAREDLIBPP_SHAREDLIBRARY_H diff --git a/src/shlibpp/SharedLibraryClass-inl.h b/src/sharedlibpp/SharedLibraryClass-inl.h similarity index 63% rename from src/shlibpp/SharedLibraryClass-inl.h rename to src/sharedlibpp/SharedLibraryClass-inl.h index 33ab54f..0743f35 100644 --- a/src/shlibpp/SharedLibraryClass-inl.h +++ b/src/sharedlibpp/SharedLibraryClass-inl.h @@ -11,27 +11,27 @@ template -shlibpp::SharedLibraryClass::SharedLibraryClass() : +sharedlibpp::SharedLibraryClass::SharedLibraryClass() : content(nullptr), pfactory(nullptr) { } template -shlibpp::SharedLibraryClass::SharedLibraryClass(SharedLibraryClassFactory& factory) : +sharedlibpp::SharedLibraryClass::SharedLibraryClass(SharedLibraryClassFactory& factory) : SharedLibraryClass() { open(factory); } template -shlibpp::SharedLibraryClass::~SharedLibraryClass() +sharedlibpp::SharedLibraryClass::~SharedLibraryClass() { close(); } template -bool shlibpp::SharedLibraryClass::open(SharedLibraryClassFactory& factory) +bool sharedlibpp::SharedLibraryClass::open(SharedLibraryClassFactory& factory) { close(); content = factory.create(); @@ -42,7 +42,7 @@ bool shlibpp::SharedLibraryClass::open(SharedLibraryClassFactory& factory) } template -bool shlibpp::SharedLibraryClass::close() +bool sharedlibpp::SharedLibraryClass::close() { if (content != nullptr) { pfactory->destroy(content); @@ -58,46 +58,46 @@ bool shlibpp::SharedLibraryClass::close() } template -T& shlibpp::SharedLibraryClass::getContent() +T& sharedlibpp::SharedLibraryClass::getContent() { return *content; } template -const T& shlibpp::SharedLibraryClass::getContent() const +const T& sharedlibpp::SharedLibraryClass::getContent() const { return *content; } template -bool shlibpp::SharedLibraryClass::isValid() const +bool sharedlibpp::SharedLibraryClass::isValid() const { return content != nullptr; } template -T& shlibpp::SharedLibraryClass::operator*() +T& sharedlibpp::SharedLibraryClass::operator*() { return (*content); } template -const T& shlibpp::SharedLibraryClass::operator*() const +const T& sharedlibpp::SharedLibraryClass::operator*() const { return (*content); } template -T* shlibpp::SharedLibraryClass::operator->() +T* sharedlibpp::SharedLibraryClass::operator->() { return (content); } template -const T* shlibpp::SharedLibraryClass::operator->() const +const T* sharedlibpp::SharedLibraryClass::operator->() const { return (content); } diff --git a/src/shlibpp/SharedLibraryClass.h b/src/sharedlibpp/SharedLibraryClass.h similarity index 95% rename from src/shlibpp/SharedLibraryClass.h rename to src/sharedlibpp/SharedLibraryClass.h index 6a5ffe4..7bc4c9f 100644 --- a/src/shlibpp/SharedLibraryClass.h +++ b/src/sharedlibpp/SharedLibraryClass.h @@ -9,9 +9,9 @@ #ifndef SHAREDLIBPP_SHAREDLIBRARYCLASS_H #define SHAREDLIBPP_SHAREDLIBRARYCLASS_H -#include +#include -namespace shlibpp { +namespace sharedlibpp { /** * Container for an object created using a factory provided by a shared library. @@ -120,9 +120,9 @@ class SharedLibraryClass #endif }; -} // namespace shlibpp +} // namespace sharedlibpp -#include +#include #endif // SHAREDLIBPP_SHAREDLIBRARYCLASS_H diff --git a/src/shlibpp/SharedLibraryClassApi.h b/src/sharedlibpp/SharedLibraryClassApi.h similarity index 95% rename from src/shlibpp/SharedLibraryClassApi.h rename to src/sharedlibpp/SharedLibraryClassApi.h index 823961e..4618f69 100644 --- a/src/shlibpp/SharedLibraryClassApi.h +++ b/src/sharedlibpp/SharedLibraryClassApi.h @@ -9,11 +9,11 @@ #ifndef SHAREDLIBPP_SHAREDLIBRARYCLASSAPI_H #define SHAREDLIBPP_SHAREDLIBRARYCLASSAPI_H -#include -#include +#include +#include #include -namespace shlibpp { +namespace sharedlibpp { // Be careful loading C++ classes from DLLs. Generally you // need an exact or very close match between compilers used @@ -55,7 +55,7 @@ extern "C" { } // extern "C" -} // namespace shlibpp +} // namespace sharedlibpp #define SHLIBPP_SHARED_CLASS_FN extern "C" SHLIBPP_EXPORT @@ -138,12 +138,12 @@ constexpr int32_t SHLIBPP_DEFAULT_SYSTEM_VERSION = 5; } \ \ SHLIBPP_SHARED_CLASS_FN int32_t factoryname(void* api, size_t len) { \ - struct shlibpp::SharedLibraryClassApi* sapi = static_cast(api); \ - if (len < sizeof(shlibpp::SharedLibraryClassApi)) { \ + struct sharedlibpp::SharedLibraryClassApi* sapi = static_cast(api); \ + if (len < sizeof(sharedlibpp::SharedLibraryClassApi)) { \ return -1; \ } \ sapi->startCheck = startcheck; \ - sapi->structureSize = sizeof(shlibpp::SharedLibraryClassApi); \ + sapi->structureSize = sizeof(sharedlibpp::SharedLibraryClassApi); \ sapi->systemVersion = systemversion; \ sapi->create = factoryname ## _create; \ sapi->destroy = factoryname ## _destroy; \ diff --git a/src/shlibpp/SharedLibraryClassFactory-inl.h b/src/sharedlibpp/SharedLibraryClassFactory-inl.h similarity index 80% rename from src/shlibpp/SharedLibraryClassFactory-inl.h rename to src/sharedlibpp/SharedLibraryClassFactory-inl.h index f126f05..13dde2d 100644 --- a/src/shlibpp/SharedLibraryClassFactory-inl.h +++ b/src/sharedlibpp/SharedLibraryClassFactory-inl.h @@ -10,7 +10,7 @@ #define SHAREDLIBPP_SHAREDLIBRARYCLASSFACTORY_INL_H template -shlibpp::SharedLibraryClassFactory::SharedLibraryClassFactory(int32_t startCheck, +sharedlibpp::SharedLibraryClassFactory::SharedLibraryClassFactory(int32_t startCheck, int32_t endCheck, int32_t systemVersion, const char *factoryName) : @@ -19,7 +19,7 @@ shlibpp::SharedLibraryClassFactory::SharedLibraryClassFactory(int32_t startCh } template -shlibpp::SharedLibraryClassFactory::SharedLibraryClassFactory(const char *dll_name, +sharedlibpp::SharedLibraryClassFactory::SharedLibraryClassFactory(const char *dll_name, int32_t startCheck, int32_t endCheck, int32_t systemVersion, @@ -29,14 +29,14 @@ shlibpp::SharedLibraryClassFactory::SharedLibraryClassFactory(const char *dll } template -shlibpp::SharedLibraryClassFactory::SharedLibraryClassFactory(const char *dll_name, +sharedlibpp::SharedLibraryClassFactory::SharedLibraryClassFactory(const char *dll_name, const char *factoryName) : SharedLibraryFactory(dll_name, factoryName) { } template -T* shlibpp::SharedLibraryClassFactory::create() const +T* sharedlibpp::SharedLibraryClassFactory::create() const { if (!isValid()) { return nullptr; @@ -45,7 +45,7 @@ T* shlibpp::SharedLibraryClassFactory::create() const } template -void shlibpp::SharedLibraryClassFactory::destroy(T *obj) const +void sharedlibpp::SharedLibraryClassFactory::destroy(T *obj) const { if (!isValid()) { return; diff --git a/src/shlibpp/SharedLibraryClassFactory.h b/src/sharedlibpp/SharedLibraryClassFactory.h similarity index 89% rename from src/shlibpp/SharedLibraryClassFactory.h rename to src/sharedlibpp/SharedLibraryClassFactory.h index e0826a2..075b6c0 100644 --- a/src/shlibpp/SharedLibraryClassFactory.h +++ b/src/sharedlibpp/SharedLibraryClassFactory.h @@ -9,10 +9,10 @@ #ifndef SHAREDLIBPP_SHAREDLIBRARYCLASSFACTORY_H #define SHAREDLIBPP_SHAREDLIBRARYCLASSFACTORY_H -#include -#include +#include +#include -namespace shlibpp { +namespace sharedlibpp { /** * A type-safe wrapper for SharedLibraryFactory, committing to @@ -44,8 +44,8 @@ class SharedLibraryClassFactory : public SharedLibraryFactory void destroy(T *obj) const; }; -} // namespace shlibpp +} // namespace sharedlibpp -#include +#include #endif // SHAREDLIBPP_SHAREDLIBRARYCLASSFACTORY_H diff --git a/src/shlibpp/SharedLibraryFactory.h b/src/sharedlibpp/SharedLibraryFactory.h similarity index 99% rename from src/shlibpp/SharedLibraryFactory.h rename to src/sharedlibpp/SharedLibraryFactory.h index 2ad2e27..fc2d9b9 100644 --- a/src/shlibpp/SharedLibraryFactory.h +++ b/src/sharedlibpp/SharedLibraryFactory.h @@ -9,11 +9,11 @@ #ifndef SHAREDLIBPP_SHAREDLIBRARYFACTORY_H #define SHAREDLIBPP_SHAREDLIBRARYFACTORY_H -#include +#include #include #include -namespace shlibpp { +namespace sharedlibpp { struct SharedLibraryClassApi; @@ -244,6 +244,6 @@ class SHLIBPP_API SharedLibraryFactory #endif }; -} // namespace shlibpp +} // namespace sharedlibpp #endif // SHAREDLIBPP_SHAREDLIBRARYFACTORY_H diff --git a/src/shlibpp/api.h b/src/sharedlibpp/api.h similarity index 100% rename from src/shlibpp/api.h rename to src/sharedlibpp/api.h diff --git a/src/shlibpp/config.h.in b/src/sharedlibpp/config.h.in similarity index 100% rename from src/shlibpp/config.h.in rename to src/sharedlibpp/config.h.in diff --git a/src/shlibpp/version.h.in b/src/sharedlibpp/version.h.in similarity index 62% rename from src/shlibpp/version.h.in rename to src/sharedlibpp/version.h.in index 0249e76..660ae85 100644 --- a/src/shlibpp/version.h.in +++ b/src/sharedlibpp/version.h.in @@ -9,21 +9,21 @@ #ifndef SHAREDLIBPP_VERSION_H #define SHAREDLIBPP_VERSION_H -#include +#include #include -#define SHLIBPP_VERSION_MAJOR @shlibpp_VERSION_MAJOR@ -#define SHLIBPP_VERSION_MINOR @shlibpp_VERSION_MINOR@ -#define SHLIBPP_VERSION_PATCH @shlibpp_VERSION_PATCH@ -#define SHLIBPP_VERSION "@shlibpp_VERSION@" +#define SHLIBPP_VERSION_MAJOR @sharedlibpp_VERSION_MAJOR@ +#define SHLIBPP_VERSION_MINOR @sharedlibpp_VERSION_MINOR@ +#define SHLIBPP_VERSION_PATCH @sharedlibpp_VERSION_PATCH@ +#define SHLIBPP_VERSION "@sharedlibpp_VERSION@" -namespace shlibpp { +namespace sharedlibpp { SHLIBPP_API int getVersionMajor(); SHLIBPP_API int getVersionMinor(); SHLIBPP_API int getVersionPatch(); SHLIBPP_API std::string getVersion(); -} // namespace shlibpp +} // namespace sharedlibpp #endif // SHAREDLIBPP_VERSION_H diff --git a/src/version.cpp b/src/version.cpp index 935d287..a48120b 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -6,24 +6,24 @@ * BSD-3-Clause license. See the accompanying LICENSE file for details. */ -#include +#include -int shlibpp::getVersionMajor() +int sharedlibpp::getVersionMajor() { return SHLIBPP_VERSION_MAJOR; } -int shlibpp::getVersionMinor() +int sharedlibpp::getVersionMinor() { return SHLIBPP_VERSION_MINOR; } -int shlibpp::getVersionPatch() +int sharedlibpp::getVersionPatch() { return SHLIBPP_VERSION_PATCH; } -std::string shlibpp::getVersion() +std::string sharedlibpp::getVersion() { return SHLIBPP_VERSION; }