X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkCommon.h;h=2f5b26f1173b3e5e94999816031695c13cb2afc4;hb=97a3a9ed3f33ab0316bd4613c8aae404de40dad1;hp=31f28dc40637bd95e91dfec7974f23183edd43ac;hpb=573d80d0f7a17607d2ee883c21c940c0ba020282;p=clitk.git diff --git a/common/clitkCommon.h b/common/clitkCommon.h index 31f28dc..2f5b26f 100644 --- a/common/clitkCommon.h +++ b/common/clitkCommon.h @@ -38,16 +38,37 @@ #if defined(unix) || defined(__APPLE__) # include # include -#elif defined(WIN32) +#elif defined(_WIN32) # include +# include #endif +#define VTK_EXCLUDE_STRSTREAM_HEADERS + //-------------------------------------------------------------------- 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 +230,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