# HG changeset patch # User Sebastien Jodogne # Date 1433152258 -7200 # Node ID 704de8c30ff5163e0441296d4baa5c8ecbb9c962 # Parent ac4efabeb80cd77c80fa431b57b7fa72bb12db55 modularization diff -r ac4efabeb80c -r 704de8c30ff5 Core/FileStorage/FilesystemStorage.cpp --- a/Core/FileStorage/FilesystemStorage.cpp Mon Jun 01 11:15:55 2015 +0200 +++ b/Core/FileStorage/FilesystemStorage.cpp Mon Jun 01 11:50:58 2015 +0200 @@ -41,7 +41,10 @@ #include "../Uuid.h" #include + +#if HAVE_GOOGLE_LOG == 1 #include +#endif static std::string ToString(const boost::filesystem::path& p) { @@ -82,7 +85,7 @@ //root_ = boost::filesystem::absolute(root).string(); root_ = root; - Toolbox::CreateDirectory(root); + Toolbox::MakeDirectory(root); } void FilesystemStorage::Create(const std::string& uuid, @@ -212,7 +215,10 @@ void FilesystemStorage::Remove(const std::string& uuid, FileContentType /*type*/) { +#if HAVE_GOOGLE_LOG == 1 LOG(INFO) << "Deleting file " << uuid; +#endif + namespace fs = boost::filesystem; fs::path p = GetPath(uuid); diff -r ac4efabeb80c -r 704de8c30ff5 Core/ImageFormats/ImageAccessor.cpp --- a/Core/ImageFormats/ImageAccessor.cpp Mon Jun 01 11:15:55 2015 +0200 +++ b/Core/ImageFormats/ImageAccessor.cpp Mon Jun 01 11:50:58 2015 +0200 @@ -38,8 +38,12 @@ #include #include +#include + +#if HAVE_GOOGLE_LOG == 1 #include -#include +#endif + namespace Orthanc { @@ -104,7 +108,10 @@ { if (readOnly_) { +#if HAVE_GOOGLE_LOG == 1 LOG(ERROR) << "Trying to write on a read-only image"; +#endif + throw OrthancException(ErrorCode_ReadOnly); } @@ -129,7 +136,10 @@ { if (readOnly_) { +#if HAVE_GOOGLE_LOG == 1 LOG(ERROR) << "Trying to write on a read-only image"; +#endif + throw OrthancException(ErrorCode_ReadOnly); } diff -r ac4efabeb80c -r 704de8c30ff5 Core/Toolbox.cpp --- a/Core/Toolbox.cpp Mon Jun 01 11:15:55 2015 +0200 +++ b/Core/Toolbox.cpp Mon Jun 01 11:50:58 2015 +0200 @@ -35,16 +35,27 @@ #include "OrthancException.h" +#include #include #include #include #include -#include #include +#include #include #include + +#if BOOST_HAS_DATE_TIME == 1 +#include +#endif + +#if BOOST_HAS_REGEX == 1 #include +#endif + +#if HAVE_GOOGLE_LOG == 1 #include +#endif #if defined(_WIN32) #include @@ -699,11 +710,15 @@ return true; } + +#if BOOST_HAS_DATE_TIME == 1 std::string Toolbox::GetNowIsoString() { boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); return boost::posix_time::to_iso_string(now); } +#endif + std::string Toolbox::StripSpaces(const std::string& source) { @@ -805,6 +820,7 @@ } +#if BOOST_HAS_REGEX == 1 std::string Toolbox::WildcardToRegularExpression(const std::string& source) { // TODO - Speed up this with a regular expression @@ -832,6 +848,7 @@ return result; } +#endif @@ -860,6 +877,7 @@ } +#if BOOST_HAS_REGEX == 1 void Toolbox::DecodeDataUriScheme(std::string& mime, std::string& content, const std::string& source) @@ -878,9 +896,10 @@ throw OrthancException(ErrorCode_BadFileFormat); } } +#endif - void Toolbox::CreateDirectory(const std::string& path) + void Toolbox::MakeDirectory(const std::string& path) { if (boost::filesystem::exists(path)) { @@ -1054,7 +1073,10 @@ if (pid == -1) { // Error in fork() +#if HAVE_GOOGLE_LOG == 1 LOG(ERROR) << "Cannot fork a child process"; +#endif + throw OrthancException(ErrorCode_SystemCommand); } else if (pid == 0) @@ -1074,7 +1096,10 @@ if (status != 0) { +#if HAVE_GOOGLE_LOG == 1 LOG(ERROR) << "System command failed with status code " << status; +#endif + throw OrthancException(ErrorCode_SystemCommand); } } diff -r ac4efabeb80c -r 704de8c30ff5 Core/Toolbox.h --- a/Core/Toolbox.h Mon Jun 01 11:15:55 2015 +0200 +++ b/Core/Toolbox.h Mon Jun 01 11:50:58 2015 +0200 @@ -122,24 +122,30 @@ std::string StripSpaces(const std::string& source); +#if BOOST_HAS_DATE_TIME == 1 std::string GetNowIsoString(); +#endif // In-place percent-decoding for URL void UrlDecode(std::string& s); Endianness DetectEndianness(); +#if BOOST_HAS_REGEX == 1 std::string WildcardToRegularExpression(const std::string& s); +#endif void TokenizeString(std::vector& result, const std::string& source, char separator); +#if BOOST_HAS_REGEX == 1 void DecodeDataUriScheme(std::string& mime, std::string& content, const std::string& source); +#endif - void CreateDirectory(const std::string& path); + void MakeDirectory(const std::string& path); bool IsExistingFile(const std::string& path); diff -r ac4efabeb80c -r 704de8c30ff5 Plugins/Engine/SharedLibrary.h --- a/Plugins/Engine/SharedLibrary.h Mon Jun 01 11:15:55 2015 +0200 +++ b/Plugins/Engine/SharedLibrary.h Mon Jun 01 11:50:58 2015 +0200 @@ -36,6 +36,10 @@ #include +#if defined(_WIN32) +#include +#endif + namespace Orthanc { class SharedLibrary : boost::noncopyable diff -r ac4efabeb80c -r 704de8c30ff5 Resources/CMake/BoostConfiguration.cmake --- a/Resources/CMake/BoostConfiguration.cmake Mon Jun 01 11:15:55 2015 +0200 +++ b/Resources/CMake/BoostConfiguration.cmake Mon Jun 01 11:50:58 2015 +0200 @@ -152,3 +152,9 @@ -DBOOST_HAS_LOCALE=1 ) endif() + + +add_definitions( + -DBOOST_HAS_DATE_TIME=1 + -DBOOST_HAS_REGEX=1 + ) diff -r ac4efabeb80c -r 704de8c30ff5 Resources/CMake/GoogleLogConfiguration.cmake --- a/Resources/CMake/GoogleLogConfiguration.cmake Mon Jun 01 11:15:55 2015 +0200 +++ b/Resources/CMake/GoogleLogConfiguration.cmake Mon Jun 01 11:50:58 2015 +0200 @@ -174,3 +174,5 @@ else() add_definitions(-DHAVE_SECURE_STRING_EXTENSIONS=0) endif() + +add_definitions(-DHAVE_GOOGLE_LOG=1) diff -r ac4efabeb80c -r 704de8c30ff5 UnitTestsSources/UnitTestsMain.cpp --- a/UnitTestsSources/UnitTestsMain.cpp Mon Jun 01 11:15:55 2015 +0200 +++ b/UnitTestsSources/UnitTestsMain.cpp Mon Jun 01 11:50:58 2015 +0200 @@ -802,7 +802,7 @@ google::InitGoogleLogging("Orthanc"); - Toolbox::CreateDirectory("UnitTestsResults"); + Toolbox::MakeDirectory("UnitTestsResults"); OrthancInitialize(); ::testing::InitGoogleTest(&argc, argv);