X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkCommon.h;h=8cd82fbe0b0bc1b20f38876368f0d6348615b1a9;hb=d7f456d86ca398a89ccf9de43ab68a2b50b8ca1f;hp=31f28dc40637bd95e91dfec7974f23183edd43ac;hpb=573d80d0f7a17607d2ee883c21c940c0ba020282;p=clitk.git diff --git a/common/clitkCommon.h b/common/clitkCommon.h index 31f28dc..8cd82fb 100644 --- a/common/clitkCommon.h +++ b/common/clitkCommon.h @@ -38,8 +38,9 @@ #if defined(unix) || defined(__APPLE__) # include # include -#elif defined(WIN32) +#elif defined(_WIN32) # include +# include #endif //-------------------------------------------------------------------- @@ -48,6 +49,24 @@ namespace clitk { typedef unsigned char uchar; typedef unsigned short ushort; typedef unsigned int uint; + +#define CLITK_TRY_CATCH_EXIT(func) \ + try { \ + func; \ + } \ + catch (const itk::ExceptionObject& e) { \ + e.Print(std::cout); \ + exit(-1);\ + } \ + catch (const std::exception& e) { \ + std::cout << e.what() << std::endl; \ + exit(-2);\ + } \ + catch (...) { \ + std::cout << "Unknown excpetion" << std::endl; \ + exit(-3); \ + } + //-------------------------------------------------------------------- // when everything goes wrong @@ -209,6 +228,18 @@ namespace clitk { //-------------------------------------------------------------------- void PrintMemoryUsed(); + //-------------------------------------------------------------------- + // Convert a map to a vector + template + void MapToVecFirst(const M & m, V & v); + template + void MapToVecSecond(const M & m, V & v); + + //-------------------------------------------------------------------- + // Find/replace string + template + int inline findAndReplace(T& source, const T& find, const T& replace); + #include "clitkCommon.txx" } // end namespace